Skip to content

Commit 1a25f96

Browse files
committedAug 29, 2018
doc: remove redundant 'Example:' and similar notes
Some nits were also fixed in passing. PR-URL: #22537 Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent b2f0cfa commit 1a25f96

27 files changed

+53
-260
lines changed
 

‎doc/api/assert.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ changes:
675675
Throws `value` if `value` is not `undefined` or `null`. This is useful when
676676
testing the `error` argument in callbacks. The stack trace contains all frames
677677
from the error passed to `ifError()` including the potential new frames for
678-
`ifError()` itself. See below for an example.
678+
`ifError()` itself.
679679

680680
```js
681681
const assert = require('assert').strict;

‎doc/api/async_hooks.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,6 @@ expensive nature of the [promise introspection API][PromiseHooks] provided by
534534
V8. This means that programs using promises or `async`/`await` will not get
535535
correct execution and trigger ids for promise callback contexts by default.
536536

537-
Here's an example:
538-
539537
```js
540538
const ah = require('async_hooks');
541539
Promise.resolve(1729).then(() => {
@@ -551,7 +549,7 @@ the `triggerAsyncId` value is `0`, which means that we are missing context about
551549
the resource that caused (triggered) the `then()` callback to be executed.
552550

553551
Installing async hooks via `async_hooks.createHook` enables promise execution
554-
tracking. Example:
552+
tracking:
555553

556554
```js
557555
const ah = require('async_hooks');

‎doc/api/child_process.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,6 @@ pipes between the parent and child. The value is one of the following:
642642
words, stdin, stdout, and stderr) a pipe is created. For fd 3 and up, the
643643
default is `'ignore'`.
644644

645-
Example:
646-
647645
```js
648646
const { spawn } = require('child_process');
649647

@@ -1060,8 +1058,7 @@ See kill(2) for reference.
10601058

10611059
Also note: on Linux, child processes of child processes will not be terminated
10621060
when attempting to kill their parent. This is likely to happen when running a
1063-
new process in a shell or with use of the `shell` option of `ChildProcess`, such
1064-
as in this example:
1061+
new process in a shell or with use of the `shell` option of `ChildProcess`:
10651062

10661063
```js
10671064
'use strict';
@@ -1105,8 +1102,6 @@ added: v0.1.90
11051102

11061103
Returns the process identifier (PID) of the child process.
11071104

1108-
Example:
1109-
11101105
```js
11111106
const { spawn } = require('child_process');
11121107
const grep = spawn('grep', ['ssh']);

‎doc/api/cluster.md

-2
Original file line numberDiff line numberDiff line change
@@ -765,8 +765,6 @@ Note that:
765765
* The defaults above apply to the first call only, the defaults for later
766766
calls is the current value at the time of `cluster.setupMaster()` is called.
767767

768-
Example:
769-
770768
```js
771769
const cluster = require('cluster');
772770
cluster.setupMaster({

‎doc/api/crypto.md

+1-11
Original file line numberDiff line numberDiff line change
@@ -1678,8 +1678,6 @@ added: v0.9.3
16781678
* Returns: {string[]} An array with the names of the supported cipher
16791679
algorithms.
16801680

1681-
Example:
1682-
16831681
```js
16841682
const ciphers = crypto.getCiphers();
16851683
console.log(ciphers); // ['aes-128-cbc', 'aes-128-ccm', ...]
@@ -1691,8 +1689,6 @@ added: v2.3.0
16911689
-->
16921690
* Returns: {string[]} An array with the names of the supported elliptic curves.
16931691

1694-
Example:
1695-
16961692
```js
16971693
const curves = crypto.getCurves();
16981694
console.log(curves); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...]
@@ -1711,7 +1707,7 @@ supported groups are: `'modp1'`, `'modp2'`, `'modp5'` (defined in
17111707
`'modp16'`, `'modp17'`, `'modp18'` (defined in [RFC 3526][]). The
17121708
returned object mimics the interface of objects created by
17131709
[`crypto.createDiffieHellman()`][], but will not allow changing
1714-
the keys (with [`diffieHellman.setPublicKey()`][] for example). The
1710+
the keys (with [`diffieHellman.setPublicKey()`][], for example). The
17151711
advantage of using this method is that the parties do not have to
17161712
generate nor exchange a group modulus beforehand, saving both processor
17171713
and communication time.
@@ -1747,8 +1743,6 @@ added: v0.9.3
17471743
* Returns: {string[]} An array of the names of the supported hash algorithms,
17481744
such as `'RSA-SHA256'`.
17491745

1750-
Example:
1751-
17521746
```js
17531747
const hashes = crypto.getHashes();
17541748
console.log(hashes); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...]
@@ -1797,8 +1791,6 @@ but will take a longer amount of time to complete.
17971791
The `salt` should be as unique as possible. It is recommended that a salt is
17981792
random and at least 16 bytes long. See [NIST SP 800-132][] for details.
17991793

1800-
Example:
1801-
18021794
```js
18031795
const crypto = require('crypto');
18041796
crypto.pbkdf2('secret', 'salt', 100000, 64, 'sha512', (err, derivedKey) => {
@@ -1862,8 +1854,6 @@ but will take a longer amount of time to complete.
18621854
The `salt` should be as unique as possible. It is recommended that a salt is
18631855
random and at least 16 bytes long. See [NIST SP 800-132][] for details.
18641856

1865-
Example:
1866-
18671857
```js
18681858
const crypto = require('crypto');
18691859
const key = crypto.pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512');

‎doc/api/dgram.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -552,17 +552,16 @@ chained.
552552
### Change to asynchronous `socket.bind()` behavior
553553

554554
As of Node.js v0.10, [`dgram.Socket#bind()`][] changed to an asynchronous
555-
execution model. Legacy code that assumes synchronous behavior, as in the
556-
following example:
555+
execution model. Legacy code would use synchronous behavior:
557556

558557
```js
559558
const s = dgram.createSocket('udp4');
560559
s.bind(1234);
561560
s.addMembership('224.0.0.114');
562561
```
563562

564-
Must be changed to pass a callback function to the [`dgram.Socket#bind()`][]
565-
function:
563+
Such legacy code would need to be changed to pass a callback function to the
564+
[`dgram.Socket#bind()`][] function:
566565

567566
```js
568567
const s = dgram.createSocket('udp4');

‎doc/api/domain.md

-6
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,6 @@ The returned function will be a wrapper around the supplied callback
311311
function. When the returned function is called, any errors that are
312312
thrown will be routed to the domain's `'error'` event.
313313

314-
#### Example
315-
316314
```js
317315
const d = domain.create();
318316

@@ -370,8 +368,6 @@ objects sent as the first argument to the function.
370368
In this way, the common `if (err) return callback(err);` pattern can be replaced
371369
with a single error handler in a single place.
372370

373-
#### Example
374-
375371
```js
376372
const d = domain.create();
377373

@@ -415,8 +411,6 @@ the function.
415411

416412
This is the most basic way to use a domain.
417413

418-
Example:
419-
420414
```js
421415
const domain = require('domain');
422416
const fs = require('fs');

‎doc/api/errors.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -1243,8 +1243,7 @@ type for one of its returned object properties on execution.
12431243
### ERR_INVALID_RETURN_VALUE
12441244

12451245
Thrown in case a function option does not return an expected value
1246-
type on execution.
1247-
For example when a function is expected to return a promise.
1246+
type on execution, such as when a function is expected to return a promise.
12481247

12491248
<a id="ERR_INVALID_SYNC_FORK_INPUT"></a>
12501249
### ERR_INVALID_SYNC_FORK_INPUT
@@ -1258,8 +1257,6 @@ for more information.
12581257

12591258
A Node.js API function was called with an incompatible `this` value.
12601259

1261-
Example:
1262-
12631260
```js
12641261
const urlSearchParams = new URLSearchParams('foo=bar&baz=new');
12651262

@@ -1590,7 +1587,6 @@ emitted.
15901587
Prevents an abort if a string decoder was set on the Socket or if the decoder
15911588
is in `objectMode`.
15921589

1593-
Example
15941590
```js
15951591
const Socket = require('net').Socket;
15961592
const instance = new Socket();

‎doc/api/fs.md

+11-26
Original file line numberDiff line numberDiff line change
@@ -1044,16 +1044,14 @@ changes:
10441044
Asynchronously append data to a file, creating the file if it does not yet
10451045
exist. `data` can be a string or a [`Buffer`][].
10461046

1047-
Example:
1048-
10491047
```js
10501048
fs.appendFile('message.txt', 'data to append', (err) => {
10511049
if (err) throw err;
10521050
console.log('The "data to append" was appended to file!');
10531051
});
10541052
```
10551053

1056-
If `options` is a string, then it specifies the encoding. Example:
1054+
If `options` is a string, then it specifies the encoding:
10571055

10581056
```js
10591057
fs.appendFile('message.txt', 'data to append', 'utf8', callback);
@@ -1097,8 +1095,6 @@ changes:
10971095
Synchronously append data to a file, creating the file if it does not yet
10981096
exist. `data` can be a string or a [`Buffer`][].
10991097

1100-
Example:
1101-
11021098
```js
11031099
try {
11041100
fs.appendFileSync('message.txt', 'data to append');
@@ -1108,7 +1104,7 @@ try {
11081104
}
11091105
```
11101106

1111-
If `options` is a string, then it specifies the encoding. Example:
1107+
If `options` is a string, then it specifies the encoding:
11121108

11131109
```js
11141110
fs.appendFileSync('message.txt', 'data to append', 'utf8');
@@ -1344,8 +1340,6 @@ fallback copy mechanism is used.
13441340
create a copy-on-write reflink. If the platform does not support copy-on-write,
13451341
then the operation will fail.
13461342

1347-
Example:
1348-
13491343
```js
13501344
const fs = require('fs');
13511345

@@ -1356,8 +1350,7 @@ fs.copyFile('source.txt', 'destination.txt', (err) => {
13561350
});
13571351
```
13581352

1359-
If the third argument is a number, then it specifies `flags`, as shown in the
1360-
following example.
1353+
If the third argument is a number, then it specifies `flags`:
13611354

13621355
```js
13631356
const fs = require('fs');
@@ -1395,8 +1388,6 @@ fallback copy mechanism is used.
13951388
create a copy-on-write reflink. If the platform does not support copy-on-write,
13961389
then the operation will fail.
13971390

1398-
Example:
1399-
14001391
```js
14011392
const fs = require('fs');
14021393

@@ -1405,8 +1396,7 @@ fs.copyFileSync('source.txt', 'destination.txt');
14051396
console.log('source.txt was copied to destination.txt');
14061397
```
14071398

1408-
If the third argument is a number, then it specifies `flags`, as shown in the
1409-
following example.
1399+
If the third argument is a number, then it specifies `flags`:
14101400

14111401
```js
14121402
const fs = require('fs');
@@ -1568,7 +1558,7 @@ deprecated: v1.0.0
15681558
* `exists` {boolean}
15691559

15701560
Test whether or not the given path exists by checking with the file system.
1571-
Then call the `callback` argument with either true or false. Example:
1561+
Then call the `callback` argument with either true or false:
15721562

15731563
```js
15741564
fs.exists('/etc/passwd', (exists) => {
@@ -1901,7 +1891,7 @@ fs.ftruncate(fd, 4, (err) => {
19011891
```
19021892

19031893
If the file previously was shorter than `len` bytes, it is extended, and the
1904-
extended part is filled with null bytes (`'\0'`). For example,
1894+
extended part is filled with null bytes (`'\0'`):
19051895

19061896
```js
19071897
console.log(fs.readFileSync('temp.txt', 'utf8'));
@@ -2505,7 +2495,7 @@ changes:
25052495
* `err` {Error}
25062496
* `data` {string|Buffer}
25072497

2508-
Asynchronously reads the entire contents of a file. Example:
2498+
Asynchronously reads the entire contents of a file.
25092499

25102500
```js
25112501
fs.readFile('/etc/passwd', (err, data) => {
@@ -2519,7 +2509,7 @@ contents of the file.
25192509

25202510
If no encoding is specified, then the raw buffer is returned.
25212511

2522-
If `options` is a string, then it specifies the encoding. Example:
2512+
If `options` is a string, then it specifies the encoding:
25232513

25242514
```js
25252515
fs.readFile('/etc/passwd', 'utf8', callback);
@@ -3519,8 +3509,6 @@ Asynchronously writes data to a file, replacing the file if it already exists.
35193509

35203510
The `encoding` option is ignored if `data` is a buffer.
35213511

3522-
Example:
3523-
35243512
```js
35253513
const data = new Uint8Array(Buffer.from('Hello Node.js'));
35263514
fs.writeFile('message.txt', data, (err) => {
@@ -3529,7 +3517,7 @@ fs.writeFile('message.txt', data, (err) => {
35293517
});
35303518
```
35313519

3532-
If `options` is a string, then it specifies the encoding. Example:
3520+
If `options` is a string, then it specifies the encoding:
35333521

35343522
```js
35353523
fs.writeFile('message.txt', 'Hello Node.js', 'utf8', callback);
@@ -3840,7 +3828,7 @@ doTruncate().catch(console.error);
38403828
```
38413829

38423830
If the file previously was shorter than `len` bytes, it is extended, and the
3843-
extended part is filled with null bytes (`'\0'`). For example,
3831+
extended part is filled with null bytes (`'\0'`):
38443832

38453833
```js
38463834
const fs = require('fs');
@@ -4050,8 +4038,6 @@ fallback copy mechanism is used.
40504038
create a copy-on-write reflink. If the platform does not support copy-on-write,
40514039
then the operation will fail.
40524040

4053-
Example:
4054-
40554041
```js
40564042
const fsPromises = require('fs').promises;
40574043

@@ -4061,8 +4047,7 @@ fsPromises.copyFile('source.txt', 'destination.txt')
40614047
.catch(() => console.log('The file could not be copied'));
40624048
```
40634049

4064-
If the third argument is a number, then it specifies `flags`, as shown in the
4065-
following example.
4050+
If the third argument is a number, then it specifies `flags`:
40664051

40674052
```js
40684053
const fs = require('fs');

0 commit comments

Comments
 (0)
Please sign in to comment.