Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add output file path and source file path to MarkedPlugin error message #1561

Merged
merged 1 commit into from Apr 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/lib/output/plugins/MarkedPlugin.ts
Expand Up @@ -82,6 +82,9 @@ export class MarkedPlugin extends ContextAwareRendererComponent {
*/
private mediaPattern = /media:\/\/([^ ")\]}]+)/g;

private sources?: { fileName: string; line: number }[];
private outputFileName?: string;

/**
* Create a new MarkedPlugin instance.
*/
Expand All @@ -92,6 +95,9 @@ export class MarkedPlugin extends ContextAwareRendererComponent {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const that = this;
Handlebars.registerHelper("markdown", function (this: any, arg: any) {
const root = arg.data.root;
that.outputFileName = root.filename;
that.sources = root.model.sources;
return that.parseMarkdown(arg.fn(this), this);
});
Handlebars.registerHelper("relativeURL", (url: string) =>
Expand All @@ -111,9 +117,13 @@ export class MarkedPlugin extends ContextAwareRendererComponent {
lang = lang.toLowerCase();
if (!isSupportedLanguage(lang)) {
// Extra newline because of the progress bar
this.application.logger.warn(
`\nUnsupported highlight language "${lang}" will not be highlighted. Run typedoc --help for a list of supported languages.`
);
this.application.logger.warn(`
Unsupported highlight language "${lang}" will not be highlighted. Run typedoc --help for a list of supported languages.
target code block :
\t${text.split("\n").join("\n\t")}
source files :${this.sources?.map((source) => `\n\t${source.fileName}`).join()}
output file :
\t${this.outputFileName}`);
return text;
}

Expand Down