Skip to content

Markdown and template syntax

A cheat sheet of the syntax that NgDoc adds to Markdown, templates, source files and doc comments.

Code block attributes

Attributes follow the language in the opening fence of a code block, separated by spaces. See Code blocks.

AttributeFormEffect
namename="app.ts"Shows a file name. In a code group, it is the tab label.
groupgroup="install"Joins every block with the same group into tabs.
activeactiveOpens this block first in its group.
iconicon="angular"Shows an icon next to the name.
Highlighted lines{1,3-5}Highlights lines. Ranges are inclusive.
filefile="./app.ts"Loads the code from a file, relative to the Markdown file.

fileName="…" is another spelling of name. lineNumbers is accepted but has no effect. Any other attribute fails the build.

The language is optional and defaults to TypeScript. It is any Shiki language id or alias, such as c++, c# or objective-c; a language Shiki doesn't know is shown as plain text. A block with the mermaid language renders a diagram (Diagrams).

Line ranges for file

Write the range right after the closing quote, with no space.

SuffixLoads
#L5-L10Lines 5 to 10.
#L12Line 12.
#L4-Line 4 to the end of the file.

Callouts

A blockquote whose first paragraph starts with a bold kind. See Markdown and callouts.

index.mdMarkdown
> **Note**
> The text of the callout.
KindRenders as
NoteAn information callout.
WarningA warning callout.
AlertAn alert callout.
SuccessA success callout.
No bold kindA plain blockquote.

Hiding lines

A comment with ng-doc-ignore-line removes itself and the next line from code loaded with file, from demos and from snippets. Add a number to remove more lines after the comment.

CommentRemoves
// ng-doc-ignore-lineThe comment line and the next line.
// ng-doc-ignore-line 3The comment line and the next 3 lines.
/* ng-doc-ignore-line */The same, in styles.
<!-- ng-doc-ignore-line -->The same, in templates.

Snippets

Snippet comments in demo source files mark the code that a demo shows. See Snippets.

CommentEffect
// snippetStarts or ends a snippet.
// snippet "Title"Starts a snippet with a title.
// snippet icon="angular"Starts a snippet with an icon.
// snippet openedOpens this snippet first.
// snippet#idStarts or ends the snippet id, which can contain others.
// snippet:cssSets the language. Write it after the ID: snippet#id:css.
// snippet-from-file="./other.ts"Shows another file, relative to the demo file.

Snippets work in //, /* */ and <!-- --> comments. The language defaults to HTML for <!-- --> comments and to TypeScript otherwise. Prettier formats a snippet only when its language is set to ts, typescript, js, javascript, html, css, scss, less or sass.

Template tags

Markdown files are nunjucks templates. See Templates.

TagEffect
{% include "./file.md" %}Inserts another file, relative to the current file.
{% import "./macros.md" as m %}Imports the macros of another file.
{% index false %} … {% endindex %}Keeps the content out of the search index.
{{ NgDocPage.title }}Outputs a value. NgDocPage is the page configuration.

Template actions

CallRenders
NgDocActions.demo()(className, options?)A demo. Options: NgDocDemoActionOptions (Demos).
NgDocActions.demoPane()(className, options?)A demo pane. Options: NgDocDemoPaneActionOptions (Demo pane).
NgDocActions.playground()(playgroundId, options?)A playground. Options: NgDocPlaygroundOptions (Playgrounds).
NgDocApi.api()(path)The API tables of a declaration (Embed API in guides).
NgDocApi.details()(path)The details of a declaration: type parameters, decorators, selectors and heritage.
JSDoc.description()(path)The description from a declaration's doc comment.
JSDoc.tag()(path, tagName)The text of the tag with that name.
JSDoc.tags()(path, tagName)The texts of every tag with that name, as a list.
JSDoc.hasTag()(path, tagName)true if the doc comment has that tag.

path is path/to/file.ts#ExportName, relative to the workspace root. tagName has no @, for example deprecated.

Keywords

Written asLinks to
* and a page keywordA guide page. Unknown page keywords fail the build.
* and a page keyword, # and a headingA section of the page.
A declaration nameIts API page.
A declaration name, . and a memberA member of the API page. Getters and setters take get- and set-.
A declaration name, # and a headingA section of the API page.
A global keywordThe URL from the configuration file.
A page keyword or a global keyword with type: 'link', ? and a queryThe same link with query parameters. Other keywords drop the query.

See Links and keywords.

Doc comment tags

Tags in the doc comments of your API change how its API page looks. See Write doc comments.

TagEffect
@deprecated, @betaShows a warning box with the tag text.
@experimental, @alphaShows an alert box with the tag text.
@internalLeaves the declaration or member out of the API pages.
@seeAdds a link to the "See Also" section. Use keywords in the text.
@remarksAdds a note to the "Notes" section.
@exampleAdds an example to the "Example usage" section.
@usageNotesStarts the "Usage Notes" section, after the API tables.
@param name - textDescribes a parameter.
@returnsDescribes the return value.
@status:<color> <text>On a page configuration only: shows a badge in the sidebar.

The status boxes appear only when the tag has text.

Edit this page