3.2 KiB
Documentation.js supports customizable themes for HTML output. A theme is a Node.js module that exports a single function with the following signature:
/**
* @function
* @param {Array<Object>} comments - an array of comments to be output
* @param {Object} options - theme options
* @param {ThemeCallback} callback - see below
*/
/**
* @callback ThemeCallback
* @param {?Error} error
* @param {?Array<vinyl.File>} output
*/
The theme function should call the callback with either an error, if one occurs,
or an array of vinyl File objects.
The theme is free to implement HTML generation however it chooses. See the default theme for some ideas.
Customizing the Default Theme
Instructions
-
Copy contents of
default_themefolder (noted above) into a new folder in your project. One way to do it is to create a new git repository with the folder contents and add this line to yourpackage.jsondevDependenciessection:"docjs-theme": "my-gh-username/reponame". That way when you install dependencies, your new theme will be in the projectsnode_modulesfolder. -
In the folder you created, replace
require('../')on lines 8 and 9 ofindex.jswithrequire('documentation')and save. -
You can now make changes that will show up when you generate your docs using your theme. Example
package.jsonscriptsentry:"documentation build index.js -f html -o docs --theme node_modules/docjs-theme"
Changes to Default Theme Via documentation.yml
If a documentation.yml file is used to establish a table of contents for your documentation, small changes to the default style can be made via a