Skip to content

Commit

Permalink
doc: consistent reference-style links
Browse files Browse the repository at this point in the history
Moved all the URLs in API docs to the bottom of the files as
reference-style links.

PR-URL: #3845
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
bengl authored and Myles Borins committed Nov 17, 2015
1 parent 79220be commit ff992ff
Show file tree
Hide file tree
Showing 28 changed files with 371 additions and 309 deletions.
33 changes: 18 additions & 15 deletions doc/api/addons.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ knowledge of several libraries:
- V8 JavaScript, a C++ library. Used for interfacing with JavaScript:
creating objects, calling functions, etc. Documented mostly in the
`v8.h` header file (`deps/v8/include/v8.h` in the Node.js source
tree), which is also available
[online](https://v8docs.nodesource.com/).
tree), which is also available [online][].

- [libuv](https://github.com/libuv/libuv), C event loop library.
Anytime one needs to wait for a file descriptor to become readable,
wait for a timer, or wait for a signal to be received one will need
to interface with libuv. That is, if you perform any I/O, libuv will
need to be used.
- [libuv][], C event loop library. Anytime one needs to wait for a file
descriptor to become readable, wait for a timer, or wait for a signal
to be received one will need to interface with libuv. That is, if you
perform any I/O, libuv will need to be used.

- Internal Node.js libraries. Most importantly is the `node::ObjectWrap`
class which you will likely want to derive from.
Expand All @@ -25,9 +23,8 @@ Node.js statically compiles all its dependencies into the executable.
When compiling your module, you don't need to worry about linking to
any of these libraries.

All of the following examples are available for
[download](https://github.com/rvagg/node-addon-examples) and may be
used as a starting-point for your own Addon.
All of the following examples are available for [download][] and may
be used as a starting-point for your own Addon.

## Hello world

Expand Down Expand Up @@ -77,7 +74,7 @@ The `module_name` needs to match the filename of the final binary (minus the
The source code needs to be built into `addon.node`, the binary Addon. To
do this we create a file called `binding.gyp` which describes the configuration
to build your module in a JSON-like format. This file gets compiled by
[node-gyp](https://github.com/nodejs/node-gyp).
[node-gyp][].

{
"targets": [
Expand Down Expand Up @@ -113,10 +110,9 @@ Please see patterns below for further information or
## Addon patterns

Below are some addon patterns to help you get started. Consult the online
[v8 reference](http://izs.me/v8-docs/main.html) for help with the various v8
calls, and v8's [Embedder's Guide](http://code.google.com/apis/v8/embed.html)
for an explanation of several concepts used such as handles, scopes,
function templates, etc.
[v8 reference][] for help with the various v8 calls, and v8's
[Embedder's Guide][] for an explanation of several concepts used such as
handles, scopes, function templates, etc.

In order to use these examples you need to compile them using `node-gyp`.
Create the following `binding.gyp` file:
Expand Down Expand Up @@ -869,3 +865,10 @@ Test in JavaScript by running:

// test.js
var addon = require('./build/Release/addon');

[online]: https://v8docs.nodesource.com/
[libuv]: https://github.com/libuv/libuv
[download]: https://github.com/rvagg/node-addon-examples
[node-gyp]: https://github.com/nodejs/node-gyp
[v8 reference]: http://izs.me/v8-docs/main.html
[Embedder's Guide]: http://code.google.com/apis/v8/embed.html
4 changes: 3 additions & 1 deletion doc/api/assert.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ operator ( `===` ).

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

Expects `block` not to throw an error. See [assert.throws()](#assert_assert_throws_block_error_message) for more details.
Expects `block` not to throw an error. See [assert.throws()][] for more details.

If `block` throws an error and if it is of a different type from `error`, the
thrown error will get propagated back to the caller. The following call will
Expand Down Expand Up @@ -128,3 +128,5 @@ Custom error validation:
},
"unexpected error"
);

[assert.throws()]: #assert_assert_throws_block_error_message
15 changes: 8 additions & 7 deletions doc/api/buffer.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ Example:
* `buf1` {Buffer}
* `buf2` {Buffer}

The same as [`buf1.compare(buf2)`](#buffer_buf_compare_otherbuffer). Useful
for sorting an Array of Buffers:
The same as [`buf1.compare(buf2)`][]. Useful for sorting an Array of Buffers:

var arr = [Buffer('1234'), Buffer('0123')];
arr.sort(Buffer.compare);
Expand Down Expand Up @@ -287,11 +286,10 @@ buffer.
* `byteOffset` Number, Optional, Default: 0
* Return: Number

Operates similar to
[Array#indexOf()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf).
Accepts a String, Buffer or Number. Strings are interpreted as UTF8. Buffers
will use the entire buffer. So in order to compare a partial Buffer use
`Buffer#slice()`. Numbers can range from 0 to 255.
Operates similar to [Array#indexOf()][]. Accepts a String, Buffer or Number.
Strings are interpreted as UTF8. Buffers will use the entire buffer. So in order
to compare a partial Buffer use `Buffer#slice()`. Numbers can range from 0 to
255.

### buf.length

Expand Down Expand Up @@ -932,3 +930,6 @@ un-pooled Buffer instance using SlowBuffer and copy out the relevant bits.

Though this should be used sparingly and only be a last resort *after* a developer
has actively observed undue memory retention in their applications.

[`buf1.compare(buf2)`]: #buffer_buf_compare_otherbuffer
[Array#indexOf()]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
51 changes: 29 additions & 22 deletions doc/api/child_process.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ data you send to the child process may not be immediately consumed.)

To create a child process use `require('child_process').spawn()` or
`require('child_process').fork()`. The semantics of each are slightly
different, and explained [below](#child_process_asynchronous_process_creation).
different, and explained [below][].

For scripting purposes you may find the
[synchronous counterparts](#child_process_synchronous_process_creation) more
For scripting purposes you may find the [synchronous counterparts][] more
convenient.

## Class: ChildProcess
Expand Down Expand Up @@ -61,8 +60,7 @@ Note that the `exit`-event may or may not fire after an error has occurred. If
you are listening on both events to fire a function, remember to guard against
calling your function twice.

See also [`ChildProcess#kill()`](#child_process_child_kill_signal) and
[`ChildProcess#send()`](#child_process_child_send_message_sendhandle_callback).
See also [`ChildProcess#kill()`][] and [`ChildProcess#send()`][].

### Event: 'exit'

Expand Down Expand Up @@ -161,7 +159,7 @@ Example:
* `callback` {Function}
* Return: Boolean

When using [`child_process.fork()`](#child_process_child_process_fork_modulepath_args_options) you can write to the child using
When using [`child_process.fork()`][] you can write to the child using
`child.send(message[, sendHandle][, callback])` and messages are received by
a `'message'` event on the child.

Expand Down Expand Up @@ -309,9 +307,7 @@ to the same object, or null.
* {Array}

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

Expand Down Expand Up @@ -438,9 +434,9 @@ the existing process and uses a shell to execute the command.*
* `stderr` {Buffer}
* Return: ChildProcess object

This is similar to [`child_process.exec()`](#child_process_child_process_exec_command_options_callback) except it does not execute a
This is similar to [`child_process.exec()`][] except it does not execute a
subshell but rather the specified file directly. This makes it slightly
leaner than [`child_process.exec()`](#child_process_child_process_exec_command_options_callback). It has the same options.
leaner than [`child_process.exec()`][]. It has the same options.


### child_process.fork(modulePath[, args][, options])
Expand All @@ -461,10 +457,10 @@ leaner than [`child_process.exec()`](#child_process_child_process_exec_command_o
* `gid` {Number} Sets the group identity of the process. (See setgid(2).)
* Return: ChildProcess object

This is a special case of the [`child_process.spawn()`](#child_process_child_process_spawn_command_args_options) functionality for spawning Node.js
processes. In addition to having all the methods in a normal ChildProcess
instance, the returned object has a communication channel built-in. See
[`child.send(message, [sendHandle])`](#child_process_child_send_message_sendhandle_callback) for details.
This is a special case of the [`child_process.spawn()`][] functionality for
spawning Node.js processes. In addition to having all the methods in a normal
ChildProcess instance, the returned object has a communication channel built-in.
See [`child.send(message, [sendHandle])`][] for details.

These child Node.js processes are still whole new instances of V8. Assume at
least 30ms startup and 10mb memory for each new Node.js. That is, you cannot
Expand Down Expand Up @@ -662,7 +658,7 @@ Example:
// startd-style interface.
spawn('prg', [], { stdio: ['pipe', null, null, null, 'pipe'] });

See also: [`child_process.exec()`](#child_process_child_process_exec_command_options_callback) and [`child_process.fork()`](#child_process_child_process_fork_modulepath_args_options)
See also: [`child_process.exec()`][] and [`child_process.fork()`][]

## Synchronous Process Creation

Expand Down Expand Up @@ -702,11 +698,7 @@ process has exited.

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

[EventEmitter]: events.html#events_class_events_eventemitter
[net.Server]: net.html#net_class_net_server
[net.Socket]: net.html#net_class_net_socket
[`child_process.spawnSync()`][]

### child_process.execSync(command[, options])

Expand Down Expand Up @@ -740,7 +732,7 @@ process has exited.

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

### child_process.spawnSync(command[, args][, options])

Expand Down Expand Up @@ -773,3 +765,18 @@ timeout has been encountered and `killSignal` is sent, the method won't return
until the process has completely exited. That is to say, if the process handles
the `SIGTERM` signal and doesn't exit, your process will wait until the child
process has exited.

[below]: #child_process_asynchronous_process_creation
[synchronous counterparts]: #child_process_synchronous_process_creation
[EventEmitter]: events.html#events_class_events_eventemitter
[`ChildProcess#kill()`]: #child_process_child_kill_signal
[`ChildProcess#send()`]: #child_process_child_send_message_sendhandle_callback
[net.Server]: net.html#net_class_net_server
[net.Socket]: net.html#net_class_net_socket
[`child_process.fork()`]: #child_process_child_process_fork_modulepath_args_options
[stdio]: #child_process_options_stdio
[spawn]: #child_process_child_process_spawn_command_args_options
[`child_process.exec()`]: #child_process_child_process_exec_command_options_callback
[`child_process.spawn()`]: #child_process_child_process_spawn_command_args_options
[`child.send(message, [sendHandle])`]: #child_process_child_send_message_sendhandle_callback
[`child_process.spawnSync()`]: #child_process_child_process_spawnsync_command_args_options
26 changes: 15 additions & 11 deletions doc/api/cluster.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ This event is the same as the one provided by `child_process.fork()`.

In a worker you can also use `process.on('error')`.

[ChildProcess.send()]: child_process.html#child_process_child_send_message_sendhandle_callback

### Event: 'exit'

* `code` {Number} the exit code, if it exited normally.
Expand Down Expand Up @@ -232,15 +230,15 @@ Causes `.suicide` to be set.
Note that after a server is closed, it will no longer accept new connections,
but connections may be accepted by any other listening worker. Existing
connections will be allowed to close as usual. When no more connections exist,
see [server.close()](net.html#net_event_close), the IPC channel to the worker
will close allowing it to die gracefully.
see [server.close()][], the IPC channel to the worker will close allowing it to
die gracefully.

The above applies *only* to server connections, client connections are not
automatically closed by workers, and disconnect does not wait for them to close
before exiting.

Note that in a worker, `process.disconnect` exists, but it is not this function,
it is [disconnect](child_process.html#child_process_child_disconnect).
it is [disconnect][].

Because long living server connections may block workers from disconnecting, it
may be useful to send a message, so application specific actions may be taken to
Expand Down Expand Up @@ -313,7 +311,7 @@ Causes `.suicide` to be set.
This method is aliased as `worker.destroy()` for backwards compatibility.

Note that in a worker, `process.kill()` exists, but it is not this function,
it is [kill](process.html#process_process_kill_pid_signal).
it is [kill][].

### worker.process

Expand All @@ -323,8 +321,7 @@ All workers are created using `child_process.fork()`, the returned object
from this function is stored as `.process`. In a worker, the global `process`
is stored.

See: [Child Process module](
child_process.html#child_process_child_process_fork_modulepath_args_options)
See: [Child Process module][]

Note that workers will call `process.exit(0)` if the `'disconnect'` event occurs
on `process` and `.suicide` is not `true`. This protects against accidental
Expand Down Expand Up @@ -408,7 +405,7 @@ This can be used to restart the worker by calling `.fork()` again.
cluster.fork();
});

See [child_process event: 'exit'](child_process.html#child_process_event_exit).
See [child_process event: 'exit'][].

## Event: 'fork'

Expand Down Expand Up @@ -464,8 +461,7 @@ The `addressType` is one of:

Emitted when any worker receives a message.

See
[child_process event: 'message'](child_process.html#child_process_event_message).
See [child_process event: 'message'][].

## Event: 'online'

Expand Down Expand Up @@ -647,3 +643,11 @@ the worker's unique id is the easiest way to find the worker.
socket.on('data', function(id) {
var worker = cluster.workers[id];
});

[server.close()]: net.html#net_event_close
[disconnect]: child_process.html#child_process_child_disconnect
[kill]: process.html#process_process_kill_pid_signal
[Child Process module]: child_process.html#child_process_child_process_fork_modulepath_args_options
[ChildProcess.send()]: child_process.html#child_process_child_send_message_sendhandle_callback
[child_process event: 'exit']: child_process.html#child_process_event_exit
[child_process event: 'message']: child_process.html#child_process_event_message.
14 changes: 8 additions & 6 deletions doc/api/console.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ The global `console` is a special `Console` whose output is sent to

new Console(process.stdout, process.stderr);

[assert.ok()]: assert.html#assert_assert_value_message_assert_ok_value_message
[util.format()]: util.html#util_util_format_format
[customizing util.inspect colors]: util.html#util_customizing_util_inspect_colors

## console

* {Object}
Expand Down Expand Up @@ -114,13 +110,13 @@ is used on each argument. See [util.format()][] for more information.
Used to calculate the duration of a specific operation. To start a timer, call
the `console.time()` method, giving it a name as only parameter. To stop the
timer, and to get the elapsed time in milliseconds, just call the
[`console.timeEnd()`](#console_console_timeend_label) method, again passing the
[`console.timeEnd()`][] method, again passing the
timer's name as the parameter.

### console.timeEnd(label)

Stops a timer that was previously started by calling
[`console.time()`](#console_console_time_label) and print the result to the
[`console.time()`][] and prints the result to the
console.

Example:
Expand All @@ -140,3 +136,9 @@ to the current position.
### console.warn([data][, ...])

Same as `console.error`.

[assert.ok()]: assert.html#assert_assert_value_message_assert_ok_value_message
[customizing util.inspect colors]: util.html#util_customizing_util_inspect_colors
[util.format()]: util.html#util_util_format_format
[`console.timeEnd()`]: #console_console_timeend_label
[`console.time()`]: #console_console_time_label
Loading

0 comments on commit ff992ff

Please sign in to comment.