Skip to content

Commit cd2824c

Browse files
aqrlnjasnell
authored andcommitted
doc: make the style of notes consistent
Make the style of "Note:" paragraphs consistent and document the guidelines in `doc/STYLE_GUIDE.md`. PR-URL: #13133 Fixes: #13131 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Daijiro Wachi <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
1 parent d99b7bc commit cd2824c

28 files changed

+189
-174
lines changed

doc/STYLE_GUIDE.md

+4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@
6161
* References to constructor instances should use camelCase.
6262
* References to methods should be used with parentheses: for example,
6363
`socket.end()` instead of `socket.end`.
64+
* To draw special attention to a note, adhere to the following guidelines:
65+
* Make the "Note:" label italic, i.e. `*Note*:`.
66+
* Use a capital letter after the "Note:" label.
67+
* Preferably, make the note a new paragraph for better visual distinction.
6468

6569
[plugin]: http://editorconfig.org/#download
6670
[Oxford comma]: https://en.wikipedia.org/wiki/Serial_comma

doc/api/addons.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ specifically to compile Node.js Addons.
113113
}
114114
```
115115

116-
*Note: A version of the `node-gyp` utility is bundled and distributed with
116+
*Note*: A version of the `node-gyp` utility is bundled and distributed with
117117
Node.js as part of `npm`. This version is not made directly available for
118118
developers to use and is intended only to support the ability to use the
119119
`npm install` command to compile and install Addons. Developers who wish to
120120
use `node-gyp` directly can install it using the command
121121
`npm install -g node-gyp`. See the `node-gyp` [installation instructions][] for
122-
more information, including platform-specific requirements.*
122+
more information, including platform-specific requirements.
123123

124124
Once the `binding.gyp` file has been created, use `node-gyp configure` to
125125
generate the appropriate project build files for the current platform. This

doc/api/buffer.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,11 @@ The character encodings currently supported by Node.js include:
193193

194194
* `'hex'` - Encode each byte as two hexadecimal characters.
195195

196-
_Note_: Today's browsers follow the [WHATWG spec] which aliases both 'latin1' and
197-
ISO-8859-1 to win-1252. This means that while doing something like `http.get()`,
198-
if the returned charset is one of those listed in the WHATWG spec it's possible
199-
that the server actually returned win-1252-encoded data, and using `'latin1'`
200-
encoding may incorrectly decode the characters.
196+
*Note*: Today's browsers follow the [WHATWG spec] which aliases both 'latin1'
197+
and ISO-8859-1 to win-1252. This means that while doing something like
198+
`http.get()`, if the returned charset is one of those listed in the WHATWG spec
199+
it's possible that the server actually returned win-1252-encoded data, and
200+
using `'latin1'` encoding may incorrectly decode the characters.
201201

202202
## Buffers and TypedArray
203203
<!-- YAML
@@ -686,7 +686,7 @@ Returns the actual byte length of a string. This is not the same as
686686
[`String.prototype.length`] since that returns the number of *characters* in
687687
a string.
688688

689-
*Note* that for `'base64'` and `'hex'`, this function assumes valid input. For
689+
*Note*: For `'base64'` and `'hex'`, this function assumes valid input. For
690690
strings that contain non-Base64/Hex-encoded data (e.g. whitespace), the return
691691
value might be greater than the length of a `Buffer` created from the string.
692692

@@ -1868,8 +1868,8 @@ changes:
18681868
Returns a new `Buffer` that references the same memory as the original, but
18691869
offset and cropped by the `start` and `end` indices.
18701870

1871-
**Note that modifying the new `Buffer` slice will modify the memory in the
1872-
original `Buffer` because the allocated memory of the two objects overlap.**
1871+
*Note*: Modifying the new `Buffer` slice will modify the memory in the
1872+
original `Buffer` because the allocated memory of the two objects overlap.
18731873

18741874
Example: Create a `Buffer` with the ASCII alphabet, take a slice, and then modify
18751875
one byte from the original `Buffer`

doc/api/child_process.md

+24-22
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ exec('echo "The \\$HOME variable is $HOME"');
163163
//The $HOME variable is escaped in the first instance, but not in the second
164164
```
165165

166-
**Note: Never pass unsanitised user input to this function. Any input
166+
*Note*: Never pass unsanitised user input to this function. Any input
167167
containing shell metacharacters may be used to trigger arbitrary command
168-
execution.**
168+
execution.
169169

170170
```js
171171
const exec = require('child_process').exec;
@@ -211,8 +211,8 @@ If `timeout` is greater than `0`, the parent will send the signal
211211
identified by the `killSignal` property (the default is `'SIGTERM'`) if the
212212
child runs longer than `timeout` milliseconds.
213213

214-
*Note: Unlike the exec(3) POSIX system call, `child_process.exec()` does not
215-
replace the existing process and uses a shell to execute the command.*
214+
*Note*: Unlike the exec(3) POSIX system call, `child_process.exec()` does not
215+
replace the existing process and uses a shell to execute the command.
216216

217217
If this method is invoked as its [`util.promisify()`][]ed version, it returns
218218
a Promise for an object with `stdout` and `stderr` properties.
@@ -348,8 +348,8 @@ parent process using the file descriptor (fd) identified using the
348348
environment variable `NODE_CHANNEL_FD` on the child process. The input and
349349
output on this fd is expected to be line delimited JSON objects.
350350

351-
*Note: Unlike the fork(2) POSIX system call, `child_process.fork()` does
352-
not clone the current process.*
351+
*Note*: Unlike the fork(2) POSIX system call, `child_process.fork()` does
352+
not clone the current process.
353353

354354
### child_process.spawn(command[, args][, options])
355355
<!-- YAML
@@ -387,9 +387,9 @@ The `child_process.spawn()` method spawns a new process using the given
387387
`command`, with command line arguments in `args`. If omitted, `args` defaults
388388
to an empty array.
389389

390-
**Note: If the `shell` option is enabled, do not pass unsanitised user input to
390+
*Note*: If the `shell` option is enabled, do not pass unsanitised user input to
391391
this function. Any input containing shell metacharacters may be used to
392-
trigger arbitrary command execution.**
392+
trigger arbitrary command execution.
393393

394394
A third argument may be used to specify additional options, with these defaults:
395395

@@ -476,13 +476,13 @@ child.on('error', (err) => {
476476
});
477477
```
478478

479-
*Note: Certain platforms (macOS, Linux) will use the value of `argv[0]` for the
480-
process title while others (Windows, SunOS) will use `command`.*
479+
*Note*: Certain platforms (macOS, Linux) will use the value of `argv[0]` for
480+
the process title while others (Windows, SunOS) will use `command`.
481481

482-
*Note: Node.js currently overwrites `argv[0]` with `process.execPath` on
482+
*Note*: Node.js currently overwrites `argv[0]` with `process.execPath` on
483483
startup, so `process.argv[0]` in a Node.js child process will not match the
484484
`argv0` parameter passed to `spawn` from the parent, retrieve it with the
485-
`process.argv0` property instead.*
485+
`process.argv0` property instead.
486486

487487
#### options.detached
488488
<!-- YAML
@@ -673,9 +673,11 @@ The `child_process.execFileSync()` method is generally identical to
673673
[`child_process.execFile()`][] with the exception that the method will not return
674674
until the child process has fully closed. When a timeout has been encountered
675675
and `killSignal` is sent, the method won't return until the process has
676-
completely exited. *Note that if the child process intercepts and handles
677-
the `SIGTERM` signal and does not exit, the parent process will still wait
678-
until the child process has exited.*
676+
completely exited.
677+
678+
*Note*: If the child process intercepts and handles the `SIGTERM` signal and
679+
does not exit, the parent process will still wait until the child process has
680+
exited.
679681

680682
If the process times out, or has a non-zero exit code, this method ***will***
681683
throw. The [`Error`][] object will contain the entire result from
@@ -729,9 +731,9 @@ If the process times out, or has a non-zero exit code, this method ***will***
729731
throw. The [`Error`][] object will contain the entire result from
730732
[`child_process.spawnSync()`][]
731733

732-
**Note: Never pass unsanitised user input to this function. Any input
734+
*Note*: Never pass unsanitised user input to this function. Any input
733735
containing shell metacharacters may be used to trigger arbitrary command
734-
execution.**
736+
execution.
735737

736738
### child_process.spawnSync(command[, args][, options])
737739
<!-- YAML
@@ -789,9 +791,9 @@ completely exited. Note that if the process intercepts and handles the
789791
`SIGTERM` signal and doesn't exit, the parent process will wait until the child
790792
process has exited.
791793

792-
**Note: If the `shell` option is enabled, do not pass unsanitised user input to
793-
this function. Any input containing shell metacharacters may be used to
794-
trigger arbitrary command execution.**
794+
*Note*: If the `shell` option is enabled, do not pass unsanitised user input
795+
to this function. Any input containing shell metacharacters may be used to
796+
trigger arbitrary command execution.
795797

796798
## Class: ChildProcess
797799
<!-- YAML
@@ -1166,8 +1168,8 @@ tracking when the socket is destroyed. To indicate this, the `.connections`
11661168
property becomes `null`. It is recommended not to use `.maxConnections` when
11671169
this occurs.
11681170

1169-
*Note: this function uses [`JSON.stringify()`][] internally to serialize the
1170-
`message`.*
1171+
*Note*: This function uses [`JSON.stringify()`][] internally to serialize the
1172+
`message`.
11711173

11721174
### child.stderr
11731175
<!-- YAML

doc/api/cli.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ added: v0.1.3
290290

291291
Print v8 command line options.
292292

293-
Note: v8 options allow words to be separated by both dashes (`-`) or underscores
294-
(`_`).
293+
*Note*: V8 options allow words to be separated by both dashes (`-`) or
294+
underscores (`_`).
295295

296296
For example, `--stack-trace-limit` is equivalent to `--stack_trace_limit`.
297297

@@ -394,7 +394,7 @@ added: v0.1.32
394394

395395
`':'`-separated list of directories prefixed to the module search path.
396396

397-
_Note: on Windows, this is a `';'`-separated list instead._
397+
*Note*: On Windows, this is a `';'`-separated list instead.
398398

399399

400400
### `NODE_DISABLE_COLORS=1`
@@ -525,7 +525,7 @@ added: v7.7.0
525525
If `--use-openssl-ca` is enabled, this overrides and sets OpenSSL's directory
526526
containing trusted certificates.
527527

528-
Note: Be aware that unless the child environment is explicitly set, this
528+
*Note*: Be aware that unless the child environment is explicitly set, this
529529
evironment variable will be inherited by any child processes, and if they use
530530
OpenSSL, it may cause them to trust the same CAs as node.
531531

@@ -537,7 +537,7 @@ added: v7.7.0
537537
If `--use-openssl-ca` is enabled, this overrides and sets OpenSSL's file
538538
containing trusted certificates.
539539

540-
Note: Be aware that unless the child environment is explicitly set, this
540+
*Note*: Be aware that unless the child environment is explicitly set, this
541541
evironment variable will be inherited by any child processes, and if they use
542542
OpenSSL, it may cause them to trust the same CAs as node.
543543

doc/api/console.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ console.assert(false, 'Whoops %s', 'didn\'t work');
121121
// AssertionError: Whoops didn't work
122122
```
123123

124-
*Note: the `console.assert()` method is implemented differently in Node.js
125-
than the `console.assert()` method [available in browsers][web-api-assert].*
124+
*Note*: The `console.assert()` method is implemented differently in Node.js
125+
than the `console.assert()` method [available in browsers][web-api-assert].
126126

127127
Specifically, in browsers, calling `console.assert()` with a falsy
128128
assertion will cause the `message` to be printed to the console without
@@ -282,10 +282,10 @@ console.timeEnd('100-elements');
282282
// prints 100-elements: 225.438ms
283283
```
284284

285-
*Note: As of Node.js v6.0.0, `console.timeEnd()` deletes the timer to avoid
285+
*Note*: As of Node.js v6.0.0, `console.timeEnd()` deletes the timer to avoid
286286
leaking it. On older versions, the timer persisted. This allowed
287287
`console.timeEnd()` to be called multiple times for the same label. This
288-
functionality was unintended and is no longer supported.*
288+
functionality was unintended and is no longer supported.
289289

290290
### console.trace([message][, ...args])
291291
<!-- YAML

doc/api/crypto.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,7 @@ comparing HMAC digests or secret values like authentication cookies or
18201820
`a` and `b` must both be `Buffer`s, `TypedArray`s, or `DataView`s, and they
18211821
must have the same length.
18221822

1823-
**Note**: Use of `crypto.timingSafeEqual` does not guarantee that the
1823+
*Note*: Use of `crypto.timingSafeEqual` does not guarantee that the
18241824
*surrounding* code is timing-safe. Care should be taken to ensure that the
18251825
surrounding code does not introduce timing vulnerabilities.
18261826

doc/api/deprecations.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,8 @@ Type: Documentation-only
531531
The `http` module `ServerResponse.prototype.writeHeader()` API has been
532532
deprecated. Please use `ServerResponse.prototype.writeHead()` instead.
533533

534-
*Note*: The `ServerResponse.prototype.writeHeader()` method was never documented
535-
as an officially supported API.
534+
*Note*: The `ServerResponse.prototype.writeHeader()` method was never
535+
documented as an officially supported API.
536536

537537
<a id="DEP0064"></a>
538538
### DEP0064: tls.createSecurePair()
@@ -568,8 +568,8 @@ properties have been deprecated. Please instead use one of the public methods
568568
`outgoingMessage.removeHeader()`, `outgoingMessage.setHeader()`) for working
569569
with outgoing headers.
570570

571-
*Note*: `outgoingMessage._headers` and `outgoingMessage._headerNames` were never
572-
documented as officially supported properties.
571+
*Note*: `outgoingMessage._headers` and `outgoingMessage._headerNames` were
572+
never documented as officially supported properties.
573573

574574
<a id="DEP0067"></a>
575575
### DEP0067: OutgoingMessage.prototype.\_renderHeaders

doc/api/domain.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ if (cluster.isMaster) {
115115
d.on('error', (er) => {
116116
console.error(`error ${er.stack}`);
117117

118-
// Note: we're in dangerous territory!
118+
// Note: We're in dangerous territory!
119119
// By definition, something unexpected occurred,
120120
// which we probably didn't want.
121121
// Anything can happen now! Be very careful!

doc/api/events.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ myEmitter.emit('error', new Error('whoops!'));
142142

143143
To guard against crashing the Node.js process, a listener can be registered
144144
on the [`process` object's `uncaughtException` event][] or the [`domain`][] module
145-
can be used. (_Note, however, that the `domain` module has been deprecated_)
145+
can be used. (Note, however, that the `domain` module has been deprecated.)
146146

147147
```js
148148
const myEmitter = new MyEmitter();

doc/api/fs.md

+16-14
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ filesystems that allow for non-UTF-8 filenames. For most typical
194194
uses, working with paths as Buffers will be unnecessary, as the string
195195
API converts to and from UTF-8 automatically.
196196

197-
*Note* that on certain file systems (such as NTFS and HFS+) filenames
197+
*Note*: On certain file systems (such as NTFS and HFS+) filenames
198198
will always be encoded as UTF-8. On such file systems, passing
199199
non-UTF-8 encoded Buffers to `fs` functions will not work as expected.
200200

@@ -1546,8 +1546,8 @@ On Linux, positional writes don't work when the file is opened in append mode.
15461546
The kernel ignores the position argument and always appends the data to
15471547
the end of the file.
15481548

1549-
*Note*: The behavior of `fs.open()` is platform-specific for some flags. As such,
1550-
opening a directory on macOS and Linux with the `'a+'` flag - see example
1549+
*Note*: The behavior of `fs.open()` is platform-specific for some flags. As
1550+
such, opening a directory on macOS and Linux with the `'a+'` flag - see example
15511551
below - will return an error. In contrast, on Windows and FreeBSD, a file
15521552
descriptor will be returned.
15531553

@@ -2156,9 +2156,9 @@ effectively stopping watching of `filename`.
21562156
Calling `fs.unwatchFile()` with a filename that is not being watched is a
21572157
no-op, not an error.
21582158

2159-
*Note*: [`fs.watch()`][] is more efficient than `fs.watchFile()` and `fs.unwatchFile()`.
2160-
`fs.watch()` should be used instead of `fs.watchFile()` and `fs.unwatchFile()`
2161-
when possible.
2159+
*Note*: [`fs.watch()`][] is more efficient than `fs.watchFile()` and
2160+
`fs.unwatchFile()`. `fs.watch()` should be used instead of `fs.watchFile()`
2161+
and `fs.unwatchFile()` when possible.
21622162

21632163
## fs.utimes(path, atime, mtime, callback)
21642164
<!-- YAML
@@ -2185,7 +2185,7 @@ changes:
21852185

21862186
Change file timestamps of the file referenced by the supplied path.
21872187

2188-
Note: the arguments `atime` and `mtime` of the following related functions
2188+
*Note*: The arguments `atime` and `mtime` of the following related functions
21892189
follow these rules:
21902190

21912191
- The value should be a Unix timestamp in seconds. For example, `Date.now()`
@@ -2366,11 +2366,12 @@ These stat objects are instances of `fs.Stat`.
23662366
To be notified when the file was modified, not just accessed, it is necessary
23672367
to compare `curr.mtime` and `prev.mtime`.
23682368

2369-
*Note*: when an `fs.watchFile` operation results in an `ENOENT` error, it will
2370-
invoke the listener once, with all the fields zeroed (or, for dates, the Unix
2371-
Epoch). In Windows, `blksize` and `blocks` fields will be `undefined`, instead
2372-
of zero. If the file is created later on, the listener will be called again,
2373-
with the latest stat objects. This is a change in functionality since v0.10.
2369+
*Note*: When an `fs.watchFile` operation results in an `ENOENT` error, it
2370+
will invoke the listener once, with all the fields zeroed (or, for dates, the
2371+
Unix Epoch). In Windows, `blksize` and `blocks` fields will be `undefined`,
2372+
instead of zero. If the file is created later on, the listener will be called
2373+
again, with the latest stat objects. This is a change in functionality since
2374+
v0.10.
23742375

23752376
*Note*: [`fs.watch()`][] is more efficient than `fs.watchFile` and
23762377
`fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and
@@ -2577,8 +2578,9 @@ Synchronous versions of [`fs.write()`][]. Returns the number of bytes written.
25772578

25782579
## FS Constants
25792580

2580-
The following constants are exported by `fs.constants`. **Note:** Not every
2581-
constant will be available on every operating system.
2581+
The following constants are exported by `fs.constants`.
2582+
2583+
*Note*: Not every constant will be available on every operating system.
25822584

25832585
### File Access Constants
25842586

doc/api/http.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ Until the data is consumed, the `'end'` event will not fire. Also, until
268268
the data is read it will consume memory that can eventually lead to a
269269
'process out of memory' error.
270270

271-
Note: Node.js does not check whether Content-Length and the length of the body
272-
which has been transmitted are equal or not.
271+
*Note*: Node.js does not check whether Content-Length and the length of the
272+
body which has been transmitted are equal or not.
273273

274274
The request implements the [Writable Stream][] interface. This is an
275275
[`EventEmitter`][] with the following events:
@@ -765,7 +765,7 @@ Begin accepting connections on the specified `port` and `hostname`. If the
765765
[unspecified IPv6 address][] (`::`) when IPv6 is available, or the
766766
[unspecified IPv4 address][] (`0.0.0.0`) otherwise.
767767

768-
*Note*: in most operating systems, listening to the
768+
*Note*: In most operating systems, listening to the
769769
[unspecified IPv6 address][] (`::`) may cause the `net.Server` to also listen on
770770
the [unspecified IPv4 address][] (`0.0.0.0`).
771771

@@ -1177,7 +1177,7 @@ the second parameter specifies how to encode it into a byte stream.
11771177
By default the `encoding` is `'utf8'`. `callback` will be called when this chunk
11781178
of data is flushed.
11791179

1180-
**Note**: This is the raw HTTP body and has nothing to do with
1180+
*Note*: This is the raw HTTP body and has nothing to do with
11811181
higher-level multi-part body encodings that may be used.
11821182

11831183
The first time [`response.write()`][] is called, it will send the buffered

0 commit comments

Comments
 (0)