Skip to content

Commit 237cbe1

Browse files
committed
doc,tools: formalize, unify, codify default values
PR-URL: #19737 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent f7049a2 commit 237cbe1

32 files changed

+347
-382
lines changed

doc/STYLE_GUIDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@
5959
* Use a capital letter after the "Note:" label.
6060
* Preferably, make the note a new paragraph for better visual distinction.
6161
* Function arguments or object properties should use the following format:
62-
* <code>* \`name\` {type|type2} Optional description. \*\*Default:\*\* \`defaultValue\`</code>
63-
* E.g. <code>* `byteOffset` {integer} Index of first byte to expose. **Default:** `0`</code>
64-
* The `type` should refer to a Node.js type or a [JavaScript type][]
62+
* <code>* \`name\` {type|type2} Optional description. \*\*Default:\*\* \`defaultValue\`.</code>
63+
* E.g. <code>* `byteOffset` {integer} Index of first byte to expose. **Default:** `0`.</code>
64+
* The `type` should refer to a Node.js type or a [JavaScript type][].
6565
* Function returns should use the following format:
6666
* <code>* Returns: {type|type2} Optional description.</code>
6767
* E.g. <code>* Returns: {AsyncHook} A reference to `asyncHook`.</code>

doc/api/assert.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ changes:
503503
* `actual` {any}
504504
* `expected` {any}
505505
* `message` {any}
506-
* `operator` {string} **Default:** '!='
506+
* `operator` {string} **Default:** `'!='`
507507
* `stackStartFunction` {Function} **Default:** `assert.fail`
508508

509509
> Stability: 0 - Deprecated: Use `assert.fail([message])` or other assert

doc/api/async_hooks.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -634,12 +634,11 @@ asyncResource.emitAfter();
634634
* `type` {string} The type of async event.
635635
* `options` {Object}
636636
* `triggerAsyncId` {number} The ID of the execution context that created this
637-
async event. **Default:** `executionAsyncId()`
637+
async event. **Default:** `executionAsyncId()`.
638638
* `requireManualDestroy` {boolean} Disables automatic `emitDestroy` when the
639639
object is garbage collected. This usually does not need to be set (even if
640640
`emitDestroy` is called manually), unless the resource's asyncId is retrieved
641-
and the sensitive API's `emitDestroy` is called with it.
642-
**Default:** `false`
641+
and the sensitive API's `emitDestroy` is called with it. **Default:** `false`.
643642

644643
Example usage:
645644

doc/api/buffer.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,9 @@ changes:
345345
346346
* `arrayBuffer` {ArrayBuffer|SharedArrayBuffer} An [`ArrayBuffer`],
347347
[`SharedArrayBuffer`] or the `.buffer` property of a [`TypedArray`].
348-
* `byteOffset` {integer} Index of first byte to expose. **Default:** `0`
348+
* `byteOffset` {integer} Index of first byte to expose. **Default:** `0`.
349349
* `length` {integer} Number of bytes to expose.
350-
**Default:** `arrayBuffer.length - byteOffset`
350+
**Default:** `arrayBuffer.length - byteOffset`.
351351

352352
This creates a view of the [`ArrayBuffer`] or [`SharedArrayBuffer`] without
353353
copying the underlying memory. For example, when passed a reference to the
@@ -459,7 +459,7 @@ changes:
459459
> Use [`Buffer.from(string[, encoding])`][`Buffer.from(string)`] instead.
460460
461461
* `string` {string} String to encode.
462-
* `encoding` {string} The encoding of `string`. **Default:** `'utf8'`
462+
* `encoding` {string} The encoding of `string`. **Default:** `'utf8'`.
463463

464464
Creates a new `Buffer` containing `string`. The `encoding` parameter identifies
465465
the character encoding of `string`.
@@ -496,9 +496,9 @@ changes:
496496

497497
* `size` {integer} The desired length of the new `Buffer`.
498498
* `fill` {string|Buffer|integer} A value to pre-fill the new `Buffer` with.
499-
**Default:** `0`
499+
**Default:** `0`.
500500
* `encoding` {string} If `fill` is a string, this is its encoding.
501-
**Default:** `'utf8'`
501+
**Default:** `'utf8'`.
502502

503503
Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the
504504
`Buffer` will be *zero-filled*.
@@ -654,7 +654,7 @@ changes:
654654
* `string` {string|Buffer|TypedArray|DataView|ArrayBuffer|SharedArrayBuffer} A
655655
value to calculate the length of.
656656
* `encoding` {string} If `string` is a string, this is its encoding.
657-
**Default:** `'utf8'`
657+
**Default:** `'utf8'`.
658658
* Returns: {integer} The number of bytes contained within `string`.
659659

660660
Returns the actual byte length of a string. This is not the same as
@@ -774,9 +774,9 @@ added: v5.10.0
774774

775775
* `arrayBuffer` {ArrayBuffer|SharedArrayBuffer} An [`ArrayBuffer`],
776776
[`SharedArrayBuffer`], or the `.buffer` property of a [`TypedArray`].
777-
* `byteOffset` {integer} Index of first byte to expose. **Default:** `0`
777+
* `byteOffset` {integer} Index of first byte to expose. **Default:** `0`.
778778
* `length` {integer} Number of bytes to expose.
779-
**Default:** `arrayBuffer.length - byteOffset`
779+
**Default:** `arrayBuffer.length - byteOffset`.
780780

781781
This creates a view of the [`ArrayBuffer`] without copying the underlying
782782
memory. For example, when passed a reference to the `.buffer` property of a
@@ -845,7 +845,7 @@ added: v5.10.0
845845
-->
846846

847847
* `string` {string} A string to encode.
848-
* `encoding` {string} The encoding of `string`. **Default:** `'utf8'`
848+
* `encoding` {string} The encoding of `string`. **Default:** `'utf8'`.
849849

850850
Creates a new `Buffer` containing `string`. The `encoding` parameter identifies
851851
the character encoding of `string`.
@@ -984,13 +984,13 @@ changes:
984984

985985
* `target` {Buffer|Uint8Array} A `Buffer` or [`Uint8Array`] to compare to.
986986
* `targetStart` {integer} The offset within `target` at which to begin
987-
comparison. **Default:** `0`
987+
comparison. **Default:** `0`.
988988
* `targetEnd` {integer} The offset with `target` at which to end comparison
989-
(not inclusive). **Default:** `target.length`
989+
(not inclusive). **Default:** `target.length`.
990990
* `sourceStart` {integer} The offset within `buf` at which to begin comparison.
991-
**Default:** `0`
991+
**Default:** `0`.
992992
* `sourceEnd` {integer} The offset within `buf` at which to end comparison
993-
(not inclusive). **Default:** [`buf.length`]
993+
(not inclusive). **Default:** [`buf.length`].
994994
* Returns: {integer}
995995

996996
Compares `buf` with `target` and returns a number indicating whether `buf`
@@ -1047,11 +1047,11 @@ added: v0.1.90
10471047

10481048
* `target` {Buffer|Uint8Array} A `Buffer` or [`Uint8Array`] to copy into.
10491049
* `targetStart` {integer} The offset within `target` at which to begin
1050-
copying to. **Default:** `0`
1050+
copying to. **Default:** `0`.
10511051
* `sourceStart` {integer} The offset within `buf` at which to begin copying from.
1052-
**Default:** `0`
1052+
**Default:** `0`.
10531053
* `sourceEnd` {integer} The offset within `buf` at which to stop copying (not
1054-
inclusive). **Default:** [`buf.length`]
1054+
inclusive). **Default:** [`buf.length`].
10551055
* Returns: {integer} The number of bytes copied.
10561056

10571057
Copies data from a region of `buf` to a region in `target` even if the `target`
@@ -1165,10 +1165,10 @@ changes:
11651165
-->
11661166

11671167
* `value` {string|Buffer|integer} The value to fill `buf` with.
1168-
* `offset` {integer} Number of bytes to skip before starting to fill `buf`. **Default:** `0`
1169-
* `end` {integer} Where to stop filling `buf` (not inclusive). **Default:** [`buf.length`]
1168+
* `offset` {integer} Number of bytes to skip before starting to fill `buf`. **Default:** `0`.
1169+
* `end` {integer} Where to stop filling `buf` (not inclusive). **Default:** [`buf.length`].
11701170
* `encoding` {string} If `value` is a string, this is its encoding.
1171-
**Default:** `'utf8'`
1171+
**Default:** `'utf8'`.
11721172
* Returns: {Buffer} A reference to `buf`.
11731173

11741174
Fills `buf` with the specified `value`. If the `offset` and `end` are not given,
@@ -1216,9 +1216,9 @@ added: v5.3.0
12161216
-->
12171217

12181218
* `value` {string|Buffer|integer} What to search for.
1219-
* `byteOffset` {integer} Where to begin searching in `buf`. **Default:** `0`
1219+
* `byteOffset` {integer} Where to begin searching in `buf`. **Default:** `0`.
12201220
* `encoding` {string} If `value` is a string, this is its encoding.
1221-
**Default:** `'utf8'`
1221+
**Default:** `'utf8'`.
12221222
* Returns: {boolean} `true` if `value` was found in `buf`, `false` otherwise.
12231223

12241224
Equivalent to [`buf.indexOf() !== -1`][`buf.indexOf()`].
@@ -1256,9 +1256,9 @@ changes:
12561256
-->
12571257

12581258
* `value` {string|Buffer|Uint8Array|integer} What to search for.
1259-
* `byteOffset` {integer} Where to begin searching in `buf`. **Default:** `0`
1259+
* `byteOffset` {integer} Where to begin searching in `buf`. **Default:** `0`.
12601260
* `encoding` {string} If `value` is a string, this is its encoding.
1261-
**Default:** `'utf8'`
1261+
**Default:** `'utf8'`.
12621262
* Returns: {integer} The index of the first occurrence of `value` in `buf` or `-1`
12631263
if `buf` does not contain `value`.
12641264

@@ -1358,9 +1358,9 @@ changes:
13581358

13591359
* `value` {string|Buffer|Uint8Array|integer} What to search for.
13601360
* `byteOffset` {integer} Where to begin searching in `buf`.
1361-
**Default:** [`buf.length`]` - 1`
1361+
**Default:** [`buf.length`]` - 1`.
13621362
* `encoding` {string} If `value` is a string, this is its encoding.
1363-
**Default:** `'utf8'`
1363+
**Default:** `'utf8'`.
13641364
* Returns: {integer} The index of the last occurrence of `value` in `buf` or `-1`
13651365
if `buf` does not contain `value`.
13661366

@@ -1792,9 +1792,9 @@ changes:
17921792
calculations with them.
17931793
-->
17941794

1795-
* `start` {integer} Where the new `Buffer` will start. **Default:** `0`
1795+
* `start` {integer} Where the new `Buffer` will start. **Default:** `0`.
17961796
* `end` {integer} Where the new `Buffer` will end (not inclusive).
1797-
**Default:** [`buf.length`]
1797+
**Default:** [`buf.length`].
17981798
* Returns: {Buffer}
17991799

18001800
Returns a new `Buffer` that references the same memory as the original, but
@@ -1963,10 +1963,10 @@ console.log(copy);
19631963
added: v0.1.90
19641964
-->
19651965

1966-
* `encoding` {string} The character encoding to decode to. **Default:** `'utf8'`
1967-
* `start` {integer} The byte offset to start decoding at. **Default:** `0`
1966+
* `encoding` {string} The character encoding to decode to. **Default:** `'utf8'`.
1967+
* `start` {integer} The byte offset to start decoding at. **Default:** `0`.
19681968
* `end` {integer} The byte offset to stop decoding at (not inclusive).
1969-
**Default:** [`buf.length`]
1969+
**Default:** [`buf.length`].
19701970
* Returns: {string}
19711971

19721972
Decodes `buf` to a string according to the specified character encoding in
@@ -2040,9 +2040,9 @@ added: v0.1.90
20402040
-->
20412041

20422042
* `string` {string} String to be written to `buf`.
2043-
* `offset` {integer} Number of bytes to skip before starting to write `string`. **Default:** `0`
2044-
* `length` {integer} Number of bytes to write. **Default:** `buf.length - offset`
2045-
* `encoding` {string} The character encoding of `string`. **Default:** `'utf8'`
2043+
* `offset` {integer} Number of bytes to skip before starting to write `string`. **Default:** `0`.
2044+
* `length` {integer} Number of bytes to write. **Default:** `buf.length - offset`.
2045+
* `encoding` {string} The character encoding of `string`. **Default:** `'utf8'`.
20462046
* Returns: {integer} Number of bytes written.
20472047

20482048
Writes `string` to `buf` at `offset` according to the character encoding in `encoding`.
@@ -2369,7 +2369,7 @@ changes:
23692369
* `value` {integer} Number to be written to `buf`.
23702370
* `offset` {integer} Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - byteLength`.
23712371
* `byteLength` {integer} Number of bytes to write. Must satisfy: `0 < byteLength <= 6`.
2372-
**Default:** `false`
2372+
**Default:** `false`.
23732373
* Returns: {integer} `offset` plus the number of bytes written.
23742374

23752375
Writes `byteLength` bytes of `value` to `buf` at the specified `offset`.

0 commit comments

Comments
 (0)