Skip to content

Commit

Permalink
doc,tools: formalize, unify, codify default values
Browse files Browse the repository at this point in the history
PR-URL: #19737
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
vsemozhetbyt committed Apr 4, 2018
1 parent f7049a2 commit 237cbe1
Show file tree
Hide file tree
Showing 32 changed files with 347 additions and 382 deletions.
6 changes: 3 additions & 3 deletions doc/STYLE_GUIDE.md
Expand Up @@ -59,9 +59,9 @@
* Use a capital letter after the "Note:" label.
* Preferably, make the note a new paragraph for better visual distinction.
* Function arguments or object properties should use the following format:
* <code>* \`name\` {type|type2} Optional description. \*\*Default:\*\* \`defaultValue\`</code>
* E.g. <code>* `byteOffset` {integer} Index of first byte to expose. **Default:** `0`</code>
* The `type` should refer to a Node.js type or a [JavaScript type][]
* <code>* \`name\` {type|type2} Optional description. \*\*Default:\*\* \`defaultValue\`.</code>
* E.g. <code>* `byteOffset` {integer} Index of first byte to expose. **Default:** `0`.</code>
* The `type` should refer to a Node.js type or a [JavaScript type][].
* Function returns should use the following format:
* <code>* Returns: {type|type2} Optional description.</code>
* E.g. <code>* Returns: {AsyncHook} A reference to `asyncHook`.</code>
Expand Down
2 changes: 1 addition & 1 deletion doc/api/assert.md
Expand Up @@ -503,7 +503,7 @@ changes:
* `actual` {any}
* `expected` {any}
* `message` {any}
* `operator` {string} **Default:** '!='
* `operator` {string} **Default:** `'!='`
* `stackStartFunction` {Function} **Default:** `assert.fail`

> Stability: 0 - Deprecated: Use `assert.fail([message])` or other assert
Expand Down
5 changes: 2 additions & 3 deletions doc/api/async_hooks.md
Expand Up @@ -634,12 +634,11 @@ asyncResource.emitAfter();
* `type` {string} The type of async event.
* `options` {Object}
* `triggerAsyncId` {number} The ID of the execution context that created this
async event. **Default:** `executionAsyncId()`
async event. **Default:** `executionAsyncId()`.
* `requireManualDestroy` {boolean} Disables automatic `emitDestroy` when the
object is garbage collected. This usually does not need to be set (even if
`emitDestroy` is called manually), unless the resource's asyncId is retrieved
and the sensitive API's `emitDestroy` is called with it.
**Default:** `false`
and the sensitive API's `emitDestroy` is called with it. **Default:** `false`.

Example usage:

Expand Down
68 changes: 34 additions & 34 deletions doc/api/buffer.md
Expand Up @@ -345,9 +345,9 @@ changes:
* `arrayBuffer` {ArrayBuffer|SharedArrayBuffer} An [`ArrayBuffer`],
[`SharedArrayBuffer`] or the `.buffer` property of a [`TypedArray`].
* `byteOffset` {integer} Index of first byte to expose. **Default:** `0`
* `byteOffset` {integer} Index of first byte to expose. **Default:** `0`.
* `length` {integer} Number of bytes to expose.
**Default:** `arrayBuffer.length - byteOffset`
**Default:** `arrayBuffer.length - byteOffset`.

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

Creates a new `Buffer` containing `string`. The `encoding` parameter identifies
the character encoding of `string`.
Expand Down Expand Up @@ -496,9 +496,9 @@ changes:

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

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

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

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

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

* `string` {string} A string to encode.
* `encoding` {string} The encoding of `string`. **Default:** `'utf8'`
* `encoding` {string} The encoding of `string`. **Default:** `'utf8'`.

Creates a new `Buffer` containing `string`. The `encoding` parameter identifies
the character encoding of `string`.
Expand Down Expand Up @@ -984,13 +984,13 @@ changes:

* `target` {Buffer|Uint8Array} A `Buffer` or [`Uint8Array`] to compare to.
* `targetStart` {integer} The offset within `target` at which to begin
comparison. **Default:** `0`
comparison. **Default:** `0`.
* `targetEnd` {integer} The offset with `target` at which to end comparison
(not inclusive). **Default:** `target.length`
(not inclusive). **Default:** `target.length`.
* `sourceStart` {integer} The offset within `buf` at which to begin comparison.
**Default:** `0`
**Default:** `0`.
* `sourceEnd` {integer} The offset within `buf` at which to end comparison
(not inclusive). **Default:** [`buf.length`]
(not inclusive). **Default:** [`buf.length`].
* Returns: {integer}

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

* `target` {Buffer|Uint8Array} A `Buffer` or [`Uint8Array`] to copy into.
* `targetStart` {integer} The offset within `target` at which to begin
copying to. **Default:** `0`
copying to. **Default:** `0`.
* `sourceStart` {integer} The offset within `buf` at which to begin copying from.
**Default:** `0`
**Default:** `0`.
* `sourceEnd` {integer} The offset within `buf` at which to stop copying (not
inclusive). **Default:** [`buf.length`]
inclusive). **Default:** [`buf.length`].
* Returns: {integer} The number of bytes copied.

Copies data from a region of `buf` to a region in `target` even if the `target`
Expand Down Expand Up @@ -1165,10 +1165,10 @@ changes:
-->

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

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

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

Equivalent to [`buf.indexOf() !== -1`][`buf.indexOf()`].
Expand Down Expand Up @@ -1256,9 +1256,9 @@ changes:
-->

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

Expand Down Expand Up @@ -1358,9 +1358,9 @@ changes:

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

Expand Down Expand Up @@ -1792,9 +1792,9 @@ changes:
calculations with them.
-->

* `start` {integer} Where the new `Buffer` will start. **Default:** `0`
* `start` {integer} Where the new `Buffer` will start. **Default:** `0`.
* `end` {integer} Where the new `Buffer` will end (not inclusive).
**Default:** [`buf.length`]
**Default:** [`buf.length`].
* Returns: {Buffer}

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

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

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

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

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

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

0 comments on commit 237cbe1

Please sign in to comment.