2017-02-12 09:12:11 +00:00
|
|
|
# Style Guide
|
|
|
|
|
2017-10-08 03:47:46 +00:00
|
|
|
* Documentation is written in markdown files with names formatted as
|
|
|
|
`lowercase-with-dashes.md`.
|
2017-02-12 09:12:11 +00:00
|
|
|
* Underscores in filenames are allowed only when they are present in the
|
2018-01-25 11:13:13 +00:00
|
|
|
topic the document will describe (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.
|
|
|
|
* The formatting described in `.editorconfig` is preferred.
|
2017-05-20 23:12:15 +00:00
|
|
|
* A [plugin][] is available for some editors to automatically apply these
|
|
|
|
rules.
|
2017-12-25 22:27:33 +00:00
|
|
|
* Changes to documentation should be checked with `make lint-md`.
|
2019-01-28 23:43:34 +00:00
|
|
|
* American English spelling is preferred.
|
|
|
|
* 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_
|
2017-02-12 09:12:11 +00:00
|
|
|
* When combining wrapping elements (parentheses and quotes), terminal
|
|
|
|
punctuation should be placed:
|
|
|
|
* Inside the wrapping element if the wrapping element contains a complete
|
|
|
|
clause — a subject, verb, and an object.
|
|
|
|
* 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.
|
2017-02-12 09:12:11 +00:00
|
|
|
* Prefer affixing links to inlining links — prefer `[a link][]` to
|
|
|
|
`[a link](http://example.com)`.
|
|
|
|
* When documenting APIs, note the version the API was introduced in at
|
|
|
|
the end of the section. If an API has been deprecated, also note the first
|
|
|
|
version that the API appeared deprecated in.
|
2017-06-17 20:09:54 +00:00
|
|
|
* When using dashes, 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 09:12:11 +00:00
|
|
|
* Including assets:
|
|
|
|
* If you wish to add an illustration or full program, add it to the
|
|
|
|
appropriate sub-directory in the `assets/` dir.
|
|
|
|
* Link to it like so: `[Asset](/assets/{subdir}/{filename})` for file-based
|
|
|
|
assets, and `![Asset](/assets/{subdir}/{filename})` for image-based assets.
|
|
|
|
* For illustrations, prefer SVG to other assets. When SVG is not feasible,
|
|
|
|
please keep a close eye on the filesize of the asset you're introducing.
|
|
|
|
* For code blocks:
|
|
|
|
* Use language aware fences. ("```js")
|
|
|
|
* Code need not be complete — treat code blocks as an illustration or aid to
|
|
|
|
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.
|
2017-05-20 23:12:15 +00:00
|
|
|
* When using underscores, asterisks, and backticks, please use proper escaping
|
2017-10-08 03:47:46 +00:00
|
|
|
(`\_`, `\*` and ``\` `` instead of `_`, `*` and `` ` ``).
|
2017-05-20 23:12:15 +00:00
|
|
|
* References to constructor functions should use PascalCase.
|
|
|
|
* References to constructor instances should use camelCase.
|
|
|
|
* References to methods should be used with parentheses: for example,
|
|
|
|
`socket.end()` instead of `socket.end`.
|
2017-06-18 19:53:54 +00:00
|
|
|
* Function arguments or object properties should use the following format:
|
2018-06-15 22:49:23 +00:00
|
|
|
* ``` * `name` {type|type2} Optional description. **Default:** `value`. ```
|
|
|
|
<!--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-06-15 22:49:23 +00:00
|
|
|
<!-- lint enable prohibited-strings remark-lint-->
|
2018-10-30 05:39:44 +00:00
|
|
|
* Use _Node.js_ and not _Node_, _NodeJS_, or similar variants.
|
|
|
|
* When referring to the executable, _`node`_ is acceptable.
|
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][].
|
|
|
|
|
2017-06-17 20:09:54 +00:00
|
|
|
[Em dashes]: https://en.wikipedia.org/wiki/Dash#Em_dash
|
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
|
2017-06-17 20:09:54 +00:00
|
|
|
[The New York Times Manual of Style and Usage]: https://en.wikipedia.org/wiki/The_New_York_Times_Manual_of_Style_and_Usage
|
2017-06-18 19:53:54 +00:00
|
|
|
[plugin]: http://editorconfig.org/#download
|
2018-04-16 11:29:39 +00:00
|
|
|
[doctools README]: ../tools/doc/README.md
|