-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
236 changed files
with
1,719 additions
and
11,008 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
repo_token: r11MtOtJBv0P70fBnfl2DHFXYilhIDJFF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
out | ||
tmp | ||
node_modules | ||
coverage | ||
tmp-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env node | ||
'use strict' | ||
var detect = require('feature-detect-es6') | ||
|
||
if (detect.all('class', 'arrowFunction', 'let', 'const')) { | ||
module.exports = require('./src/bin/cli') | ||
} else { | ||
require('core-js/es6/object') | ||
module.exports = require('./es5/bin/cli') | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
<a name="module_jsdoc-to-markdown"></a> | ||
|
||
# jsdoc-to-markdown | ||
**Example** | ||
```js | ||
const jsdoc2md = require('jsdoc-to-markdown') | ||
``` | ||
|
||
* [jsdoc-to-markdown](#module_jsdoc-to-markdown) | ||
* [JsdocToMarkdown](#exp_module_jsdoc-to-markdown--JsdocToMarkdown) ⏏ | ||
* _async_ | ||
* [.render([options])](#module_jsdoc-to-markdown--JsdocToMarkdown+render) ⇒ <code>Promise</code> | ||
* [.getTemplateData([options])](#module_jsdoc-to-markdown--JsdocToMarkdown+getTemplateData) ⇒ <code>Promise</code> | ||
* [.getJsdocData([options])](#module_jsdoc-to-markdown--JsdocToMarkdown+getJsdocData) ⇒ <code>Promise</code> | ||
* [.clear()](#module_jsdoc-to-markdown--JsdocToMarkdown+clear) ⇒ <code>Promise</code> | ||
* _sync_ | ||
* [.renderSync([options])](#module_jsdoc-to-markdown--JsdocToMarkdown+renderSync) ⇒ <code>string</code> | ||
* [.getTemplateDataSync([options])](#module_jsdoc-to-markdown--JsdocToMarkdown+getTemplateDataSync) ⇒ <code>Array.<object></code> | ||
* [.getJsdocDataSync([options])](#module_jsdoc-to-markdown--JsdocToMarkdown+getJsdocDataSync) ⇒ <code>Array.<object></code> | ||
|
||
|
||
- | ||
|
||
<a name="exp_module_jsdoc-to-markdown--JsdocToMarkdown"></a> | ||
|
||
## JsdocToMarkdown ⏏ | ||
**Kind**: Exported class | ||
|
||
- | ||
|
||
<a name="module_jsdoc-to-markdown--JsdocToMarkdown+render"></a> | ||
|
||
### jsdoc2md.render([options]) ⇒ <code>Promise</code> | ||
Returns markdown documentation from jsdoc-annoted source code. | ||
|
||
**Kind**: instance method of <code>[JsdocToMarkdown](#exp_module_jsdoc-to-markdown--JsdocToMarkdown)</code> | ||
**Category**: async | ||
**Fulfil**: <code>string</code> - the rendered docs | ||
|
||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| [options] | <code>object</code> | Accepts all [getJsdocData](#module_jsdoc-to-markdown--JsdocToMarkdown+getJsdocData) options plus the following: | | ||
| [options.data] | <code>Array.<object></code> | 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] | <code>string</code> | 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] | <code>number</code> | The initial heading depth. For example, with a value of `2` the top-level markdown headings look like `"## The heading"`. | | ||
| [options.example-lang] | <code>string</code> | Specifies the default language used in @example blocks (for [syntax-highlighting](https://help.github.com/articles/github-flavored-markdown/#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] | <code>string</code> | <code>Array.<string></code> | Use an installed package containing helper and/or partial overrides. | | ||
| [options.helper] | <code>string</code> | <code>Array.<string></code> | handlebars helper files to override or extend the default set. | | ||
| [options.partial] | <code>string</code> | <code>Array.<string></code> | handlebars partial files to override or extend the default set. | | ||
| [options.name-format] | <code>string</code> | Format identifier names in the [code](http://daringfireball.net/projects/markdown/syntax#code) style, (i.e. format using backticks or `<code></code>`). | | ||
| [options.no-gfm] | <code>boolean</code> | 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] | <code>boolean</code> | Put `<hr>` breaks between identifiers. Improves readability on bulky docs. | | ||
| [options.module-index-format] | <code>string</code> | 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: | ||
```js | ||
> jsdoc2md.render('lib/*.js').then(console.log) | ||
``` | ||
|
||
- | ||
|
||
<a name="module_jsdoc-to-markdown--JsdocToMarkdown+getTemplateData"></a> | ||
|
||
### jsdoc2md.getTemplateData([options]) ⇒ <code>Promise</code> | ||
Returns template data (jsdoc-parse output). | ||
|
||
**Kind**: instance method of <code>[JsdocToMarkdown](#exp_module_jsdoc-to-markdown--JsdocToMarkdown)</code> | ||
**Category**: async | ||
**Fulfil**: <code>object[]</code> - the json data | ||
|
||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| [options] | <code>object</code> | Identical options to [getJsdocData](#module_jsdoc-to-markdown--JsdocToMarkdown+getJsdocData). | | ||
|
||
|
||
- | ||
|
||
<a name="module_jsdoc-to-markdown--JsdocToMarkdown+getJsdocData"></a> | ||
|
||
### jsdoc2md.getJsdocData([options]) ⇒ <code>Promise</code> | ||
Returns raw jsdoc data. | ||
|
||
**Kind**: instance method of <code>[JsdocToMarkdown](#exp_module_jsdoc-to-markdown--JsdocToMarkdown)</code> | ||
**Category**: async | ||
**Fulfil**: <code>object[]</code> | ||
|
||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| [options] | <code>object</code> | the options | | ||
| [options.cache] | <code>boolean</code> | Set to false to disable memoisation cache. Defaults to true. | | ||
| [options.files] | <code>string</code> | <code>Array.<string></code> | One or more filenames to process. Accepts globs (e.g. `*.js`). Either `files`, `source` or `data` must be supplied. | | ||
| [options.source] | <code>string</code> | A string containing source code to process. Either `files`, `source` or `data` must be supplied. | | ||
| [options.configure] | <code>string</code> | The path to the configuration file. Default: path/to/jsdoc/conf.json. | | ||
| [options.html] | <code>boolean</code> | Enable experimental documentation of `.html` files. | | ||
|
||
|
||
- | ||
|
||
<a name="module_jsdoc-to-markdown--JsdocToMarkdown+clear"></a> | ||
|
||
### jsdoc2md.clear() ⇒ <code>Promise</code> | ||
Clear the cache. | ||
|
||
**Kind**: instance method of <code>[JsdocToMarkdown](#exp_module_jsdoc-to-markdown--JsdocToMarkdown)</code> | ||
**Category**: async | ||
|
||
- | ||
|
||
<a name="module_jsdoc-to-markdown--JsdocToMarkdown+renderSync"></a> | ||
|
||
### jsdoc2md.renderSync([options]) ⇒ <code>string</code> | ||
Sync version of `render`. | ||
|
||
**Kind**: instance method of <code>[JsdocToMarkdown](#exp_module_jsdoc-to-markdown--JsdocToMarkdown)</code> | ||
**Category**: sync | ||
**Engine**: nodejs >= 0.12 | ||
|
||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| [options] | <code>object</code> | Identical options to [render](#module_jsdoc-to-markdown--JsdocToMarkdown+render). | | ||
|
||
**Example** | ||
```js | ||
const docs = jsdoc2md.renderSync('lib/*.js') | ||
``` | ||
|
||
- | ||
|
||
<a name="module_jsdoc-to-markdown--JsdocToMarkdown+getTemplateDataSync"></a> | ||
|
||
### jsdoc2md.getTemplateDataSync([options]) ⇒ <code>Array.<object></code> | ||
Sync version of `getTemplateData`. | ||
|
||
**Kind**: instance method of <code>[JsdocToMarkdown](#exp_module_jsdoc-to-markdown--JsdocToMarkdown)</code> | ||
**Category**: sync | ||
|
||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| [options] | <code>object</code> | Identical options to [getJsdocData](#module_jsdoc-to-markdown--JsdocToMarkdown+getJsdocData). | | ||
|
||
|
||
- | ||
|
||
<a name="module_jsdoc-to-markdown--JsdocToMarkdown+getJsdocDataSync"></a> | ||
|
||
### jsdoc2md.getJsdocDataSync([options]) ⇒ <code>Array.<object></code> | ||
Sync version of `getJsdocData`. | ||
|
||
**Kind**: instance method of <code>[JsdocToMarkdown](#exp_module_jsdoc-to-markdown--JsdocToMarkdown)</code> | ||
**Category**: sync | ||
|
||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| [options] | <code>object</code> | Identical options to [getJsdocData](#module_jsdoc-to-markdown--JsdocToMarkdown+getJsdocData). | | ||
|
||
|
||
- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
'use strict'; | ||
|
||
var tool = require('command-line-tool'); | ||
var version = require('../../package').version; | ||
|
||
var cli = parseCommandLine(); | ||
var options = cli.options._all; | ||
options = loadStoredConfig(options); | ||
|
||
if (options['no-cache']) { | ||
options.cache = false; | ||
delete options['no-cache']; | ||
} | ||
|
||
if (options.help) { | ||
tool.printOutput(cli.usage); | ||
} else if (options.version) { | ||
tool.printOutput(version); | ||
} else if (options.clear) { | ||
var jsdoc2md = require('../../'); | ||
jsdoc2md._interface = 'cli'; | ||
jsdoc2md.clear().catch(handleError); | ||
} else { | ||
var _jsdoc2md = require('../../'); | ||
_jsdoc2md._interface = 'cli'; | ||
|
||
if (options.config) { | ||
var omit = require('lodash.omit'); | ||
tool.stop(JSON.stringify(omit(options, 'config'), null, ' ')); | ||
} | ||
|
||
try { | ||
var assert = require('assert'); | ||
options.files = options.files || []; | ||
assert.ok(options.files.length || options.source, 'Must supply either --files or --source'); | ||
} catch (err) { | ||
tool.printOutput(cli.usage); | ||
handleError(err); | ||
} | ||
|
||
if (options.json) { | ||
_jsdoc2md.getTemplateData(options).then(function (json) { | ||
tool.printOutput(JSON.stringify(json, null, ' ')); | ||
}).catch(handleError); | ||
} else if (options.jsdoc) { | ||
_jsdoc2md.getJsdocData(options).then(function (json) { | ||
tool.printOutput(JSON.stringify(json, null, ' ')); | ||
}).catch(handleError); | ||
} else if (options.namepaths) { | ||
_jsdoc2md.getNamepaths(options).then(function (namepaths) { | ||
tool.printOutput(JSON.stringify(namepaths, null, ' ')); | ||
}).catch(handleError); | ||
} else { | ||
var fs = require('fs'); | ||
if (options.template) options.template = fs.readFileSync(options.template, 'utf8'); | ||
|
||
_jsdoc2md.render(options).then(function (output) { | ||
return process.stdout.write(output); | ||
}).catch(handleError); | ||
} | ||
} | ||
|
||
function loadStoredConfig(options) { | ||
var loadConfig = require('config-master'); | ||
var jsdoc2mdConfig = loadConfig('jsdoc2md'); | ||
return Object.assign(jsdoc2mdConfig, options); | ||
} | ||
|
||
function parseCommandLine() { | ||
var cliData = require('../lib/cli-data'); | ||
try { | ||
return tool.getCli(cliData.definitions, cliData.usageSections); | ||
} catch (err) { | ||
handleError(err); | ||
} | ||
} | ||
|
||
function handleError(err) { | ||
tool.halt(err.toString()); | ||
} |
Oops, something went wrong.