Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Theme

Base class of all themes.

A theme defines the logical and graphical output of a documentation. Themes are directories containing a theme.js file defining a [[BaseTheme]] subclass and a series of subdirectories containing templates and assets. You can select a theme through the --theme <path/to/theme> commandline argument.

The theme class controls which files will be created through the [[BaseTheme.getUrls]] function. It returns an array of UrlMapping instances defining the target files, models and templates to use. Additionally themes can subscribe to the events emitted by Renderer to control and manipulate the output process.

The default file structure of a theme looks like this:

  • /assets/
    Contains static assets like stylesheets, images or javascript files used by the theme. The AssetsPlugin will deep copy this directory to the output directory.

  • /layouts/
    Contains layout templates that the LayoutPlugin wraps around the output of the page template. Currently only one default.hbs layout is supported. Layout templates receive the current PageEvent instance as their handlebars context. Place the {{{contents}}} variable to render the actual body of the document within this template.

  • /partials/
    Contains partial templates that can be used by other templates using handlebars partial syntax {{> partial-name}}. The [[PartialsPlugin]] loads all files in this directory and combines them with the partials of the default theme.

  • /templates/
    Contains the main templates of the theme. The theme maps models to these templates through the [[BaseTheme.getUrls]] function. If the [[Renderer.getTemplate]] function cannot find a given template within this directory, it will try to find it in the default theme /templates/ directory. Templates receive the current PageEvent instance as their handlebars context. You can access the target model through the {{model}} variable.

  • /theme.js
    A javascript file that returns the definition of a [[BaseTheme]] subclass. This file will be executed within the context of TypeDoc, one may directly access all classes and functions of TypeDoc. If this file is not present, an instance of DefaultTheme will be used to render this theme.

Hierarchy

Implements

Index

Constructors

constructor

Properties

basePath

basePath: string

The base path of this theme.

componentName

componentName: string

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

resources

resources: Resources

Accessors

application

owner

Methods

Protected bubble

getNavigation

  • Create a navigation structure for the given project.

    A navigation is a tree structure consisting of NavigationItem nodes. This function should return the root node of the desired navigation tree.

    The NavigationPlugin will call this hook before a project will be rendered. The plugin will update the state of the navigation tree and pass it to the templates.

    Parameters

    Returns NavigationItem

    The root navigation item.

getOptionDeclarations

getUrls

  • Map the models of the given project to the desired output files.

    Every theme must have an own implementation of this function, the default implementation always returns an empty array.

    Parameters

    Returns UrlMapping[]

    A list of UrlMapping instances defining which models should be rendered to which files.

Protected initialize

  • initialize(): void

isOutputDirectory

  • isOutputDirectory(path: string): boolean
  • Test whether the given path contains a documentation generated by this theme.

    TypeDoc empties the output directory before rendering a project. This function is used to ensure that only previously generated documentations are deleted. When this function returns FALSE, the documentation will not be created and an error message will be displayed.

    Every theme must have an own implementation of this function, the default implementation always returns FALSE.

    see

    Renderer.prepareOutputDirectory

    Parameters

    • path: string

      The path of the directory that should be tested.

    Returns boolean

    TRUE if the given path seems to be a previous output directory, otherwise FALSE.

listenTo

listenToOnce

off

  • off(): any
  • off(eventMap: EventMap, context?: any): any
  • off(name: string, callback?: EventCallback, context?: any): any

on

  • on(eventMap: EventMap, context?: any): any
  • on(eventMap: EventMap, callback?: EventCallback, context?: any, priority?: number): any
  • on(name: string, callback: EventCallback, context?: any, priority?: number): any

once

  • once(eventMap: EventMap, context?: any): any
  • once(name: string, callback: EventCallback, context?: any, priority?: any): any
  • Bind an event to only be triggered a single time. After the first time the callback is invoked, its listener will be removed. If multiple events are passed in using the space-separated syntax, the handler will fire once for each event, not once for a combination of all events.

    Parameters

    • eventMap: EventMap
    • Optional context: any

    Returns any

  • Parameters

    • name: string
    • callback: EventCallback
    • Optional context: any
    • Optional priority: any

    Returns any

stopListening

trigger

  • Trigger one or many events, firing all bound callbacks. Callbacks are passed the same arguments as trigger is, apart from the event name (unless you're listening on "all", which will cause your callback to receive the true name of the event as the first argument).

    Parameters

    Returns this

Generated using TypeDoc