Skip to content
Open
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
13 changes: 13 additions & 0 deletions plugins/processor/index.mjs
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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`;

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.

Suggested change
const frontmatter = `---\n` + `source: ${source}\n` + `---\n\n`;
const frontmatter = `---\nsource: ${source}\n---\n\n`;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I put it like that to be more readable if we add more tags in future!


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.
Expand Down