Skip to content

Commit 8532251

Browse files
Trottaddaleax
authored andcommitted
doc: remove extraneous "for example" text
No need to announce obvious example code as being example code. Remove unneeded "for example" text as one small way to try to keep the docs more concise.. PR-URL: #18890 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]>
1 parent 38cf3cf commit 8532251

22 files changed

+12
-127
lines changed

doc/api/addons.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ Each of these examples using the following `binding.gyp` file:
292292
```
293293

294294
In cases where there is more than one `.cc` file, simply add the additional
295-
filename to the `sources` array. For example:
295+
filename to the `sources` array:
296296

297297
```json
298298
"sources": ["addon.cc", "myexample.cc"]

doc/api/async_hooks.md

+1-7
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,6 @@ Note that `resolve()` does not do any observable synchronous work.
451451
rejected at this point, if the `Promise` was resolved by assuming the state
452452
of another `Promise`.
453453

454-
For example:
455-
456454
```js
457455
new Promise((resolve) => resolve(true)).then((a) => {});
458456
```
@@ -481,8 +479,6 @@ changes:
481479
* Returns: {number} The `asyncId` of the current execution context. Useful to
482480
track when something calls.
483481

484-
For example:
485-
486482
```js
487483
const async_hooks = require('async_hooks');
488484

@@ -493,7 +489,7 @@ fs.open(path, 'r', (err, fd) => {
493489
```
494490

495491
The ID returned from `executionAsyncId()` is related to execution timing, not
496-
causality (which is covered by `triggerAsyncId()`). For example:
492+
causality (which is covered by `triggerAsyncId()`):
497493

498494
```js
499495
const server = net.createServer(function onConnection(conn) {
@@ -517,8 +513,6 @@ See the section on [promise execution tracking][].
517513
* Returns: {number} The ID of the resource responsible for calling the callback
518514
that is currently being executed.
519515

520-
For example:
521-
522516
```js
523517
const server = net.createServer((conn) => {
524518
// The resource that caused (or triggered) this callback to be called

doc/api/buffer.md

-4
Original file line numberDiff line numberDiff line change
@@ -930,8 +930,6 @@ added: v8.2.0
930930
For objects whose `valueOf()` function returns a value not strictly equal to
931931
`object`, returns `Buffer.from(object.valueOf(), offsetOrEncoding, length)`.
932932

933-
For example:
934-
935933
```js
936934
const buf = Buffer.from(new String('this is a test'));
937935
// <Buffer 74 68 69 73 20 69 73 20 61 20 74 65 73 74>
@@ -940,8 +938,6 @@ const buf = Buffer.from(new String('this is a test'));
940938
For objects that support `Symbol.toPrimitive`, returns
941939
`Buffer.from(object[Symbol.toPrimitive](), offsetOrEncoding, length)`.
942940

943-
For example:
944-
945941
```js
946942
class Foo {
947943
[Symbol.toPrimitive]() {

doc/api/child_process.md

-2
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,6 @@ a Promise for an object with `stdout` and `stderr` properties. In case of an
226226
error, a rejected promise is returned, with the same `error` object given in the
227227
callback, but with an additional two properties `stdout` and `stderr`.
228228

229-
For example:
230-
231229
```js
232230
const util = require('util');
233231
const exec = util.promisify(require('child_process').exec);

doc/api/dns.md

-6
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ Returns an array of IP address strings, formatted according to [rfc5952][],
114114
that are currently configured for DNS resolution. A string will include a port
115115
section if a custom port is used.
116116

117-
For example:
118-
119117
<!-- eslint-disable semi-->
120118
```js
121119
[
@@ -369,8 +367,6 @@ function will contain an array of objects with the following properties:
369367
* `order`
370368
* `preference`
371369

372-
For example:
373-
374370
<!-- eslint-skip -->
375371
```js
376372
{
@@ -558,8 +554,6 @@ Sets the IP address and port of servers to be used when performing DNS
558554
resolution. The `servers` argument is an array of [rfc5952][] formatted
559555
addresses. If the port is the IANA default DNS port (53) it can be omitted.
560556

561-
For example:
562-
563557
```js
564558
dns.setServers([
565559
'4.4.4.4',

doc/api/domain.md

-2
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,6 @@ perhaps we would like to have a separate domain to use for each request.
239239

240240
That is possible via explicit binding.
241241

242-
For example:
243-
244242
```js
245243
// create a top-level domain for the server
246244
const domain = require('domain');

doc/api/errors.md

+2-9
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,6 @@ console.error(err.message);
292292
The `error.stack` property is a string describing the point in the code at which
293293
the `Error` was instantiated.
294294

295-
For example:
296-
297295
```txt
298296
Error: Things keep happening!
299297
at /home/gbusey/file.js:525:2
@@ -368,8 +366,6 @@ detailed [here](#errors_system_errors).
368366
A subclass of `Error` that indicates the failure of an assertion. Such errors
369367
commonly indicate inequality of actual and expected value.
370368

371-
For example:
372-
373369
```js
374370
assert.strictEqual(1, 2);
375371
// AssertionError [ERR_ASSERTION]: 1 === 2
@@ -381,8 +377,6 @@ A subclass of `Error` that indicates that a provided argument was not within the
381377
set or range of acceptable values for a function; whether that is a numeric
382378
range, or outside the set of options for a given function parameter.
383379

384-
For example:
385-
386380
```js
387381
require('net').connect(-1);
388382
// throws "RangeError: "port" option should be >= 0 and < 65536: -1"
@@ -1298,9 +1292,8 @@ compiled with ICU support.
12981292
<a id="ERR_NO_LONGER_SUPPORTED"></a>
12991293
### ERR_NO_LONGER_SUPPORTED
13001294

1301-
A Node.js API was called in an unsupported manner.
1302-
1303-
For example: `Buffer.write(string, encoding, offset[, length])`
1295+
A Node.js API was called in an unsupported manner, such as
1296+
`Buffer.write(string, encoding, offset[, length])`.
13041297

13051298
<a id="ERR_OUT_OF_RANGE"></a>
13061299
### ERR_OUT_OF_RANGE

doc/api/fs.md

-10
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ The arguments passed to the completion callback depend on the method, but the
2222
first argument is always reserved for an exception. If the operation was
2323
completed successfully, then the first argument will be `null` or `undefined`.
2424

25-
For example:
26-
2725
```js
2826
const fs = require('fs');
2927

@@ -36,8 +34,6 @@ fs.unlink('/tmp/hello', (err) => {
3634
Exceptions that occur using synchronous operations are thrown immediately and
3735
may be handled using `try`/`catch`, or may be allowed to bubble up.
3836

39-
For example:
40-
4137
```js
4238
const fs = require('fs');
4339

@@ -403,7 +399,6 @@ A `fs.Stats` object provides information about a file.
403399
Objects returned from [`fs.stat()`][], [`fs.lstat()`][] and [`fs.fstat()`][] and
404400
their synchronous counterparts are of this type.
405401

406-
For example:
407402
```console
408403
Stats {
409404
dev: 2114,
@@ -703,9 +698,6 @@ so introduces a race condition, since other processes may change the file's
703698
state between the two calls. Instead, user code should open/read/write the
704699
file directly and handle the error raised if the file is not accessible.
705700

706-
For example:
707-
708-
709701
**write (NOT RECOMMENDED)**
710702

711703
```js
@@ -1354,8 +1346,6 @@ so introduces a race condition, since other processes may change the file's
13541346
state between the two calls. Instead, user code should open/read/write the
13551347
file directly and handle the error raised if the file does not exist.
13561348

1357-
For example:
1358-
13591349
**write (NOT RECOMMENDED)**
13601350

13611351
```js

doc/api/http2.md

-4
Original file line numberDiff line numberDiff line change
@@ -1094,8 +1094,6 @@ received for this stream from the connected HTTP/2 server. The listener is
10941094
invoked with two arguments: an Object containing the received
10951095
[HTTP2 Headers Object][], and flags associated with the headers.
10961096

1097-
For example:
1098-
10991097
```js
11001098
const http2 = require('http2');
11011099
const client = http2.connect('https://localhost');
@@ -2008,8 +2006,6 @@ keys will be serialized to lower-case. Property values should be strings (if
20082006
they are not they will be coerced to strings) or an Array of strings (in order
20092007
to send more than one value per header field).
20102008

2011-
For example:
2012-
20132009
```js
20142010
const headers = {
20152011
':status': '200',

doc/api/modules.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ exports = { hello: false }; // Not exported, only available in the module
729729
```
730730

731731
When the `module.exports` property is being completely replaced by a new
732-
object, it is common to also reassign `exports`, for example:
732+
object, it is common to also reassign `exports`:
733733

734734
<!-- eslint-disable func-name-matching -->
735735
```js

doc/api/n-api.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ example is: [node-api](https://github.com/nodejs/node-api).
5959

6060
In order to use the N-API functions, include the file
6161
[node_api.h](https://github.com/nodejs/node/blob/master/src/node_api.h)
62-
which is located in the src directory in the node development tree.
63-
For example:
62+
which is located in the src directory in the node development tree:
63+
6464
```C
6565
#include <node_api.h>
6666
```

doc/api/os.md

-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ The properties included on each object include:
7070
* `idle` {number} The number of milliseconds the CPU has spent in idle mode.
7171
* `irq` {number} The number of milliseconds the CPU has spent in irq mode.
7272

73-
For example:
74-
7573
<!-- eslint-disable semi -->
7674
```js
7775
[

doc/api/path.md

-10
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ The `path.basename()` methods returns the last portion of a `path`, similar to
7979
the Unix `basename` command. Trailing directory separators are ignored, see
8080
[`path.sep`][].
8181

82-
For example:
83-
8482
```js
8583
path.basename('/foo/bar/baz/asdf/quux.html');
8684
// Returns: 'quux.html'
@@ -140,8 +138,6 @@ The `path.dirname()` method returns the directory name of a `path`, similar to
140138
the Unix `dirname` command. Trailing directory separators are ignored, see
141139
[`path.sep`][].
142140

143-
For example:
144-
145141
```js
146142
path.dirname('/foo/bar/baz/asdf/quux');
147143
// Returns: '/foo/bar/baz/asdf'
@@ -167,8 +163,6 @@ the `path`. If there is no `.` in the last portion of the `path`, or if the
167163
first character of the basename of `path` (see `path.basename()`) is `.`, then
168164
an empty string is returned.
169165

170-
For example:
171-
172166
```js
173167
path.extname('index.html');
174168
// Returns: '.html'
@@ -302,8 +296,6 @@ Zero-length `path` segments are ignored. If the joined path string is a
302296
zero-length string then `'.'` will be returned, representing the current
303297
working directory.
304298

305-
For example:
306-
307299
```js
308300
path.join('/foo', 'bar', 'baz/asdf', 'quux', '..');
309301
// Returns: '/foo/bar/baz/asdf'
@@ -497,8 +489,6 @@ Zero-length `path` segments are ignored.
497489
If no `path` segments are passed, `path.resolve()` will return the absolute path
498490
of the current working directory.
499491

500-
For example:
501-
502492
```js
503493
path.resolve('/foo/bar', './baz');
504494
// Returns: '/foo/bar/baz'

doc/api/process.md

-20
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ The listener callback function is invoked with the exit code specified either
5858
by the [`process.exitCode`][] property, or the `exitCode` argument passed to the
5959
[`process.exit()`] method, as the only argument.
6060

61-
For example:
62-
6361
```js
6462
process.on('exit', (code) => {
6563
console.log(`About to exit with code: ${code}`);
@@ -129,8 +127,6 @@ In asynchronous code, the `'unhandledRejection'` event is emitted when the list
129127
of unhandled rejections grows, and the `'rejectionHandled'` event is emitted
130128
when the list of unhandled rejections shrinks.
131129

132-
For example:
133-
134130
```js
135131
const unhandledRejections = new Map();
136132
process.on('unhandledRejection', (reason, p) => {
@@ -161,8 +157,6 @@ behavior.
161157
The listener function is called with the `Error` object passed as the only
162158
argument.
163159

164-
For example:
165-
166160
```js
167161
process.on('uncaughtException', (err) => {
168162
fs.writeSync(1, `Caught exception: ${err}\n`);
@@ -230,8 +224,6 @@ The listener function is called with the following arguments:
230224
(typically an [`Error`][] object).
231225
* `p` the `Promise` that was rejected.
232226

233-
For example:
234-
235227
```js
236228
process.on('unhandledRejection', (reason, p) => {
237229
console.log('Unhandled Rejection at:', p, 'reason:', reason);
@@ -355,8 +347,6 @@ The signal handler will receive the signal's name (`'SIGINT'`,
355347
The name of each event will be the uppercase common name for the signal (e.g.
356348
`'SIGINT'` for `SIGINT` signals).
357349

358-
For example:
359-
360350
```js
361351
// Begin reading from stdin so the process does not exit.
362352
process.stdin.resume();
@@ -925,8 +915,6 @@ include the Node.js executable, the name of the script, or any options following
925915
the script name. These options are useful in order to spawn child processes with
926916
the same execution environment as the parent.
927917

928-
For example:
929-
930918
```console
931919
$ node --harmony script.js --version
932920
```
@@ -955,8 +943,6 @@ added: v0.1.100
955943
The `process.execPath` property returns the absolute pathname of the executable
956944
that started the Node.js process.
957945

958-
For example:
959-
960946
<!-- eslint-disable semi -->
961947
```js
962948
'/usr/local/bin/node'
@@ -1229,8 +1215,6 @@ group.
12291215
really just a signal sender, like the `kill` system call. The signal sent may
12301216
do something other than kill the target process.
12311217

1232-
For example:
1233-
12341218
```js
12351219
process.on('SIGHUP', () => {
12361220
console.log('Got SIGHUP signal.');
@@ -1506,8 +1490,6 @@ tarball.
15061490
- `'Boron'` for the 6.x LTS line beginning with 6.9.0.
15071491
- `'Carbon'` for the 8.x LTS line beginning with 8.9.1.
15081492

1509-
For example:
1510-
15111493
<!-- eslint-skip -->
15121494
```js
15131495
{
@@ -1712,8 +1694,6 @@ The `process.stdin` property returns a stream connected to
17121694
stream) unless fd `0` refers to a file, in which case it is
17131695
a [Readable][] stream.
17141696

1715-
For example:
1716-
17171697
```js
17181698
process.stdin.setEncoding('utf8');
17191699

doc/api/querystring.md

-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ It serializes the following types of values passed in `obj`:
108108
{string|number|boolean|string[]|number[]|boolean[]}
109109
Any other input values will be coerced to empty strings.
110110

111-
For example:
112-
113111
```js
114112
querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' });
115113
// returns 'foo=bar&baz=qux&baz=quux&corge='

0 commit comments

Comments
 (0)