Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"globals": "^17.6.0",
"husky": "^9.1.7",
"lint-staged": "^17.0.5",
"prettier": "^3.8.3"
"prettier": "^3.8.3",
"typedoc-plugin-missing-exports": "^4.1.3"
}
}
30 changes: 30 additions & 0 deletions plugins/processor/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { applySourceMetadata } from './source.mjs';
import { DocKitRouter } from './router.mjs';
import { sidebar } from './site.mjs';
import { createTypeMap } from './typeMap.mjs';
import { categoryForReflection } from '../shared/categories.mjs';

/**
* @param {import('typedoc-plugin-markdown').MarkdownApplication} app
Expand Down Expand Up @@ -40,6 +41,35 @@ export function load(app) {
applySourceMetadata(context.project);
});

app.converter.on(Converter.EVENT_RESOLVE_END, context => {
const project = context.project;

const internalModules = project.children?.filter(
c => c.name === '<internal>'
);
if (internalModules) {
internalModules.forEach(internalModule => {
const importantTypes = [];
const noiseTypes = [];

if (internalModule.children) {
internalModule.children.forEach(child => {
if (categoryForReflection(child)) {
importantTypes.push(child);
} else {
noiseTypes.push(child);
}
});
}

noiseTypes.forEach(noise => project.removeReflection(noise));
internalModule.children = importantTypes;

project.mergeReflections(internalModule, project);
});
}
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to adjust createTypePages() to also check <internal>, that way we reduce the code duplication?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when I searched for where I will write the code, I found that Converter.EVENT_RESOLVE_END is much safer and cleaner, I think of it as Early Garbage Collection, The plugin actually extracts over 600+ types (mostly internal dependencies/noise), but we only need about ~300 (increased from ~60 to ~300). By filtering and deleting the noise before the routing phase, we prevent TypeDoc from wasting memory, building URLs, or assigning them to groups and categories.

And using Separation of Concerns keep things clean. This early hook handles the AST extraction and cleanup, while createTypePages() remains strictly focused on routing.

WDUT?

app.renderer.on(Renderer.EVENT_END, () => {
// doc-kit resolves custom type annotations from this map while generating
// HTML, so use the final router URLs instead of recomputing paths here.
Expand Down
2 changes: 2 additions & 0 deletions scripts/markdown.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const app = await Application.bootstrapWithPlugins({
// Plugins
plugin: [
'typedoc-plugin-markdown',
'typedoc-plugin-missing-exports',
'./plugins/processor/index.mjs',
'./plugins/theme/index.mjs',
],
Expand All @@ -28,6 +29,7 @@ const app = await Application.bootstrapWithPlugins({
modulesFileName: 'index',
entryFileName: 'index',
tsconfig: 'tsconfig.json',
excludeExternals: true,
});

const project = await app.convert();
Expand Down