-
Notifications
You must be signed in to change notification settings - Fork 711
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
Document how to create code blocks with syntax highlighting #917
Comments
What do your docstrings look like? Highlighting works for us using this style: /**
* Here is a docstring that contains some code...
*
* Code example:
* ```js
* function foo() {
* console.log('Welcome to foo');
* }
* ```
*/
public methodA() {
// ...
} |
Would it be better if TypeDoc defaulted code to TypeScript? |
@jonchardy Thanks a lot. Works now. Instead, I found this:
on https://highlightjs.org/usage/ @aciccarello: Now that I know the syntax I can mark code as Typescript - however, of course it makes sense to default typedoc to typescript. |
why would typedoc/src/lib/output/plugins/MarkedPlugin.ts /**
* Highlight the synatx of the given text using HighlightJS.
*
* @param text The text taht should be highlightes.
* @param lang The language that should be used to highlight the string.
* @return A html string with syntax highlighting.
*/
public getHighlighted(text: string, lang?: string): string {
try {
if (lang) {
return HighlightJS.highlight(lang, text).value;
} else {
return HighlightJS.highlightAuto(text).value;
}
} catch (error) {
this.application.logger.warn(error.message);
return text;
}
} anyhow, if we wanted to default the language to typescript, we could just set the default param ( |
Yes, works without 'ts'. Thanks. No need for default param. |
That's true, it should be autodetecting the language. We can add a note about code fences and highlightjs to the doccomments documentation. |
is typedoc-site the right place to submit a PR on that? |
TypeDoc's howto document is here: TypeDoc and links to HighlightJS on github. |
@9oelM I'm working on some changes to the website infrastructure so I'll make this change myself. Thanks! |
@aciccarello great! looking forward to seeing the website also getting optimized for mobile view. |
I use TypeDoc successfully now, but I can't get Highlight.js make my example code being highlighted.
I installed TypeDoc as a local development package (--save-dev) and I think it installed highlight.js automatically. However, because there was no highlighting happening, I updated highlight.js.
I don't really know why things don't work.
I used some example Code in a .ts code file comment (/** I put example code like code you can see below here */) as well as in my introductory .md markup file.
Nothing works, also not with a class indicator, neither Typescript, typescript, TypeScript or ts.
My example code simply was something like:
myExampleFunc(n: a.INotification): string {
this.ExampleResource.markUsed({ id: n.Id });
return "OK";
}
Can anyone help me get this running?
The text was updated successfully, but these errors were encountered: