Create a custom partial
jsdoc-to-markdown
- Home
- How jsdoc2md works
- Additional jsdoc tags supported
- Cherry picking which documentation appears in output
- Showcase ...
- Create ...
- How To ...
- How to use with npm run
- How to use with gulp
- How to create one output file per class
- How to document a AMD module
- How to document a CommonJS module (exports)
- How to document a CommonJS module (module.exports)
- How to document an ES2015 module (multiple named exports)
- How to document an ES2015 module (single default export)
- How to document Promises (using custom tags)
- How to document a ToDo list
- How to document ES2017 features
- How to document TypeScript
- The @typicalname tag
- Linking to external resources
- Param list format options
- Listing namepaths
- Troubleshooting
Clone this wiki locally
It's possible to change any part of the output by overriding the built in partials. In this example we will change the default separator. Currently, the default is -
(a single dash which renders as a thin line on Github) and the --no-gfm
(no github-flavoured markdown) option uses * * *
. We will change the default to ---
. Below is the typical workflow for finding and editing a partial.
1. Navigate to the template entry point, the main partial:
{{>main-index~}}
{{>all-docs~}}
2. You'll see the output is broken into an index section and the main documentation. Press t
on the keyboard to launch the Github file chooser then navigate to all-docs.hbs. Here we see the main docs are generated by iterating over the orphans (top-level globals and modules with no parent) rendering docs for each:
{{#orphans ~}}
{{>docs~}}
{{/orphans~}}
3. Press t
on Github again and navigate to docs.hbs. Here we discover the separator is rendered after the header, body and member-index of each identifier's documentation:
{{>header~}}
{{>body}}
{{>member-index~}}
{{>separator~}}
{{>members~}}
4. Navigate to separator.hbs, this is the partial we will edit:
{{#if (option "separators")~}}
{{#if (option "no-gfm")}}
* * *
{{else}}
-
{{/if~}}
{{/if~}}
5. Create a duplicate of the file (e.g. in your project repository). Filenames are significant in handlebars so the filename must be separator.hbs
. Now, tweak the custom partial as required:
{{#if (option "separators")~}}
{{#if (option "no-gfm")}}
* * *
{{else}}
---
{{/if~}}
{{/if~}}
6. Launch jsdoc2md supplying the path to the custom partial.
$ jsdoc2md --partial separator.hbs --files lib/*.js