mirror of
https://github.com/XeroAlpha/sapi-typedoc.git
synced 2024-11-22 17:48:50 +00:00
This commit is contained in:
parent
65748e7b56
commit
09d85524e2
@ -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();
|
||||
|
@ -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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user