8.0 KiB
jsdoc-to-markdown
Example
const jsdoc2md = require('jsdoc-to-markdown')
- jsdoc-to-markdown
- JsdocToMarkdown ⏏
- async
- .render([options]) ⇒
Promise - .getTemplateData([options]) ⇒
Promise - .getJsdocData([options]) ⇒
Promise - .clear() ⇒
Promise
- .render([options]) ⇒
- sync
- .renderSync([options]) ⇒
string - .getTemplateDataSync([options]) ⇒
Array.<object> - .getJsdocDataSync([options]) ⇒
Array.<object>
- .renderSync([options]) ⇒
- async
- JsdocToMarkdown ⏏
JsdocToMarkdown ⏏
Kind: Exported class
jsdoc2md.render([options]) ⇒ Promise
Returns markdown documentation from jsdoc-annoted source code.
Kind: instance method of JsdocToMarkdown
Category: async
Fulfil: string - the rendered docs
| Param | Type | Description |
|---|---|---|
| [options] | object |
Accepts all getJsdocData options plus the following: |
| [options.data] | Array.<object> |
Raw template data to use. Useful when you already have template data, obtained from .getTemplateData. Either files, source or data must be supplied. |
| [options.template] | string |
The template the supplied documentation will be rendered into. Use the default or supply your own template for full control over the output. |
| [options.heading-depth] | number |
The initial heading depth. For example, with a value of 2 the top-level markdown headings look like "## The heading". |
| [options.example-lang] | string |
Specifies the default language used in @example blocks (for syntax-highlighting purposes). In gfm mode, each @example is wrapped in a fenced-code block. Example usage: --example-lang js. Use the special value none for no specific language. While using this option, you can override the supplied language for any @example by specifying the @lang subtag, e.g @example @lang hbs. Specifying @example @lang off will disable code blocks for that example. |
| [options.plugin] | string | Array.<string> |
Use an installed package containing helper and/or partial overrides. |
| [options.helper] | string | Array.<string> |
handlebars helper files to override or extend the default set. |
| [options.partial] | string | Array.<string> |
handlebars partial files to override or extend the default set. |
| [options.name-format] | string |
Format identifier names in the code style, (i.e. format using backticks or <code></code>). |
| [options.no-gfm] | boolean |
By default, dmd generates github-flavoured markdown. Not all markdown parsers render gfm correctly. If your generated docs look incorrect on sites other than Github (e.g. npmjs.org) try enabling this option to disable Github-specific syntax. |
| [options.separators] | boolean |
Put <hr> breaks between identifiers. Improves readability on bulky docs. |
| [options.module-index-format] | string |
none, grouped, table, dl. |
| [options.global-index-format] | none, grouped, table, dl. | |
| [options.param-list-format] | Two options to render parameter lists: 'list' or 'table' (default). Table format works well in most cases but switch to list if things begin to look crowded / squashed. | |
| [options.property-list-format] | list, table. | |
| [options.member-index-format] | grouped, list |
Example
Pass in filepaths (** glob matching supported) of javascript source files:
> jsdoc2md.render('lib/*.js').then(console.log)
jsdoc2md.getTemplateData([options]) ⇒ Promise
Returns template data (jsdoc-parse output).
Kind: instance method of JsdocToMarkdown
Category: async
Fulfil: object[] - the json data
| Param | Type | Description |
|---|---|---|
| [options] | object |
Identical options to getJsdocData. |
jsdoc2md.getJsdocData([options]) ⇒ Promise
Returns raw jsdoc data.
Kind: instance method of JsdocToMarkdown
Category: async
Fulfil: object[]
| Param | Type | Description |
|---|---|---|
| [options] | object |
the options |
| [options.cache] | boolean |
Set to false to disable memoisation cache. Defaults to true. |
| [options.files] | string | Array.<string> |
One or more filenames to process. Accepts globs (e.g. *.js). Either files, source or data must be supplied. |
| [options.source] | string |
A string containing source code to process. Either files, source or data must be supplied. |
| [options.configure] | string |
The path to the configuration file. Default: path/to/jsdoc/conf.json. |
| [options.html] | boolean |
Enable experimental documentation of .html files. |
jsdoc2md.clear() ⇒ Promise
Clear the cache.
Kind: instance method of JsdocToMarkdown
Category: async
jsdoc2md.renderSync([options]) ⇒ string
Sync version of render.
Kind: instance method of JsdocToMarkdown
Category: sync
Engine: nodejs >= 0.12
| Param | Type | Description |
|---|---|---|
| [options] | object |
Identical options to render. |
Example
const docs = jsdoc2md.renderSync('lib/*.js')
jsdoc2md.getTemplateDataSync([options]) ⇒ Array.<object>
Sync version of getTemplateData.
Kind: instance method of JsdocToMarkdown
Category: sync
| Param | Type | Description |
|---|---|---|
| [options] | object |
Identical options to getJsdocData. |
jsdoc2md.getJsdocDataSync([options]) ⇒ Array.<object>
Sync version of getJsdocData.
Kind: instance method of JsdocToMarkdown
Category: sync
| Param | Type | Description |
|---|---|---|
| [options] | object |
Identical options to getJsdocData. |