2017-02-12 09:12:11 +00:00
|
|
|
# Style Guide
|
|
|
|
|
2019-02-18 02:38:25 +00:00
|
|
|
* Documentation is in markdown files with names formatted as
|
2017-10-08 03:47:46 +00:00
|
|
|
`lowercase-with-dashes.md`.
|
2019-02-18 02:38:25 +00:00
|
|
|
* Use an underscore in the filename only if the underscore is part of the
|
|
|
|
topic name (e.g., `child_process`).
|
2017-02-12 09:12:11 +00:00
|
|
|
* Some files, such as top-level markdown files, are exceptions.
|
|
|
|
* Documents should be word-wrapped at 80 characters.
|
2019-02-18 02:38:25 +00:00
|
|
|
* `.editorconfig` describes the preferred formatting.
|
|
|
|
* A [plugin][] is available for some editors to apply these rules.
|
|
|
|
* Check changes to documentation with `make lint-md`.
|
|
|
|
* Use American English spelling.
|
2019-01-28 23:43:34 +00:00
|
|
|
* OK: _capitalize_, _color_
|
|
|
|
* NOT OK: _capitalise_, _colour_
|
2017-11-29 02:37:55 +00:00
|
|
|
* Use [serial commas][].
|
2019-01-28 23:43:34 +00:00
|
|
|
* Avoid personal pronouns (_I_, _you_, _we_) in reference documentation.
|
2018-03-09 22:49:59 +00:00
|
|
|
* Personal pronouns are acceptable in colloquial documentation such as guides.
|
|
|
|
* Use gender-neutral pronouns and gender-neutral plural nouns.
|
2019-01-28 23:43:34 +00:00
|
|
|
* OK: _they_, _their_, _them_, _folks_, _people_, _developers_
|
|
|
|
* NOT OK: _his_, _hers_, _him_, _her_, _guys_, _dudes_
|
2019-02-18 02:38:25 +00:00
|
|
|
* When combining wrapping elements (parentheses and quotes), place terminal
|
|
|
|
punctuation:
|
2017-02-12 09:12:11 +00:00
|
|
|
* Inside the wrapping element if the wrapping element contains a complete
|
2019-02-18 02:38:25 +00:00
|
|
|
clause.
|
2017-02-12 09:12:11 +00:00
|
|
|
* Outside of the wrapping element if the wrapping element contains only a
|
|
|
|
fragment of a clause.
|
2018-05-30 07:56:48 +00:00
|
|
|
* Documents must start with a level-one heading.
|
2020-03-04 05:23:59 +00:00
|
|
|
* Prefer affixing links (`[a link][]`) to inlining links
|
|
|
|
(`[a link](http://example.com)`).
|
2019-02-18 02:38:25 +00:00
|
|
|
* When documenting APIs, update the YAML comment associated with the API as
|
|
|
|
appropriate. This is especially true when introducing or deprecating an API.
|
2017-02-12 09:12:11 +00:00
|
|
|
* For code blocks:
|
2020-05-16 19:54:24 +00:00
|
|
|
* Use [language aware fences][]. (<code>```js</code>)
|
2019-02-18 02:38:25 +00:00
|
|
|
* Code need not be complete. Treat code blocks as an illustration or aid to
|
2017-02-12 09:12:11 +00:00
|
|
|
your point, not as complete running programs. If a complete running program
|
|
|
|
is necessary, include it as an asset in `assets/code-examples` and link to
|
|
|
|
it.
|
2019-02-18 02:38:25 +00:00
|
|
|
* When using underscores, asterisks, and backticks, please use
|
|
|
|
backslash-escaping: `\_`, `\*`, and ``\` ``.
|
|
|
|
* Constructors should use PascalCase.
|
|
|
|
* Instances should use camelCase.
|
|
|
|
* Denote methods with parentheses: `socket.end()` instead of `socket.end`.
|
2017-06-18 19:53:54 +00:00
|
|
|
* Function arguments or object properties should use the following format:
|
2019-08-27 03:52:08 +00:00
|
|
|
* ```* `name` {type|type2} Optional description. **Default:** `value`.```
|
2018-06-15 22:49:23 +00:00
|
|
|
<!--lint disable maximum-line-length remark-lint-->
|
|
|
|
* For example: <code>* `byteOffset` {integer} Index of first byte to expose. **Default:** `0`.</code>
|
|
|
|
<!--lint enable maximum-line-length remark-lint-->
|
2018-04-02 01:44:32 +00:00
|
|
|
* The `type` should refer to a Node.js type or a [JavaScript type][].
|
2017-06-18 19:53:54 +00:00
|
|
|
* Function returns should use the following format:
|
|
|
|
* <code>* Returns: {type|type2} Optional description.</code>
|
|
|
|
* E.g. <code>* Returns: {AsyncHook} A reference to `asyncHook`.</code>
|
2017-11-18 22:09:05 +00:00
|
|
|
* Use official styling for capitalization in products and projects.
|
|
|
|
* OK: JavaScript, Google's V8
|
2018-06-15 22:49:23 +00:00
|
|
|
<!--lint disable prohibited-strings remark-lint-->
|
2017-11-18 22:09:05 +00:00
|
|
|
* NOT OK: Javascript, Google's v8
|
2018-10-30 05:39:44 +00:00
|
|
|
* Use _Node.js_ and not _Node_, _NodeJS_, or similar variants.
|
2019-12-02 06:12:44 +00:00
|
|
|
<!-- lint enable prohibited-strings remark-lint-->
|
2018-10-30 05:39:44 +00:00
|
|
|
* When referring to the executable, _`node`_ is acceptable.
|
2019-12-13 15:18:33 +00:00
|
|
|
* Be direct.
|
|
|
|
* OK: The return value is a string.
|
|
|
|
<!-- lint disable prohibited-strings remark-lint-->
|
|
|
|
* NOT OK: It is important to note that, in all cases, the return value will be
|
|
|
|
a string regardless.
|
|
|
|
<!-- lint enable prohibited-strings remark-lint-->
|
2017-02-12 09:12:11 +00:00
|
|
|
|
2018-04-16 11:29:39 +00:00
|
|
|
See also API documentation structure overview in [doctools README][].
|
|
|
|
|
2020-05-16 19:54:24 +00:00
|
|
|
[language aware fences]: https://github.com/highlightjs/highlight.js/blob/master/SUPPORTED_LANGUAGES.md
|
2017-06-18 19:53:54 +00:00
|
|
|
[Javascript type]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Data_structures_and_types
|
2017-11-29 02:37:55 +00:00
|
|
|
[serial commas]: https://en.wikipedia.org/wiki/Serial_comma
|
2019-09-04 06:39:05 +00:00
|
|
|
[plugin]: https://editorconfig.org/#download
|
2020-03-31 17:08:49 +00:00
|
|
|
[doctools README]: ../../tools/doc/README.md
|