diff --git a/plugins/processor/index.mjs b/plugins/processor/index.mjs index 42c34cd..3f53030 100644 --- a/plugins/processor/index.mjs +++ b/plugins/processor/index.mjs @@ -1,4 +1,6 @@ import { Converter, ReflectionKind, Renderer } from 'typedoc'; +import { MarkdownPageEvent } from 'typedoc-plugin-markdown'; +import { getSourceMetadata } from './metadata.mjs'; import { writeFileSync } from 'node:fs'; import { join } from 'node:path'; import { applyExportEqualsReflections } from './exportEquals.mjs'; @@ -62,6 +64,17 @@ export function load(app) { } }); + app.renderer.on(MarkdownPageEvent.END, page => { + const sourceMeta = getSourceMetadata(page.model); + + if (sourceMeta && sourceMeta.sourceRelativePath) { + const source = `https://github.com/webpack/webpack/edit/main/lib/${sourceMeta.sourceRelativePath}`; + const frontmatter = `---\n` + `source: ${source}\n` + `---\n\n`; + + page.contents = frontmatter + page.contents; + } + }); + 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.