Skip to content

Commit 3169eed

Browse files
jperssonrvagg
jpersson
authored andcommitted
doc: add links and backticks around names
* add backticks around names * add single quotes around event names * add parenthesis after function names * add internal links between different sections * add external links to MDN for some JavaScript references * sort the link definitions alphabetically PR-URL: #4054 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Roman Reiss <[email protected]>
1 parent 4b43bf0 commit 3169eed

27 files changed

+712
-625
lines changed

doc/api/assert.markdown

+13-8
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ comparison operator ( `==` ).
1919
This only considers enumerable properties. It does not test object prototypes,
2020
attached symbols, or non-enumerable properties. This can lead to some
2121
potentially surprising results. For example, this does not throw an
22-
`AssertionError` because the properties on the `Error` object are
22+
`AssertionError` because the properties on the [`Error`][] object are
2323
non-enumerable:
2424

2525
// WARNING: This does not throw an AssertionError!
@@ -32,11 +32,11 @@ operator ( `===` ).
3232

3333
## assert.doesNotThrow(block[, error][, message])
3434

35-
Expects `block` not to throw an error. See [assert.throws()][] for more details.
35+
Expects `block` not to throw an error. See [`assert.throws()`][] for more details.
3636

3737
If `block` throws an error and if it is of a different type from `error`, the
3838
thrown error will get propagated back to the caller. The following call will
39-
throw the `TypeError`, since we're not matching the error types in the
39+
throw the [`TypeError`][], since we're not matching the error types in the
4040
assertion.
4141

4242
assert.doesNotThrow(
@@ -72,11 +72,11 @@ argument in callbacks.
7272

7373
## assert.notDeepEqual(actual, expected[, message])
7474

75-
Tests for any deep inequality. Opposite of `assert.deepEqual`.
75+
Tests for any deep inequality. Opposite of [`assert.deepEqual`][].
7676

7777
## assert.notDeepStrictEqual(actual, expected[, message])
7878

79-
Tests for deep inequality. Opposite of `assert.deepStrictEqual`.
79+
Tests for deep inequality. Opposite of [`assert.deepStrictEqual`][].
8080

8181
## assert.notEqual(actual, expected[, message])
8282

@@ -94,7 +94,7 @@ Tests strict equality as determined by the strict equality operator ( `===` ).
9494

9595
## assert.throws(block[, error][, message])
9696

97-
Expects `block` to throw an error. `error` can be a constructor, `RegExp`, or
97+
Expects `block` to throw an error. `error` can be a constructor, [`RegExp`][], or
9898
validation function.
9999

100100
Validate instanceof using constructor:
@@ -106,7 +106,7 @@ Validate instanceof using constructor:
106106
Error
107107
);
108108

109-
Validate error message using RegExp:
109+
Validate error message using [`RegExp`][]:
110110

111111
assert.throws(
112112
function() {
@@ -129,4 +129,9 @@ Custom error validation:
129129
"unexpected error"
130130
);
131131

132-
[assert.throws()]: #assert_assert_throws_block_error_message
132+
[`assert.deepEqual`]: #assert_assert_deepequal_actual_expected_message
133+
[`assert.deepStrictEqual`]: #assert_assert_deepstrictequal_actual_expected_message
134+
[`assert.throws()`]: #assert_assert_throws_block_error_message
135+
[`Error`]: errors.html#errors_class_error
136+
[`RegExp`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
137+
[`TypeError`]: errors.html#errors_class_typeerror

doc/api/buffer.markdown

+15-10
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ instead of cloning it.
5050

5151
While more efficient, it introduces subtle incompatibilities with the typed
5252
arrays specification. `ArrayBuffer#slice()` makes a copy of the slice while
53-
`Buffer#slice()` creates a view.
53+
[`Buffer#slice()`][] creates a view.
5454

5555
## Class: Buffer
5656

@@ -76,11 +76,11 @@ Copies the passed `buffer` data onto a new `Buffer` instance.
7676
Allocates a new buffer of `size` bytes. `size` must be less than
7777
1,073,741,824 bytes (1 GB) on 32 bits architectures or
7878
2,147,483,648 bytes (2 GB) on 64 bits architectures,
79-
otherwise a `RangeError` is thrown.
79+
otherwise a [`RangeError`][] is thrown.
8080

8181
Unlike `ArrayBuffers`, the underlying memory for buffers is not initialized. So
8282
the contents of a newly created `Buffer` are unknown and could contain
83-
sensitive data. Use `buf.fill(0)` to initialize a buffer to zeroes.
83+
sensitive data. Use [`buf.fill(0)`][] to initialize a buffer to zeroes.
8484

8585
### new Buffer(str[, encoding])
8686

@@ -97,7 +97,7 @@ Allocates a new buffer containing the given `str`.
9797
* Return: Number
9898

9999
Gives the actual byte length of a string. `encoding` defaults to `'utf8'`.
100-
This is not the same as `String.prototype.length` since that returns the
100+
This is not the same as [`String.prototype.length`][] since that returns the
101101
number of *characters* in a string.
102102

103103
Example:
@@ -286,9 +286,9 @@ buffer.
286286
* `byteOffset` Number, Optional, Default: 0
287287
* Return: Number
288288

289-
Operates similar to [Array#indexOf()][]. Accepts a String, Buffer or Number.
289+
Operates similar to [`Array#indexOf()`][]. Accepts a String, Buffer or Number.
290290
Strings are interpreted as UTF8. Buffers will use the entire buffer. So in order
291-
to compare a partial Buffer use `Buffer#slice()`. Numbers can range from 0 to
291+
to compare a partial Buffer use [`Buffer#slice()`][]. Numbers can range from 0 to
292292
255.
293293

294294
### buf.length
@@ -311,7 +311,7 @@ buffer object. It does not change when the contents of the buffer are changed.
311311
While the `length` property is not immutable, changing the value of `length`
312312
can result in undefined and inconsistent behavior. Applications that wish to
313313
modify the length of a buffer should therefore treat `length` as read-only and
314-
use `buf.slice` to create a new buffer.
314+
use [`buf.slice`][] to create a new buffer.
315315

316316
buf = new Buffer(10);
317317
buf.write("abcdefghj", 0, "ascii");
@@ -882,7 +882,7 @@ to `false`.
882882
* Number, Default: 50
883883

884884
How many bytes will be returned when `buffer.inspect()` is called. This can
885-
be overridden by user modules. See [util.inspect()][] for more details on
885+
be overridden by user modules. See [`util.inspect()`][] for more details on
886886
`buffer.inspect()` behavior.
887887

888888
Note that this is a property on the buffer module returned by
@@ -932,6 +932,11 @@ un-pooled Buffer instance using SlowBuffer and copy out the relevant bits.
932932
Though this should be used sparingly and only be a last resort *after* a developer
933933
has actively observed undue memory retention in their applications.
934934

935+
[`Array#indexOf()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
936+
[`buf.fill(0)`]: #buffer_buf_fill_value_offset_end
937+
[`buf.slice`]: #buffer_buf_slice_start_end
935938
[`buf1.compare(buf2)`]: #buffer_buf_compare_otherbuffer
936-
[Array#indexOf()]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
937-
[util.inspect()]: util.html#util_util_inspect_object_options
939+
[`Buffer#slice()`]: #buffer_buf_slice_start_end
940+
[`RangeError`]: errors.html#errors_class_rangeerror
941+
[`String.prototype.length`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length
942+
[`util.inspect()`]: util.html#util_util_inspect_object_options

doc/api/child_process.markdown

+36-32
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ convenient.
1919

2020
## Class: ChildProcess
2121

22-
`ChildProcess` is an [EventEmitter][].
22+
`ChildProcess` is an [`EventEmitter`][].
2323

2424
Child processes always have three streams associated with them. `child.stdin`,
2525
`child.stdout`, and `child.stderr`. These may be shared with the stdio
2626
streams of the parent process, or they may be separate stream objects
2727
which can be piped to and from.
2828

2929
The ChildProcess class is not intended to be used directly. Use the
30-
`spawn()`, `exec()`, `execFile()`, or `fork()` methods to create a Child
30+
[`spawn()`][], [`exec()`][], [`execFile()`][], or [`fork()`][] methods to create a Child
3131
Process instance.
3232

3333
### Event: 'close'
@@ -37,7 +37,7 @@ Process instance.
3737
was killed by the parent.
3838

3939
This event is emitted when the stdio streams of a child process have all
40-
terminated. This is distinct from 'exit', since multiple processes
40+
terminated. This is distinct from `'exit'`, since multiple processes
4141
might share the same stdio streams.
4242

4343
### Event: 'disconnect'
@@ -56,7 +56,7 @@ Emitted when:
5656
2. The process could not be killed, or
5757
3. Sending a message to the child process failed for whatever reason.
5858

59-
Note that the `exit`-event may or may not fire after an error has occurred. If
59+
Note that the `'exit'` event may or may not fire after an error has occurred. If
6060
you are listening on both events to fire a function, remember to guard against
6161
calling your function twice.
6262

@@ -75,20 +75,20 @@ of the signal, otherwise `null`.
7575

7676
Note that the child process stdio streams might still be open.
7777

78-
Also, note that Node.js establishes signal handlers for `'SIGINT'` and
79-
`'SIGTERM`', so it will not terminate due to receipt of those signals,
78+
Also, note that Node.js establishes signal handlers for `SIGINT` and
79+
`SIGTERM`, so it will not terminate due to receipt of those signals,
8080
it will exit.
8181

8282
See `waitpid(2)`.
8383

8484
### Event: 'message'
8585

8686
* `message` {Object} a parsed JSON object or primitive value.
87-
* `sendHandle` {Handle object} a [net.Socket][] or [net.Server][] object, or
87+
* `sendHandle` {Handle object} a [`net.Socket`][] or [`net.Server`][] object, or
8888
undefined.
8989

9090
Messages sent by `.send(message, [sendHandle])` are obtained using the
91-
`message` event.
91+
`'message'` event.
9292

9393
### child.connected
9494

@@ -103,11 +103,11 @@ gracefully once there are no other connections keeping it alive. After calling
103103
this method the `.connected` flag will be set to `false` in both the parent and
104104
child, and it is no longer possible to send messages.
105105

106-
The 'disconnect' event will be emitted when there are no messages in the process
106+
The `'disconnect'` event will be emitted when there are no messages in the process
107107
of being received, most likely immediately.
108108

109109
Note that you can also call `process.disconnect()` in the child process when the
110-
child process has any open IPC channels with the parent (i.e `fork()`).
110+
child process has any open IPC channels with the parent (i.e [`fork()`][]).
111111

112112
### child.kill([signal])
113113

@@ -188,17 +188,17 @@ will emit objects each time it receives a message on its channel.
188188

189189
There is a special case when sending a `{cmd: 'NODE_foo'}` message. All messages
190190
containing a `NODE_` prefix in its `cmd` property will not be emitted in
191-
the `message` event, since they are internal messages used by Node.js core.
192-
Messages containing the prefix are emitted in the `internalMessage` event.
191+
the `'message'` event, since they are internal messages used by Node.js core.
192+
Messages containing the prefix are emitted in the `'internalMessage'` event.
193193
Avoid using this feature; it is subject to change without notice.
194194

195195
The `sendHandle` option to `child.send()` is for sending a TCP server or
196196
socket object to another process. The child will receive the object as its
197-
second argument to the `message` event.
197+
second argument to the `'message'` event.
198198

199199
The `callback` option is a function that is invoked after the message is
200200
sent but before the target may have received it. It is called with a single
201-
argument: `null` on success, or an `Error` object on failure.
201+
argument: `null` on success, or an [`Error`][] object on failure.
202202

203203
`child.send()` emits an `'error'` event if no callback was given and the message
204204
cannot be sent, for example because the child process has already exited.
@@ -237,7 +237,7 @@ Note that the server is now shared between the parent and child, this means
237237
that some connections will be handled by the parent and some by the child.
238238

239239
For `dgram` servers the workflow is exactly the same. Here you listen on
240-
a `message` event instead of `connection` and use `server.bind` instead of
240+
a `'message'` event instead of `'connection'` and use `server.bind` instead of
241241
`server.listen`. (Currently only supported on UNIX platforms.)
242242

243243
#### Example: sending socket object
@@ -308,7 +308,7 @@ to the same object, or null.
308308
* {Array}
309309

310310
A sparse array of pipes to the child process, corresponding with positions in
311-
the [stdio][] option to [spawn][] that have been set to `'pipe'`.
311+
the [`stdio`][] option to [`spawn()`][] that have been set to `'pipe'`.
312312
Note that streams 0-2 are also available as ChildProcess.stdin,
313313
ChildProcess.stdout, and ChildProcess.stderr, respectively.
314314

@@ -392,7 +392,7 @@ Runs a command in a shell and buffers the output.
392392
});
393393

394394
The callback gets the arguments `(error, stdout, stderr)`. On success, `error`
395-
will be `null`. On error, `error` will be an instance of `Error` and `error.code`
395+
will be `null`. On error, `error` will be an instance of [`Error`][] and `error.code`
396396
will be the exit code of the child process, and `error.signal` will be set to the
397397
signal that terminated the process.
398398

@@ -452,7 +452,7 @@ leaner than [`child_process.exec()`][]. It has the same options.
452452
(Default: `process.execArgv`)
453453
* `silent` {Boolean} If true, stdin, stdout, and stderr of the child will be
454454
piped to the parent, otherwise they will be inherited from the parent, see
455-
the "pipe" and "inherit" options for `spawn()`'s `stdio` for more details
455+
the `'pipe'` and `'inherit'` options for [`spawn()`][]'s [`stdio`][] for more details
456456
(default is false)
457457
* `uid` {Number} Sets the user identity of the process. (See setuid(2).)
458458
* `gid` {Number} Sets the group identity of the process. (See setgid(2).)
@@ -473,7 +473,7 @@ done with care and by default will talk over the fd represented an
473473
environmental variable `NODE_CHANNEL_FD` on the child process. The input and
474474
output on this fd is expected to be line delimited JSON objects.
475475

476-
*Note: Unlike the `fork()` POSIX system call, `child_process.fork()` does not clone the
476+
*Note: Unlike the `fork()` POSIX system call, [`child_process.fork()`][] does not clone the
477477
current process.*
478478

479479
### child_process.spawn(command[, args][, options])
@@ -614,7 +614,7 @@ As a shorthand, the `stdio` argument may be one of the following strings:
614614
* `'ignore'` - `['ignore', 'ignore', 'ignore']`
615615
* `'inherit'` - `[process.stdin, process.stdout, process.stderr]` or `[0,1,2]`
616616

617-
Otherwise, the 'stdio' option to `child_process.spawn()` is an array where each
617+
Otherwise, the `'stdio'` option to [`child_process.spawn()`][] is an array where each
618618
index corresponds to a fd in the child. The value is one of the following:
619619

620620
1. `'pipe'` - Create a pipe between the child process and the parent process.
@@ -698,7 +698,7 @@ the `SIGTERM` signal and doesn't exit, your process will wait until the child
698698
process has exited.
699699

700700
If the process times out, or has a non-zero exit code, this method ***will***
701-
throw. The `Error` object will contain the entire result from
701+
throw. The [`Error`][] object will contain the entire result from
702702
[`child_process.spawnSync()`][]
703703

704704
### child_process.execSync(command[, options])
@@ -732,7 +732,7 @@ the `SIGTERM` signal and doesn't exit, your process will wait until the child
732732
process has exited.
733733

734734
If the process times out, or has a non-zero exit code, this method ***will***
735-
throw. The `Error` object will contain the entire result from
735+
throw. The [`Error`][] object will contain the entire result from
736736
[`child_process.spawnSync()`][]
737737

738738
### child_process.spawnSync(command[, args][, options])
@@ -767,16 +767,20 @@ until the process has completely exited. That is to say, if the process handles
767767
the `SIGTERM` signal and doesn't exit, your process will wait until the child
768768
process has exited.
769769

770-
[below]: #child_process_asynchronous_process_creation
771-
[synchronous counterparts]: #child_process_synchronous_process_creation
772-
[EventEmitter]: events.html#events_class_events_eventemitter
773-
[`ChildProcess#kill()`]: #child_process_child_kill_signal
774-
[`ChildProcess#send()`]: #child_process_child_send_message_sendhandle_callback
775-
[net.Server]: net.html#net_class_net_server
776-
[net.Socket]: net.html#net_class_net_socket
777-
[`child_process.fork()`]: #child_process_child_process_fork_modulepath_args_options
778-
[stdio]: #child_process_options_stdio
779-
[spawn]: #child_process_child_process_spawn_command_args_options
780770
[`child_process.exec()`]: #child_process_child_process_exec_command_options_callback
771+
[`child_process.fork()`]: #child_process_child_process_fork_modulepath_args_options
781772
[`child_process.spawn()`]: #child_process_child_process_spawn_command_args_options
782773
[`child_process.spawnSync()`]: #child_process_child_process_spawnsync_command_args_options
774+
[`ChildProcess#kill()`]: #child_process_child_kill_signal
775+
[`ChildProcess#send()`]: #child_process_child_send_message_sendhandle_callback
776+
[`Error`]: errors.html#errors_class_error
777+
[`EventEmitter`]: events.html#events_class_events_eventemitter
778+
[`exec()`]: #child_process_child_process_exec_command_options_callback
779+
[`execFile()`]: #child_process_child_process_execfile_file_args_options_callback
780+
[`fork()`]: #child_process_child_process_fork_modulepath_args_options
781+
[`net.Server`]: net.html#net_class_net_server
782+
[`net.Socket`]: net.html#net_class_net_socket
783+
[`spawn()`]: #child_process_child_process_spawn_command_args_options
784+
[`stdio`]: #child_process_options_stdio
785+
[below]: #child_process_asynchronous_process_creation
786+
[synchronous counterparts]: #child_process_synchronous_process_creation

0 commit comments

Comments
 (0)