2017-02-12 10:12:11 +01:00
|
|
|
# Style Guide
|
|
|
|
|
2019-02-18 03:38:25 +01:00
|
|
|
* Documentation is in markdown files with names formatted as
|
2017-10-08 05:47:46 +02:00
|
|
|
`lowercase-with-dashes.md`.
|
2019-02-18 03:38:25 +01:00
|
|
|
* Use an underscore in the filename only if the underscore is part of the
|
|
|
|
topic name (e.g., `child_process`).
|
2017-02-12 10:12:11 +01:00
|
|
|
* Some files, such as top-level markdown files, are exceptions.
|
|
|
|
* Documents should be word-wrapped at 80 characters.
|
2019-02-18 03:38:25 +01: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-29 00:43:34 +01:00
|
|
|
* OK: _capitalize_, _color_
|
|
|
|
* NOT OK: _capitalise_, _colour_
|
2017-11-29 03:37:55 +01:00
|
|
|
* Use [serial commas][].
|
2019-01-29 00:43:34 +01:00
|
|
|
* Avoid personal pronouns (_I_, _you_, _we_) in reference documentation.
|
2018-03-09 23:49:59 +01:00
|
|
|
* Personal pronouns are acceptable in colloquial documentation such as guides.
|
|
|
|
* Use gender-neutral pronouns and gender-neutral plural nouns.
|
2019-01-29 00:43:34 +01:00
|
|
|
* OK: _they_, _their_, _them_, _folks_, _people_, _developers_
|
|
|
|
* NOT OK: _his_, _hers_, _him_, _her_, _guys_, _dudes_
|
2019-02-18 03:38:25 +01:00
|
|
|
* When combining wrapping elements (parentheses and quotes), place terminal
|
|
|
|
punctuation:
|
2017-02-12 10:12:11 +01:00
|
|
|
* Inside the wrapping element if the wrapping element contains a complete
|
2019-02-18 03:38:25 +01:00
|
|
|
clause.
|
2017-02-12 10:12:11 +01:00
|
|
|
* Outside of the wrapping element if the wrapping element contains only a
|
|
|
|
fragment of a clause.
|
2018-05-30 09:56:48 +02:00
|
|
|
* Documents must start with a level-one heading.
|
2017-02-12 10:12:11 +01:00
|
|
|
* Prefer affixing links to inlining links — prefer `[a link][]` to
|
|
|
|
`[a link](http://example.com)`.
|
2019-02-18 03:38:25 +01:00
|
|
|
* When documenting APIs, update the YAML comment associated with the API as
|
|
|
|
appropriate. This is especially true when introducing or deprecating an API.
|
|
|
|
* Use [Em dashes][] ("—" or `Option+Shift+"-"` on macOS) surrounded by spaces,
|
|
|
|
as per [The New York Times Manual of Style and Usage][].
|
2017-02-12 10:12:11 +01:00
|
|
|
* For code blocks:
|
|
|
|
* Use language aware fences. ("```js")
|
2019-02-18 03:38:25 +01:00
|
|
|
* Code need not be complete. Treat code blocks as an illustration or aid to
|
2017-02-12 10:12:11 +01: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 03:38:25 +01: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 21:53:54 +02:00
|
|
|
* Function arguments or object properties should use the following format:
|
2019-08-27 05:52:08 +02:00
|
|
|
* ```* `name` {type|type2} Optional description. **Default:** `value`.```
|
2018-06-16 00:49:23 +02: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 03:44:32 +02:00
|
|
|
* The `type` should refer to a Node.js type or a [JavaScript type][].
|
2017-06-18 21:53:54 +02: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 23:09:05 +01:00
|
|
|
* Use official styling for capitalization in products and projects.
|
|
|
|
* OK: JavaScript, Google's V8
|
2018-06-16 00:49:23 +02:00
|
|
|
<!--lint disable prohibited-strings remark-lint-->
|
2017-11-18 23:09:05 +01:00
|
|
|
* NOT OK: Javascript, Google's v8
|
2019-09-06 07:42:22 +02:00
|
|
|
|
2018-10-30 06:39:44 +01:00
|
|
|
* Use _Node.js_ and not _Node_, _NodeJS_, or similar variants.
|
2019-12-02 07:12:44 +01:00
|
|
|
<!-- lint enable prohibited-strings remark-lint-->
|
2018-10-30 06:39:44 +01:00
|
|
|
* When referring to the executable, _`node`_ is acceptable.
|
2017-02-12 10:12:11 +01:00
|
|
|
|
2018-04-16 13:29:39 +02:00
|
|
|
See also API documentation structure overview in [doctools README][].
|
|
|
|
|
2017-06-17 22:09:54 +02:00
|
|
|
[Em dashes]: https://en.wikipedia.org/wiki/Dash#Em_dash
|
2017-06-18 21:53:54 +02:00
|
|
|
[Javascript type]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Data_structures_and_types
|
2017-11-29 03:37:55 +01:00
|
|
|
[serial commas]: https://en.wikipedia.org/wiki/Serial_comma
|
2017-06-17 22:09:54 +02:00
|
|
|
[The New York Times Manual of Style and Usage]: https://en.wikipedia.org/wiki/The_New_York_Times_Manual_of_Style_and_Usage
|
2019-09-04 08:39:05 +02:00
|
|
|
[plugin]: https://editorconfig.org/#download
|
2018-04-16 13:29:39 +02:00
|
|
|
[doctools README]: ../tools/doc/README.md
|