2020-07-19 00:08:12 +02:00
|
|
|
# Documentation style guide
|
|
|
|
|
|
|
|
This style guide helps us create organized and easy-to-read documentation. It
|
|
|
|
provides guidelines for organization, spelling, formatting, and more.
|
|
|
|
|
|
|
|
These are guidelines rather than strict rules. Content is more important than
|
|
|
|
formatting. You do not need to learn the entire style guide before contributing
|
|
|
|
to documentation. Someone can always edit your material later to conform with
|
|
|
|
this guide.
|
2017-02-12 10:12:11 +01:00
|
|
|
|
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.
|
2020-10-19 12:58:55 +02:00
|
|
|
* Check changes to documentation with `make test-doc -j` or `vcbuild test-doc`.
|
2020-08-22 01:54:59 +02:00
|
|
|
* [Use US spelling][].
|
|
|
|
* [Use serial commas][].
|
2020-07-14 07:03:35 +02:00
|
|
|
* Avoid first-person pronouns (_I_, _we_).
|
|
|
|
* Exception: _we recommend foo_ is preferable to _foo is recommended_.
|
|
|
|
* Use gender-neutral pronouns and gender-neutral plural nouns.
|
|
|
|
* 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.
|
2020-03-04 06:23:59 +01:00
|
|
|
* Prefer affixing links (`[a link][]`) to inlining links
|
|
|
|
(`[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.
|
2022-03-09 23:33:20 +01:00
|
|
|
* When documenting APIs, every function should have a usage example or
|
|
|
|
link to an example that uses the function.
|
2017-02-12 10:12:11 +01:00
|
|
|
* For code blocks:
|
2021-10-07 06:40:23 +02:00
|
|
|
* Use [language][]-aware fences. (<code>\`\`\`js</code>)
|
|
|
|
|
2020-06-23 09:45:00 +02:00
|
|
|
* For the [info string][], use one of the following.
|
|
|
|
|
2020-10-14 19:37:04 +02:00
|
|
|
| Meaning | Info string |
|
|
|
|
| ------------- | ------------ |
|
|
|
|
| Bash | `bash` |
|
|
|
|
| C | `c` |
|
|
|
|
| C++ | `cpp` |
|
|
|
|
| CoffeeScript | `coffee` |
|
|
|
|
| Diff | `diff` |
|
|
|
|
| HTTP | `http` |
|
|
|
|
| JavaScript | `js` |
|
|
|
|
| JSON | `json` |
|
|
|
|
| Markdown | `markdown` |
|
|
|
|
| Plaintext | `text` |
|
|
|
|
| Powershell | `powershell` |
|
|
|
|
| R | `r` |
|
|
|
|
| Shell Session | `console` |
|
2020-06-23 09:45:00 +02:00
|
|
|
|
|
|
|
If one of your language-aware fences needs an info string that is not
|
|
|
|
already on this list, you may use `text` until the grammar gets added to
|
|
|
|
[`remark-preset-lint-node`][].
|
|
|
|
|
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:
|
2021-10-07 06:40:23 +02:00
|
|
|
* ``* `name` {type|type2} Optional description. **Default:** `value`.``
|
2018-06-16 00:49:23 +02:00
|
|
|
<!--lint disable maximum-line-length remark-lint-->
|
2021-10-07 06:40:23 +02:00
|
|
|
* For example: <code>\* `byteOffset` {integer} Index of first byte to expose. **Default:** `0`.</code>
|
2018-06-16 00:49:23 +02:00
|
|
|
<!--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:
|
2021-10-07 06:40:23 +02:00
|
|
|
* <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
|
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.
|
2020-08-22 01:54:59 +02:00
|
|
|
* [Be direct][].
|
2021-10-07 06:40:23 +02:00
|
|
|
|
2020-08-22 01:54:59 +02:00
|
|
|
<!-- lint disable prohibited-strings remark-lint-->
|
2021-10-07 06:40:23 +02:00
|
|
|
|
2020-06-05 19:33:27 +02:00
|
|
|
* When referring to a version of Node.js in prose, use _Node.js_ and the version
|
|
|
|
number. Do not prefix the version number with _v_ in prose. This is to avoid
|
|
|
|
confusion about whether _v8_ refers to Node.js 8.x or the V8 JavaScript
|
|
|
|
engine.
|
2020-06-08 01:26:16 +02:00
|
|
|
<!-- lint enable prohibited-strings remark-lint-->
|
2020-06-05 19:33:27 +02:00
|
|
|
* OK: _Node.js 14.x_, _Node.js 14.3.1_
|
|
|
|
* NOT OK: _Node.js v14_
|
2020-08-22 01:54:59 +02:00
|
|
|
* [Use sentence-style capitalization for headings][].
|
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][].
|
|
|
|
|
2020-08-18 08:01:10 +02:00
|
|
|
For topics not covered here, refer to the [Microsoft Writing Style Guide][].
|
|
|
|
|
2020-08-22 01:54:59 +02:00
|
|
|
[Be direct]: https://docs.microsoft.com/en-us/style-guide/word-choice/use-simple-words-concise-sentences
|
2020-08-18 08:01:10 +02:00
|
|
|
[Javascript type]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Data_structures_and_types
|
|
|
|
[Microsoft Writing Style Guide]: https://docs.microsoft.com/en-us/style-guide/welcome/
|
2020-08-22 01:54:59 +02:00
|
|
|
[Use US spelling]: https://docs.microsoft.com/en-us/style-guide/word-choice/use-us-spelling-avoid-non-english-words
|
|
|
|
[Use sentence-style capitalization for headings]: https://docs.microsoft.com/en-us/style-guide/scannable-content/headings#formatting-headings
|
|
|
|
[Use serial commas]: https://docs.microsoft.com/en-us/style-guide/punctuation/commas
|
2020-08-18 08:01:10 +02:00
|
|
|
[`remark-preset-lint-node`]: https://github.com/nodejs/remark-preset-lint-node
|
2021-12-11 05:26:27 +01:00
|
|
|
[doctools README]: ../tools/doc/README.md
|
2020-06-23 09:45:00 +02:00
|
|
|
[info string]: https://github.github.com/gfm/#info-string
|
2021-02-17 20:49:52 +01:00
|
|
|
[language]: https://github.com/highlightjs/highlight.js/blob/HEAD/SUPPORTED_LANGUAGES.md
|
2019-09-04 08:39:05 +02:00
|
|
|
[plugin]: https://editorconfig.org/#download
|