node/tools/doc
Richard Lau a175b8d3a7
tools: only fetch previous versions when necessary
Refactor the logic for working out the previous versions of Node.js for
the API documentation so that the parsing (including the potential https
get) happens at most once per build (as opposed to the current once per
generated API doc).

Signed-off-by: Richard Lau <riclau@uk.ibm.com>

Backport-PR-URL: https://github.com/nodejs/node/pull/32642
PR-URL: https://github.com/nodejs/node/pull/32518
Fixes: https://github.com/nodejs/node/issues/32512
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
2020-04-06 22:38:35 +01:00
..
addon-verify.js tools: convert addon-verify to remark 2018-08-15 20:23:17 +10:00
allhtml.js tools: validate apidoc links 2018-07-24 20:49:04 +02:00
alljson.js tools: build all.json by combining generated JSON 2018-07-12 09:16:54 +02:00
apilinks.js tools: make apilinks building more robust 2019-02-28 23:37:45 +11:00
common.js tools: fix doc tool behavior for version arrays 2018-09-19 09:59:42 +02:00
generate.js tools: only fetch previous versions when necessary 2020-04-06 22:38:35 +01:00
html.js tools: only fetch previous versions when necessary 2020-04-06 22:38:35 +01:00
json.js tools: produce JSON documentation using unified/remark/rehype 2018-08-07 08:56:18 +02:00
LICENSE
package-lock.json tools: update to mdast-util-to-hast v3.0.2 2019-04-16 22:59:18 +01:00
package.json tools: update to mdast-util-to-hast v3.0.2 2019-04-16 22:59:18 +01:00
README.md doc: update tools/doc/README.md 2018-04-16 16:20:09 -07:00
type-parser.js doc: add documentation for brotli support 2019-05-16 14:57:03 -04:00
versions.js tools: only fetch previous versions when necessary 2020-04-06 22:38:35 +01:00

Here's how the node docs work.

1:1 relationship from lib/<module>.js to doc/api/<module>.md.

Each type of heading has a description block.

# module

<!--introduced_in=v0.10.0-->

> Stability: 2 - Stable

A description and examples.

## module.property
<!-- YAML
added: v0.10.0
-->

* {type}

A description of the property.

## module.someFunction(x, y, [z=100])
<!-- YAML
added: v0.10.0
-->

* `x` {string} The description of the string.
* `y` {boolean} Should I stay or should I go?
* `z` {number} How many zebras to bring. **Default:** `100`.

A description of the function.

## module.someNewFunction(x)
<!-- YAML
added: REPLACEME
-->

* `x` {string} The description of the string.

This feature is not in a release yet.

## Event: 'blerg'
<!-- YAML
added: v0.10.0
-->

* `anArg` {type} A description of the listener argument.

Modules don't usually raise events on themselves. `cluster` is the
only exception.

## Class: SomeClass
<!-- YAML
added: v0.10.0
-->

A description of the class.

### SomeClass.classMethod(anArg)
<!-- YAML
added: v0.10.0
-->

* `anArg` {Object} Just an argument.
  * `field` {string} `anArg` can have this field.
  * `field2` {boolean} Another field. **Default:** `false`.
* Returns: {boolean} `true` if it worked.

A description of the method for humans.

### SomeClass.nextSibling()
<!-- YAML
added: v0.10.0
-->

* Returns: {SomeClass | null} The next `SomeClass` in line.

`SomeClass` must be registered in `tools/doc/type-parser.js`
to be properly parsed in `{type}` fields.

### SomeClass.someProperty
<!-- YAML
added: v0.10.0
-->

* {string}

The indication of what `someProperty` is.

### Event: 'grelb'
<!-- YAML
added: v0.10.0
-->

* `isBlerg` {boolean}

This event is emitted on instances of `SomeClass`, not on the module itself.
  • Classes have (description, Properties, Methods, Events).
  • Events have (list of listener arguments, description).
  • Functions have (list of arguments, returned value if defined, description).
  • Methods have (list of arguments, returned value if defined, description).
  • Modules have (description, Properties, Functions, Classes, Examples).
  • Properties have (type, description).