Skip to content
@ng-doc/app / Class

NgDocHighlighterService

Highlights code with Shiki. provideNgDocApp starts its initialization where it is provided (the application, or the route that holds the documentation), and the server render waits for it. Shiki is loaded on demand: initialize() imports it.

Decorators
@Service
Implements
OnDestroy
DeclarationTypeScript
@Service()
export class NgDocHighlighterService implements OnDestroy { … }

Members

Properties

2
ready: Signal<boolean>
readonly

Whether highlight() can highlight: true once initialize() has finished, and false again after the service is destroyed.

protectedreadonly
—

Methods

3
(…): string

Returns the code as highlighted HTML, or an empty string before initialize() has finished. It reads ready(), so a computed over it updates once Shiki is loaded.

(…): Promise<void>

Loads Shiki with the built-in themes (github-light, ayu-dark and NgDoc's css-variables) and the given ones, and the given languages. Concurrent and repeated calls share one initialization; a failed one can be retried.

(): void
implements OnDestroy

Disposes the highlighter this service created for custom themes or languages.

Symbol
Kind
Class
Decorators
@Service
Implements
OnDestroy
Scope
@ng-doc/app
Edit this page