Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New package to auto-generate public API documentation #13329

Merged
merged 213 commits into from
Mar 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
213 commits
Select commit Hold shift + click to select a range
0a6b23c
First, find export declarations
oandregal Jan 15, 2019
81d4b78
Second, parse JSDoc
oandregal Jan 15, 2019
c5ad307
Third, create markdown files with exports and JDoc descriptions.
oandregal Jan 15, 2019
16c178c
Refactor and prevent against no JSDoc
oandregal Jan 16, 2019
9ee1aea
Move script to own package
oandregal Jan 16, 2019
4e6b22b
Split api into cli, engine, and formatter
oandregal Jan 16, 2019
7225849
Add initial tests
oandregal Jan 16, 2019
de314f5
Test named export (const)
oandregal Jan 16, 2019
f27fb08
Add test for default named functions
oandregal Jan 16, 2019
07e21fa
Add support for default export of anonymous functions
oandregal Jan 16, 2019
7b3dafc
Better phrasing for test
oandregal Jan 16, 2019
441ba4b
Add support for default exports (identifiers)
oandregal Jan 16, 2019
d305f7c
Add support for named exports of a single identifier
oandregal Jan 16, 2019
e1b83c0
Add test for many exports at once
oandregal Jan 16, 2019
04b6c8e
Tweak text and reorder tests
oandregal Jan 16, 2019
acef18c
Teach engine to take JSDoc from identifier declaration
oandregal Jan 16, 2019
e042c8c
Cover undocumented exports
oandregal Jan 16, 2019
4e74cb1
Be more explicit about what is a test file
oandregal Jan 16, 2019
fd60891
Add more test to cover potential regressions
oandregal Jan 16, 2019
5fa808c
Expose script as npm script
oandregal Jan 16, 2019
f2b7c98
CLI: manage errors
oandregal Jan 16, 2019
97ae482
Refactor to pave the way to next step
oandregal Jan 17, 2019
5f45ad7
Refactor to prepare next step
oandregal Jan 17, 2019
c92e15b
Refactor to prepare next step
oandregal Jan 17, 2019
ef0d41e
Add helper functions
oandregal Jan 17, 2019
48281e5
Add mechanism to query upper layers for dependency code
oandregal Jan 17, 2019
84f5e1c
Engine can lookup JSDoc in dependency file
oandregal Jan 17, 2019
6e006ea
Formatter - adapt a new engine API
oandregal Jan 17, 2019
560abda
Add test for looking up JSDoc in dependency
oandregal Jan 17, 2019
444891a
CLI: adapt to new engine API
oandregal Jan 17, 2019
fe14068
Engine: enable JSX support
oandregal Jan 17, 2019
0ab135f
Evaluate how much coverage do we have already
oandregal Jan 17, 2019
a2a5a6a
Remove unused file
oandregal Jan 17, 2019
2d7268a
Add test for multiple named exports
oandregal Jan 18, 2019
f017dfe
Add more info for debugging purposes
oandregal Jan 18, 2019
84f4dbc
Add tests for get name of named function and variable
oandregal Jan 18, 2019
844d74a
Add support and test for parsing classes
oandregal Jan 18, 2019
bb34043
Add test for single identifier
oandregal Jan 18, 2019
8cc1be8
Add test for multiple named identifiers
oandregal Jan 18, 2019
0f80013
Add tests for default export of functions (anonymous and named)
oandregal Jan 18, 2019
0fb9542
Add tests for default export of variables
oandregal Jan 18, 2019
c3a74d7
Add tests for default export of classes
oandregal Jan 18, 2019
633e0f9
Add tests for default export of identifier
oandregal Jan 18, 2019
009cf5d
Add test for export redirects (* and default)
oandregal Jan 18, 2019
d939c4a
Placeholder to implement ExportAllDeclaration
oandregal Jan 18, 2019
aca12d4
Update engine and tests
oandregal Jan 18, 2019
6986119
Adapt get-name-declaration to return an array
oandregal Jan 18, 2019
4b063a0
Implement retrieval of multiple specifiers
oandregal Jan 18, 2019
255af56
Reorganize test to prepare next steps
oandregal Jan 21, 2019
ec547fc
Refactor default and namespace exports
oandregal Jan 21, 2019
9f5eafb
Flatten importName and localName
oandregal Jan 21, 2019
dc95707
get-name-declaration: refactor to return export entry list
oandregal Jan 21, 2019
10b271f
get-name-declaration renamed to get-export-entries
oandregal Jan 21, 2019
461ec44
Reorder dependency statements
oandregal Jan 21, 2019
e714f9a
Remove uncessary test
oandregal Jan 21, 2019
d59f26c
Refactor get IR and add tests for default exports
oandregal Jan 21, 2019
421cdf0
Rename file
oandregal Jan 21, 2019
f9b3a86
Flatten export entries returned by IR
oandregal Jan 21, 2019
927ec0b
Fix engine tests
oandregal Jan 21, 2019
0b1e42c
Update tests for IR
oandregal Jan 21, 2019
d41beb8
Fix tests
oandregal Jan 21, 2019
45eb32e
getExportEntries: retrieve module from export statement
oandregal Jan 21, 2019
6f8849e
getIR: fix dependency lookup
oandregal Jan 21, 2019
2a72444
Protect against no code provided
oandregal Jan 21, 2019
27756e8
Better test names
oandregal Jan 21, 2019
e79bb85
Implement exported names
oandregal Jan 21, 2019
7f73a4f
Fix exported names
oandregal Jan 21, 2019
71d170e
Update coverage
oandregal Jan 21, 2019
f363338
Add test for namespace export
oandregal Jan 21, 2019
9fbac97
Update coverage.md
oandregal Jan 22, 2019
b7b2b30
Fix export entries test
oandregal Jan 22, 2019
f116fbf
IR: add support for namespace exports
oandregal Jan 22, 2019
93b9044
Fix method call
oandregal Jan 22, 2019
73f4b83
Extract constants for better encapsulation
oandregal Jan 22, 2019
2d5ab5c
Update coverage
oandregal Jan 22, 2019
721cfdc
Add test for named and default exports
oandregal Jan 22, 2019
12621e9
Add JSDoc lookup for named inline nodes such as:
oandregal Jan 22, 2019
626ad86
Update coverage
oandregal Jan 22, 2019
ef09517
Better test organization
oandregal Jan 22, 2019
d98b214
Implement JSDoc lookup in default identifier from import
oandregal Jan 22, 2019
2b4019d
Better test organization
oandregal Jan 22, 2019
a21d8c0
getExportEntries: test for _import default from module_
oandregal Jan 22, 2019
a8b7d0d
Add support for JSDoc lookup of imported identifiers
oandregal Jan 22, 2019
970fcd7
Update coverage
oandregal Jan 22, 2019
3465afd
Install docgen package
oandregal Jan 22, 2019
33ee82b
Improve CLI
oandregal Jan 23, 2019
e304911
Add tests for retrieving JSDoc of destructured objects
oandregal Jan 23, 2019
c72c154
Add support for JSDoc lookup of destructured objects
oandregal Jan 23, 2019
bfc9a3b
Adapt tests to new engine API
oandregal Jan 23, 2019
c3bb4e9
Fix JSDoc lookup for named export
oandregal Jan 23, 2019
3826642
Update coverage
oandregal Jan 23, 2019
a592ad7
Remove docgen from package.json
oandregal Jan 23, 2019
12acf30
Better README
oandregal Jan 23, 2019
34fc211
Update coverage
oandregal Jan 24, 2019
26c51ca
Ignore comments in namespace exports
oandregal Jan 24, 2019
9d4cc08
Update coverage
oandregal Jan 24, 2019
c632bec
CLI generates output by adding suffixes to input
oandregal Jan 24, 2019
002f204
Add test for export imported namespaces
oandregal Jan 24, 2019
15a753f
Add test for export imported namespaces
oandregal Jan 24, 2019
5768a6f
Add named-import-namespace AST
oandregal Jan 24, 2019
10d0a0b
Extract method
oandregal Jan 24, 2019
e2ef4b0
IR - add breaking test
oandregal Jan 24, 2019
8ff0e45
Fix bug on export redirection
oandregal Jan 24, 2019
2ac38a6
Add support for import namespace
oandregal Jan 24, 2019
ba1e68f
Update coverage
oandregal Jan 24, 2019
90258c9
Respect the dependency extension if any
oandregal Jan 24, 2019
9615010
Update coverage
oandregal Jan 24, 2019
a49bfcd
Add test for undocumented declaration (no comments)
oandregal Jan 24, 2019
f68a3d2
Add test for undocumented declaration (// comment)
oandregal Jan 24, 2019
2cb4014
Update README
oandregal Jan 24, 2019
dbac1dc
Add a debug mode
oandregal Jan 24, 2019
6a83ff8
Update coverage
oandregal Jan 24, 2019
fce4ad8
Better example
oandregal Jan 24, 2019
86c4350
Better README.md
oandregal Jan 24, 2019
a81b7a6
Add params tags to IR and formatter
oandregal Jan 29, 2019
49ede6f
Formatter: show return tag output
oandregal Jan 30, 2019
52bd077
Adapt engine tests to new API
oandregal Jan 30, 2019
31bdfa7
Adapt formatter tests to new API
oandregal Jan 30, 2019
27ac534
Adapt IR tests to new API
oandregal Jan 30, 2019
23ee549
Update fixtures and test data to uncover some bug
oandregal Jan 30, 2019
174dbb0
Reorder tests
oandregal Feb 1, 2019
18257d0
Fix bug on retrieving JSDoc from module dep
oandregal Feb 1, 2019
3bf4732
Markdown: clean spaces in descriptions
oandregal Feb 6, 2019
7816de2
Add support for nullable types
oandregal Feb 6, 2019
a0bdec9
Extract getParamType and add tests
oandregal Feb 6, 2019
c2f814b
getParamType: add support for RestType
oandregal Feb 6, 2019
72b1adc
getParamType: add support for unions
oandregal Feb 6, 2019
2b3fe94
Markdown tweaks: better formatting, adding output type
oandregal Feb 6, 2019
3de973d
Markdown: sort output by symbol name
oandregal Feb 6, 2019
ad3e48b
Markdown: improve spacing
oandregal Feb 6, 2019
39fd98f
Use | symbols for type unions
oandregal Feb 6, 2019
88ed5bf
Use ... symbols for rest tipes
oandregal Feb 6, 2019
c2dc8e2
Markdown: update to consider uniont and rest types
oandregal Feb 6, 2019
09763d7
getParamType: add support for nullable params
oandregal Feb 6, 2019
28f06f4
Markdown: add example tag to output
oandregal Feb 6, 2019
78db25b
Update tests to API changes
oandregal Feb 6, 2019
a89f9e5
Prevent bug when paragraph is null
oandregal Feb 6, 2019
796ad3f
Update coverage
oandregal Feb 6, 2019
3e3810f
Update coverage
oandregal Feb 7, 2019
5f2cf4a
Add support for see tag
oandregal Feb 7, 2019
ca2fde9
Add support for link tag
oandregal Feb 7, 2019
2a2743a
Allow having several examples for one symbol
oandregal Feb 7, 2019
5f60034
Less space between types: (object|string)
oandregal Feb 7, 2019
dbae6fe
Keep description format as it is
oandregal Feb 7, 2019
b76e001
Add support for type tag
oandregal Feb 7, 2019
9d3dcc2
Rename get-param-type-as-string to get-type-as-string
oandregal Feb 7, 2019
c149320
Adapt test to API changes
oandregal Feb 7, 2019
88004d9
Add support for * type
oandregal Feb 7, 2019
b8e21b0
Add support for type applications
oandregal Feb 7, 2019
d8c8a18
Add support for NullLiteral
oandregal Feb 7, 2019
3b3cd21
Add support for UndefinedLiteral and optional parameters
oandregal Feb 7, 2019
f485e71
Add support for default values
oandregal Feb 8, 2019
bf2a2d4
Add support for deprecated tag
oandregal Feb 8, 2019
6753293
params and return tags are no longer special
oandregal Feb 8, 2019
9bcce9e
Refactor formatter to compact code
oandregal Feb 8, 2019
22f78f0
Update coverage
oandregal Feb 8, 2019
b16d957
Add line numbers (start, end) to export tokens
oandregal Feb 11, 2019
acc8ccb
Adapt tests to new API
oandregal Feb 11, 2019
b913608
Add line number to intermediate representation
oandregal Feb 11, 2019
de6d74b
Fix line numbers for namespace export
oandregal Feb 11, 2019
c31d43c
Remove duplicated tests
oandregal Feb 11, 2019
a14178f
Better test names
oandregal Feb 11, 2019
ab9dd27
Add path to intermediate representation
oandregal Feb 11, 2019
a935f66
Adapt tests to API changes
oandregal Feb 11, 2019
6070c62
Add path and line numbers to markdown output
oandregal Feb 11, 2019
8016fb7
Add TODO file
oandregal Feb 11, 2019
e842a63
Use optionator to process CLI options
oandregal Feb 11, 2019
c0ba93b
Allow to specify a markdown output file
oandregal Feb 11, 2019
915091c
Allow to pass a formatter
oandregal Feb 11, 2019
f7577df
Document new added options
oandregal Feb 11, 2019
9ab9cfb
CLI: add ability to ignore symbols by name
oandregal Feb 12, 2019
63c6702
Update README
oandregal Feb 12, 2019
d90aaf5
CLI: support append to existing Markdown file
oandregal Feb 13, 2019
4abfe52
Make linter happy
oandregal Feb 13, 2019
3dfb4cc
Add package to manifest
oandregal Feb 13, 2019
1b6578b
Update as per new package recommendations
oandregal Feb 13, 2019
09e4775
Update package name
oandregal Feb 13, 2019
fe3c531
Add docgen as a dev dependency
oandregal Feb 13, 2019
03e779c
Add wordpress keyword to package.json
oandregal Feb 15, 2019
3dc7410
Mark as a bash command
oandregal Feb 15, 2019
bf08a54
CLI: allow for walking parent directories
oandregal Feb 21, 2019
26411bb
Add tests for tags
oandregal Feb 25, 2019
d4c1f80
Adapt formatter test to API
oandregal Feb 25, 2019
8a0695c
Move IR tests related to JSDoc to its own tester
oandregal Feb 25, 2019
d994a27
get-jsdoc-from-token returns a human-readable type
oandregal Feb 25, 2019
2849440
Implement a token-based injection for Markdown
oandregal Feb 25, 2019
3d5b911
Add embed JSDoc
oandregal Feb 25, 2019
287a1fb
Formatter: let heading index be configurable
oandregal Feb 25, 2019
5e22438
Use proper heading when embedding content within token
oandregal Feb 25, 2019
25b0898
Move default markdown code to own folder
oandregal Feb 26, 2019
59d5f19
Migrate engine tests to jest
oandregal Feb 26, 2019
a58775b
Reorganize fixtures
oandregal Feb 27, 2019
62878c6
Migrate export tests to jest
oandregal Feb 27, 2019
ba86e53
Migrate getTypeFromJSDoc tests to jest
oandregal Feb 27, 2019
a4af39d
Migrate getJSDocFromToken tests to jest
oandregal Feb 27, 2019
99a41f3
Migrate getIntermediateRepresentation tests to jest
oandregal Feb 27, 2019
7e68a46
Migrate Markdown formatter tests to jest
oandregal Feb 27, 2019
71a64d6
Extract bin/cli utility
oandregal Feb 27, 2019
95239cb
Uninstall no longer needed dev deps
oandregal Feb 27, 2019
94411fa
Fix docgen dependencies
oandregal Feb 27, 2019
1f617be
Add command to generate docs
oandregal Feb 27, 2019
996e65a
Update docs
oandregal Feb 27, 2019
ae3cf05
Update README
oandregal Feb 27, 2019
3e842bc
Add --use-token option
oandregal Feb 27, 2019
8429aa2
Extract constants
oandregal Feb 27, 2019
5c30f1c
Update README
oandregal Feb 27, 2019
fb03ec9
Make formatter-markdown test be deterministic
oandregal Feb 27, 2019
77e3d8e
Make formatter-markdown test be deterministic
oandregal Feb 27, 2019
f255304
Update packages/docgen/README.md
chrisvanpatten Feb 27, 2019
6616bc0
Update packages/docgen/README.md
chrisvanpatten Feb 27, 2019
c8fcab7
Update packages/docgen/README.md
chrisvanpatten Feb 27, 2019
47b78e3
Add command in the examples
oandregal Feb 27, 2019
2610e87
Update package-lock using the latest npm
oandregal Mar 1, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,12 @@
"markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/packages/deprecated/README.md",
"parent": "packages"
},
{
"title": "@wordpress/docgen",
"slug": "packages-docgen",
"markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/packages/docgen/README.md",
"parent": "packages"
},
{
"title": "@wordpress/dom-ready",
"slug": "packages-dom-ready",
Expand Down
26 changes: 26 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"@wordpress/babel-preset-default": "file:packages/babel-preset-default",
"@wordpress/browserslist-config": "file:packages/browserslist-config",
"@wordpress/custom-templated-path-webpack-plugin": "file:packages/custom-templated-path-webpack-plugin",
"@wordpress/docgen": "file:packages/docgen",
"@wordpress/e2e-test-utils": "file:packages/e2e-test-utils",
"@wordpress/e2e-tests": "file:packages/e2e-tests",
"@wordpress/eslint-plugin": "file:packages/eslint-plugin",
Expand Down Expand Up @@ -161,6 +162,7 @@
"dev": "npm run build:packages && concurrently \"wp-scripts start\" \"npm run dev:packages\"",
"dev:packages": "node ./bin/packages/watch.js",
"docs:build": "node docs/tool",
"docs:generate": "lerna run docs:generate",
"fixtures:clean": "rimraf \"packages/e2e-tests/fixtures/blocks/*.+(json|serialized.html)\"",
"fixtures:server-registered": "docker-compose run -w /var/www/html/wp-content/plugins/gutenberg --rm wordpress ./bin/get-server-blocks.php > test/integration/full-content/server-registered.json",
"fixtures:generate": "npm run fixtures:server-registered && cross-env GENERATE_MISSING_FIXTURES=y npm run test-unit",
Expand Down
1 change: 1 addition & 0 deletions packages/docgen/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
3 changes: 3 additions & 0 deletions packages/docgen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0 (Unreleased)

- Initial release
250 changes: 250 additions & 0 deletions packages/docgen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
# `docgen`

`docgen` helps you to generate the _public API_ of your code. Given an entry point file, it outputs the ES6 export statements and their corresponding JSDoc comments in human-readable format.

Some characteristics:

* If the export statement doesn't contain any JSDoc, it'll look up for JSDoc up to the declaration.
oandregal marked this conversation as resolved.
Show resolved Hide resolved
* It can resolve relative dependencies, either files or directories. For example, `import default from './dependency'` will find `dependency.js` or `dependency/index.js`

## Installation

Install the module

```bash
npm install @wordpress/docgen --save-dev
```

## Usage

```bash
oandregal marked this conversation as resolved.
Show resolved Hide resolved
npx docgen <entry-point.js>
```

This command will generate a file named `entry-point-api.md` containing all the exports and their JSDoc comments.

### CLI options

* **--formatter** `(String)`: A path to a custom formatter to control the contents of the output file. It should be a CommonJS module that exports a function that takes as input:
* *rootDir* `(String)`: current working directory as seen by docgen.
* *docPath* `(String)`: path of the output document to generate.
* *symbols* `(Array)`: the symbols found.
* **--ignore** `(RegExp)`: A regular expression used to ignore symbols whose name match it.
* **--output** `(String)`: Output file that will contain the API documentation.
* **--to-section** `(String)`: Append generated documentation to this section in the Markdown output. To be used by the default Markdown formatter. Depends on `--output` and bypasses the custom `--formatter` passed, if any.
* **--to-token**: Embed generated documentation within the start and end tokens in the Markdown output. To be used by the default Markdown formatter.Depends on `--output` and bypasses the custom `--formatter` passed, if any.
* Start token: `<!-- START TOKEN(Autogenerated API docs) -->`
* End token: `<!-- END TOKEN(Autogenerated API docs) -->`
* **--use-token** `(String)`: This options allows you to customize the string between the tokens. For example, `--use-token my-api` will look up for the start token `<!-- START TOKEN(my-api) -->` and the end token `<!-- END TOKEN(my-api) -->`. Depends on `--to-token`.
* **--debug**: Run in debug mode, which outputs some intermediate files useful for debugging.

## Examples

### Default export

Entry point `index.js`:

```js
oandregal marked this conversation as resolved.
Show resolved Hide resolved
/**
* Adds two numbers.
*
* @param {number} term1 First number.
* @param {number} term2 Second number.
* @return {number} The result of adding the two numbers.
*/
export default function addition( term1, term2 ) {
// Implementation would go here.
}
```

Output of `npx docgen index.js` would be `index-api.js`:

```markdown
# API

## default

[example.js#L8-L10](example.js#L8-L10)

Adds two numbers.

**Parameters**

- **term1** `number`: First number.
- **term2** `number`: Second number.

**Returns**

`number` The result of adding the two numbers.
```

### Named export

Entry point `index.js`:

```js
/**
* Adds two numbers.
*
* @param {number} term1 First number.
* @param {number} term2 Second number.
* @return {number} The result of adding the two numbers.
*/
function addition( term1, term2 ) {
return term1 + term2;
}

/**
* Adds two numbers.
*
* @deprecated Use `addition` instead.
*
* @param {number} term1 First number.
* @param {number} term2 Second number.
* @return {number} The result of adding the two numbers.
*/
function count( term1, term2 ) {
return term1 + term2;
}

export { count, addition };
```

Output of `npx docgen index.js` would be `index-api.js`:

```markdown
# API

## addition

[example.js#L25-L25](example.js#L25-L25)

Adds two numbers.

**Parameters**

- **term1** `number`: First number.
- **term2** `number`: Second number.

**Returns**

`number` The result of adding the two numbers.

## count

[example.js#L25-L25](example.js#L25-L25)

> **Deprecated** Use `addition` instead.

Adds two numbers.

**Parameters**

- **term1** `number`: First number.
- **term2** `number`: Second number.

**Returns**

`number` The result of adding the two numbers.
```

### Namespace export

Let the entry point be `index.js`:

```js
export * from './count';
```

with `./count/index.js` contents being:

```js
/**
* Substracts two numbers.
*
* @example
*
* ```js
* const result = substraction( 5, 2 );
* console.log( result ); // Will log 3
* ```
*
* @param {number} term1 First number.
* @param {number} term2 Second number.
* @return {number} The result of subtracting the two numbers.
*/
export function substraction( term1, term2 ) {
return term1 - term2;
}

/**
* Adds two numbers.
*
* @example
*
* ```js
* const result = addition( 5, 2 );
* console.log( result ); // Will log 7
* ```
*
* @param {number} term1 First number.
* @param {number} term2 Second number.
* @return {number} The result of adding the two numbers.
*/
export function addition( term1, term2 ) {
// Implementation would go here.
return term1 - term2;
}
```

Output of `npx docgen index.js` would be `index-api.js`:

````markdown
# API

## addition

[example-module.js#L1-L1](example-module.js#L1-L1)

Adds two numbers.

**Usage**

```js
const result = addition( 5, 2 );
console.log( result ); // Will log 7
```

**Parameters**

- **term1** `number`: First number.
- **term2** `number`: Second number.

**Returns**

`number` The result of adding the two numbers.

## substraction

[example-module.js#L1-L1](example-module.js#L1-L1)

Substracts two numbers.

**Usage**

```js
const result = substraction( 5, 2 );
console.log( result ); // Will log 3
```

**Parameters**

- **term1** `number`: First number.
- **term2** `number`: Second number.

**Returns**

`number` The result of subtracting the two numbers.
````

<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
44 changes: 44 additions & 0 deletions packages/docgen/bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env node

const docgen = require( '../src' );

const optionator = require( 'optionator' )( {
prepend: 'Usage: node <path-to-docgen> <relative-path-to-entry-point>',
options: [ {
option: 'formatter',
type: 'String',
description: 'A custom function to format the generated documentation. By default, a Markdown formatter will be used.',
}, {
option: 'output',
type: 'String',
description: 'Output file to contain the API documentation.',
}, {
option: 'ignore',
type: 'RegExp',
description: 'A regular expression used to ignore symbols whose name match it.',
}, {
option: 'to-section',
type: 'String',
description: 'Append generated documentation to this section in the Markdown output. To be used by the default Markdown formatter.',
dependsOn: 'output',
}, {
option: 'to-token',
type: 'Boolean',
description: 'Embed generated documentation within this token in the Markdown output. To be used by the default Markdown formatter.',
dependsOn: 'output',
}, {
option: 'use-token',
type: 'String',
default: 'Autogenerated API docs',
description: 'Add this string to the start/end tokens.',
dependsOn: 'to-token',
}, {
option: 'debug',
type: 'Boolean',
default: false,
description: 'Run in debug mode, which outputs some intermediate files useful for debugging.',
} ],
} );

const options = optionator.parseArgv( process.argv );
docgen( options._[ 0 ], options );
Loading