同步更改:修复示例文档对应URL
Some checks failed
Deploy / deploy (push) Has been cancelled

This commit is contained in:
ProjectXero 2024-10-04 16:41:47 +08:00
commit f54860cf08
No known key found for this signature in database
GPG Key ID: 5B1AA72F4425593E
2 changed files with 8 additions and 8 deletions

View File

@ -2,7 +2,7 @@ const TypeDoc = require('typedoc');
const { Project } = require('ts-morph');
const { createRequire } = require('module');
const { resolve: resolvePath, relative: relativePath } = require('path');
const { existsSync, readFileSync, readdirSync, mkdirSync, writeFileSync } = require('fs');
const { existsSync, readFileSync, readdirSync, mkdirSync, writeFileSync, rmSync } = require('fs');
const { split, replacePieces } = require('./split.js');
const { execSync } = require('child_process');
const { loadHooks } = require('./hooks.js');
@ -198,6 +198,7 @@ async function build(translated) {
},
[new TypeDoc.TSConfigReader()]
);
rmSync(distPath, { recursive: true, force: true });
Object.assign(hookEventContext, { tsdocApplication });
await runHooks('beforeConvert', hookEventContext);
const tsdocProject = await tsdocApplication.convert();

View File

@ -152,6 +152,10 @@ module.exports = {
afterConvert({ tsdocProject }) {
const exampleRefls = [];
// 添加 example 页面
const exampleParentRef = new DocumentReflection('示例', tsdocProject, [], { title: '示例' });
exampleParentRef._alias = 'examples';
tsdocProject.registerReflection(exampleParentRef);
tsdocProject.addChild(exampleParentRef);
for (const exampleName of Object.keys(examples).sort()) {
const exampleVersions = examples[exampleName];
const content = [];
@ -207,16 +211,11 @@ module.exports = {
text: '\n\n'
});
}
const docRef = new DocumentReflection(exampleName, tsdocProject, content, { title: exampleName });
const docRef = new DocumentReflection(exampleName, exampleParentRef, content, { title: exampleName });
tsdocProject.registerReflection(docRef);
exampleRefls.push([exampleName, docRef, exampleVersions]);
exampleParentRef.addChild(docRef);
}
const exampleParentRef = new DocumentReflection('示例', tsdocProject, [], { title: '示例' });
for (const exampleRefl of exampleRefls) {
exampleParentRef.addChild(exampleRefl[1]);
}
tsdocProject.registerReflection(exampleParentRef);
tsdocProject.addChild(exampleParentRef);
// 修正 @example 引用
for (const refl of Object.values(tsdocProject.reflections)) {