Class Renderer

The renderer processes a ProjectReflection using a Theme instance and writes the emitted html documents to a output directory. You can specify which theme should be used using the --theme <name> command line argument.

Renderer is a subclass of EventDispatcher and triggers a series of events while a project is being processed. You can listen to these events to control the flow or manipulate the output.

Hierarchy

Accessors

cacheBust: any
  • get owner(): O
  • Return the owner of this component.

    Returns O

Constructors

Events

EVENT_BEGIN: "beginRender" = RendererEvent.BEGIN
EVENT_BEGIN_PAGE: "beginPage" = PageEvent.BEGIN
EVENT_END: "endRender" = RendererEvent.END
EVENT_END_PAGE: "endPage" = PageEvent.END
EVENT_PREPARE_INDEX: "prepareIndex" = IndexEvent.PREPARE_INDEX

Methods

  • Define a new theme that can be used to render output. This API will likely be changing at some point, to allow more easily overriding parts of the theme without requiring additional boilerplate.

    Parameters

    Returns void

  • Stops listening to an event.

    Type Parameters

    Parameters

    • event: K

      the event to stop listening to.

    • listener: (this: undefined, ...args: RendererEvents[K]) => void

      the function to remove from the listener array.

    Returns void

  • Starts listening to an event.

    Type Parameters

    Parameters

    • event: K

      the event to listen to.

    • listener: (this: undefined, ...args: RendererEvents[K]) => void

      function to be called when an this event is emitted.

    • priority: number = 0

      optional priority to insert this hook with.

    Returns void

  • Render the given project reflection to the specified output directory.

    Parameters

    • project: Models.ProjectReflection

      The project that should be rendered.

    • outputDirectory: string

      The path of the directory the documentation should be rendered to.

    Returns Promise<void>

Properties

componentName: string

The name of this component as set by the @Component decorator.

Hooks which will be called when rendering pages. Note:

  • Hooks added during output will be discarded at the end of rendering.
  • Hooks added during a page render will be discarded at the end of that page's render.

See RendererHooks for a description of each available hook, and when it will be called.

markedPlugin: MarkedPlugin
postRenderAsyncJobs: (output: RendererEvent) => Promise<void>[] = []

A list of async jobs which must be completed after rendering output files but before generation is considered successful. These functions will be called after all documents have been written to the filesystem.

This may be used by plugins to register work that must be done to finalize output files. For example: asynchronously generating an image referenced in a render hook.

Note: This array is cleared after calling the contained functions on each Renderer.render call.

preRenderAsyncJobs: (output: RendererEvent) => Promise<void>[] = []

A list of async jobs which must be completed before rendering output. They will be called after RendererEvent.BEGIN has fired, but before any files have been written.

This may be used by plugins to register work that must be done to prepare output files. For example: asynchronously transform markdown to HTML.

Note: This array is cleared after calling the contained functions on each Renderer.render call.

renderStartTime: number = -1
theme?: Theme

The theme that is used to render the documentation.