Skip to content

Commit 0658632

Browse files
estliberitasMylesBorins
authored andcommitted
tools,doc: parse types in braces everywhere
Also add `EvalError`, `RangeError`, `ReferenceError`, `SyntaxError`, `TypeError`, `URIError` to list of global types. Fix errors.markdown copy accordingly. Fixes: #5325. PR-URL: #5329 Reviewed-By: James M Snell <[email protected]>
1 parent bb97de0 commit 0658632

File tree

3 files changed

+14
-24
lines changed

3 files changed

+14
-24
lines changed

doc/api/errors.markdown

+10-19
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Applications running in Node.js will generally experience four categories of
66
errors:
77

88
- Standard JavaScript errors such as:
9-
- [`EvalError`][]: thrown when a call to `eval()` fails.
10-
- [`SyntaxError`][]: thrown in response to improper JavaScript language
9+
- {EvalError} : thrown when a call to `eval()` fails.
10+
- {SyntaxError} : thrown in response to improper JavaScript language
1111
syntax.
12-
- [`RangeError`][]: thrown when a value is not within an expected range
13-
- [`ReferenceError`][]: thrown when using undefined variables
14-
- [`TypeError`][]: thrown when passing arguments of the wrong type
15-
- [`URIError`][]: thrown when a global URI handling function is misused.
12+
- {RangeError} : thrown when a value is not within an expected range
13+
- {ReferenceError} : thrown when using undefined variables
14+
- {TypeError} : thrown when passing arguments of the wrong type
15+
- {URIError} : thrown when a global URI handling function is misused.
1616
- System errors triggered by underlying operating system constraints such
1717
as attempting to open a file that does not exist, attempting to send data
1818
over a closed socket, etc;
@@ -22,7 +22,7 @@ errors:
2222
are raised typically by the `assert` module.
2323

2424
All JavaScript and System errors raised by Node.js inherit from, or are
25-
instances of, the standard JavaScript [`Error`][] class and are guaranteed
25+
instances of, the standard JavaScript {Error} class and are guaranteed
2626
to provide *at least* the properties available on that class.
2727

2828
## Error Propagation and Interception
@@ -36,7 +36,7 @@ called.
3636

3737
All JavaScript errors are handled as exceptions that *immediately* generate
3838
and throw an error using the standard JavaScript `throw` mechanism. These
39-
are handled using the [`try / catch` construct][] provided by the JavaScript
39+
are handled using the [`try / catch` construct][try-catch] provided by the JavaScript
4040
language.
4141

4242
```js
@@ -105,7 +105,7 @@ pass or fail).
105105

106106
For *all* `EventEmitter` objects, if an `'error'` event handler is not
107107
provided, the error will be thrown, causing the Node.js process to report an
108-
unhandled exception and crash unless either: The [`domain`][] module is used
108+
unhandled exception and crash unless either: The [`domain`][domains] module is used
109109
appropriately or a handler has been registered for the
110110
[`process.on('uncaughtException')`][] event.
111111

@@ -520,9 +520,6 @@ found [here][online].
520520
encountered by [`http`][] or [`net`][] -- often a sign that a `socket.end()`
521521
was not properly called.
522522

523-
[`domain`]: domain.html
524-
[`EvalError`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError
525-
[`Error`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
526523
[`fs.readdir`]: fs.html#fs_fs_readdir_path_callback
527524
[`fs.readFileSync`]: fs.html#fs_fs_readfilesync_file_options
528525
[`fs.unlink`]: fs.html#fs_fs_unlink_path_callback
@@ -531,18 +528,12 @@ found [here][online].
531528
[`https`]: https.html
532529
[`net`]: net.html
533530
[`process.on('uncaughtException')`]: process.html#process_event_uncaughtexception
534-
[`try / catch` construct]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch
535-
[`try { } catch(err) { }`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch
536531
[domains]: domain.html
537532
[event emitter-based]: events.html#events_class_events_eventemitter
538533
[file descriptors]: https://en.wikipedia.org/wiki/File_descriptor
539534
[online]: http://man7.org/linux/man-pages/man3/errno.3.html
540535
[stream-based]: stream.html
541536
[syscall]: http://man7.org/linux/man-pages/man2/syscall.2.html
537+
[try-catch]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch
542538
[V8's stack trace API]: https://github.com/v8/v8/wiki/Stack-Trace-API
543539
[vm]: vm.html
544-
[`SyntaxError`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError
545-
[`RangeError`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError
546-
[`ReferenceError`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError
547-
[`TypeError`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError
548-
[`URIError`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError

tools/doc/html.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ function parseText(lexed) {
112112
lexed.forEach(function(tok) {
113113
if (tok.text && tok.type !== 'code') {
114114
tok.text = linkManPages(tok.text);
115+
tok.text = linkJsTypeDocs(tok.text);
115116
}
116117
});
117118
}
@@ -166,9 +167,6 @@ function parseLists(input) {
166167
}
167168
return;
168169
}
169-
if (tok.text) {
170-
tok.text = parseListItem(tok.text);
171-
}
172170
}
173171
output.push(tok);
174172
});
@@ -197,7 +195,7 @@ function linkManPages(text) {
197195
});
198196
}
199197

200-
function parseListItem(text) {
198+
function linkJsTypeDocs(text) {
201199
var parts = text.split('`');
202200
var i;
203201
var typeMatches;

tools/doc/type-parser.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const jsGlobalTypes = [
1111
'Error', 'Object', 'Function', 'Array', 'Uint8Array',
1212
'Uint16Array', 'Uint32Array', 'Int8Array', 'Int16Array', 'Int32Array',
1313
'Uint8ClampedArray', 'Float32Array', 'Float64Array', 'Date', 'RegExp',
14-
'ArrayBuffer', 'DataView', 'Promise'
14+
'ArrayBuffer', 'DataView', 'Promise', 'EvalError', 'RangeError',
15+
'ReferenceError', 'SyntaxError', 'TypeError', 'URIError'
1516
];
1617
const typeMap = {
1718
'Buffer': 'buffer.html#buffer_class_buffer',

0 commit comments

Comments
 (0)