mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-30 03:51:25 -08:00
fix: update test generation script to use Chinese documentation and exclude specific directories
This commit is contained in:
1 parent
7bfee6c6dc
commit
0f752260a4
2 files changed
+15
-6
No files matched your search
+5
-5
@@ -1,5 +1,5 @@
|
|||||||
// Auto-generated smoke tests from documentation code blocks
|
// Auto-generated smoke tests from documentation code blocks
|
||||||
// Generated at: 2026-03-07T07:48:59.683Z
|
// Generated at: 2026-03-07T07:54:41.642Z
|
||||||
// Do not edit manually - run 'node scripts/build-test.js' to regenerate
|
// Do not edit manually - run 'node scripts/build-test.js' to regenerate
|
||||||
|
|
||||||
describe('Documentation Code Examples', function () {
|
describe('Documentation Code Examples', function () {
|
||||||
@@ -1895,7 +1895,7 @@ describe('Documentation Code Examples', function () {
|
|||||||
url: '/assets/sample/video.mp4',
|
url: '/assets/sample/video.mp4',
|
||||||
});
|
});
|
||||||
|
|
||||||
// Only destroys the UI, does not actively clear src
|
// 只销毁界面,不主动清空 src
|
||||||
art.destroy();
|
art.destroy();
|
||||||
// Wait a bit for async initialization
|
// Wait a bit for async initialization
|
||||||
setTimeout(() => done(), 100);
|
setTimeout(() => done(), 100);
|
||||||
@@ -2125,7 +2125,7 @@ describe('Documentation Code Examples', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
art.on('ready', () => {
|
art.on('ready', () => {
|
||||||
// Only reset the video, do not remove the interface
|
// 仅重置 video,不移除界面
|
||||||
art.reset();
|
art.reset();
|
||||||
});
|
});
|
||||||
// Wait a bit for async initialization
|
// Wait a bit for async initialization
|
||||||
@@ -2523,7 +2523,7 @@ describe('Documentation Code Examples', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
art.on('ready', () => {
|
art.on('ready', () => {
|
||||||
console.info(art.state); // Default: standard
|
console.info(art.state); // 默认 standard
|
||||||
art.state = 'mini';
|
art.state = 'mini';
|
||||||
});
|
});
|
||||||
// Wait a bit for async initialization
|
// Wait a bit for async initialization
|
||||||
@@ -4018,7 +4018,7 @@ describe('Documentation Code Examples', function () {
|
|||||||
var art = new Artplayer({
|
var art = new Artplayer({
|
||||||
container: '.artplayer-app',
|
container: '.artplayer-app',
|
||||||
url: '/assets/sample/video.mp4',
|
url: '/assets/sample/video.mp4',
|
||||||
backdrop: false, // Disable frosted glass effect
|
backdrop: false, // 关闭毛玻璃效果
|
||||||
});
|
});
|
||||||
// Wait a bit for async initialization
|
// Wait a bit for async initialization
|
||||||
setTimeout(() => done(), 100);
|
setTimeout(() => done(), 100);
|
||||||
|
|||||||
+10
-1
@@ -1,9 +1,13 @@
|
|||||||
import fs from 'node:fs'
|
import fs from 'node:fs'
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
|
|
||||||
const docsDir = path.resolve('packages/artplayer-vitepress/docs/en')
|
// 使用中文文档作为源(中文是原始文档,英文是 AI 翻译的)
|
||||||
|
const docsDir = path.resolve('packages/artplayer-vitepress/docs')
|
||||||
const outputFile = path.resolve('docs/test/test.js')
|
const outputFile = path.resolve('docs/test/test.js')
|
||||||
|
|
||||||
|
// 排除的目录
|
||||||
|
const excludeDirs = ['en', '.vitepress', 'public', 'plugin']
|
||||||
|
|
||||||
// Regex to match code blocks after "Run Code" markers
|
// Regex to match code blocks after "Run Code" markers
|
||||||
// Match until we find a closing ``` that's on its own line
|
// Match until we find a closing ``` that's on its own line
|
||||||
const runCodePattern = /<div className="run-code">.*?<\/div>\s*\n\s*```js[^\n]*\n([\s\S]*?)\n```(?=\s*\n|$)/g
|
const runCodePattern = /<div className="run-code">.*?<\/div>\s*\n\s*```js[^\n]*\n([\s\S]*?)\n```(?=\s*\n|$)/g
|
||||||
@@ -35,6 +39,11 @@ function processMarkdownFiles(dir, relativePath = '') {
|
|||||||
const items = fs.readdirSync(dir)
|
const items = fs.readdirSync(dir)
|
||||||
|
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
|
// 跳过排除的目录
|
||||||
|
if (excludeDirs.includes(item)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
const fullPath = path.join(dir, item)
|
const fullPath = path.join(dir, item)
|
||||||
const relPath = path.join(relativePath, item)
|
const relPath = path.join(relativePath, item)
|
||||||
const stat = fs.statSync(fullPath)
|
const stat = fs.statSync(fullPath)
|
||||||
|
|||||||
Reference in new issue
Block a user