From 44448025489b324676c2835ffdb9087b4a62bf3e Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Tue, 30 Jan 2018 00:15:53 +0200 Subject: [PATCH] doc: linkify missing types Also, alphabetize all types in type-parser.js and fix some nits in type formats. Backport-PR-URL: https://github.com/nodejs/node/pull/19500 PR-URL: https://github.com/nodejs/node/pull/18444 Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- doc/api/cluster.md | 2 +- doc/api/readline.md | 14 +++++------ doc/api/repl.md | 4 +-- doc/api/stream.md | 8 +++--- tools/doc/type-parser.js | 53 ++++++++++++++++++++++++++++++---------- 5 files changed, 54 insertions(+), 27 deletions(-) diff --git a/doc/api/cluster.md b/doc/api/cluster.md index 648c753931d936..0bc768030728ab 100644 --- a/doc/api/cluster.md +++ b/doc/api/cluster.md @@ -265,7 +265,7 @@ It is not emitted in the worker. added: v0.7.7 --> -* Returns: {Worker} A reference to `worker`. +* Returns: {cluster.Worker} A reference to `worker`. In a worker, this function will close all servers, wait for the `'close'` event on those servers, and then disconnect the IPC channel. diff --git a/doc/api/readline.md b/doc/api/readline.md index b88c37e5bdbfa3..04c838a0024ed4 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -323,7 +323,7 @@ Interface's `input` *as if it were provided by the user*. added: v0.7.7 --> -* `stream` {Writable} +* `stream` {stream.Writable} * `dir` {number} * `-1` - to the left from cursor * `1` - to the right from cursor @@ -338,7 +338,7 @@ in a specified direction identified by `dir`. added: v0.7.7 --> -* `stream` {Writable} +* `stream` {stream.Writable} The `readline.clearScreenDown()` method clears the given [TTY][] stream from the current position of the cursor down. @@ -349,9 +349,9 @@ added: v0.1.98 --> * `options` {Object} - * `input` {Readable} The [Readable][] stream to listen to. This option is + * `input` {stream.Readable} The [Readable][] stream to listen to. This option is *required*. - * `output` {Writable} The [Writable][] stream to write readline data to. + * `output` {stream.Writable} The [Writable][] stream to write readline data to. * `completer` {Function} An optional function used for Tab autocompletion. * `terminal` {boolean} `true` if the `input` and `output` streams should be treated like a TTY, and have ANSI/VT100 escape codes written to it. @@ -431,7 +431,7 @@ function completer(linePartial, callback) { added: v0.7.7 --> -* `stream` {Writable} +* `stream` {stream.Writable} * `x` {number} * `y` {number} @@ -443,7 +443,7 @@ given [TTY][] `stream`. added: v0.7.7 --> -* `stream` {Readable} +* `stream` {stream.Readable} * `interface` {readline.Interface} The `readline.emitKeypressEvents()` method causes the given [Readable][] @@ -469,7 +469,7 @@ if (process.stdin.isTTY) added: v0.7.7 --> -* `stream` {Writable} +* `stream` {stream.Writable} * `dx` {number} * `dy` {number} diff --git a/doc/api/repl.md b/doc/api/repl.md index 69f709a1be874b..17c44fbe36c7ba 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -381,9 +381,9 @@ added: v0.1.91 * `options` {Object | string} * `prompt` {string} The input prompt to display. Defaults to `> `. - * `input` {Readable} The Readable stream from which REPL input will be read. + * `input` {stream.Readable} The Readable stream from which REPL input will be read. Defaults to `process.stdin`. - * `output` {Writable} The Writable stream to which REPL output will be + * `output` {stream.Writable} The Writable stream to which REPL output will be written. Defaults to `process.stdout`. * `terminal` {boolean} If `true`, specifies that the `output` should be treated as a TTY terminal, and have ANSI/VT100 escape codes written to it. diff --git a/doc/api/stream.md b/doc/api/stream.md index 4e7e897b3dd163..f1b5ef565517ff 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -385,7 +385,7 @@ added: v0.11.15 --> * `encoding` {string} The new default encoding -* Returns: `this` +* Returns: {this} The `writable.setDefaultEncoding()` method sets the default `encoding` for a [Writable][] stream. @@ -771,7 +771,7 @@ readable.isPaused(); // === false added: v0.9.4 --> -* Returns: `this` +* Returns: {this} The `readable.pause()` method will cause a stream in flowing mode to stop emitting [`'data'`][] events, switching out of flowing mode. Any data that @@ -903,7 +903,7 @@ event has been emitted will return `null`. No runtime error will be raised. added: v0.9.4 --> -* Returns: `this` +* Returns: {this} The `readable.resume()` method causes an explicitly paused Readable stream to resume emitting [`'data'`][] events, switching the stream into flowing mode. @@ -926,7 +926,7 @@ added: v0.9.4 --> * `encoding` {string} The encoding to use. -* Returns: `this` +* Returns: {this} The `readable.setEncoding()` method sets the character encoding for data read from the Readable stream. diff --git a/tools/doc/type-parser.js b/tools/doc/type-parser.js index bfe058a42c2cd2..5aa91c39b2a669 100644 --- a/tools/doc/type-parser.js +++ b/tools/doc/type-parser.js @@ -14,31 +14,58 @@ const jsPrimitives = { 'undefined': 'Undefined' }; const jsGlobalTypes = [ - 'Error', 'Object', 'Function', 'Array', 'TypedArray', 'Uint8Array', - 'Uint16Array', 'Uint32Array', 'Int8Array', 'Int16Array', 'Int32Array', - 'Uint8ClampedArray', 'Float32Array', 'Float64Array', 'Date', 'RegExp', - 'ArrayBuffer', 'DataView', 'Promise', 'EvalError', 'RangeError', - 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError' + 'Array', 'ArrayBuffer', 'DataView', 'Date', 'Error', 'EvalError', + 'Float32Array', 'Float64Array', 'Function', 'Int16Array', 'Int32Array', + 'Int8Array', 'Object', 'Promise', 'RangeError', 'ReferenceError', 'RegExp', + 'SharedArrayBuffer', 'SyntaxError', 'TypeError', 'TypedArray', 'URIError', + 'Uint16Array', 'Uint32Array', 'Uint8Array', 'Uint8ClampedArray' ]; const typeMap = { + 'Iterable': + 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol', + 'Iterator': + 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol', + + 'this': + 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this', + 'Buffer': 'buffer.html#buffer_class_buffer', - 'Handle': 'net.html#net_server_listen_handle_backlog_callback', - 'Stream': 'stream.html#stream_stream', - 'stream.Writable': 'stream.html#stream_class_stream_writable', - 'stream.Readable': 'stream.html#stream_class_stream_readable', - 'stream.Duplex': 'stream.html#stream_class_stream_duplex', + 'ChildProcess': 'child_process.html#child_process_class_childprocess', + 'cluster.Worker': 'cluster.html#cluster_class_worker', + 'dgram.Socket': 'dgram.html#dgram_class_dgram_socket', - 'net.Socket': 'net.html#net_class_net_socket', - 'tls.TLSSocket': 'tls.html#tls_class_tls_tlssocket', + + 'Domain': 'domain.html#domain_class_domain', + 'EventEmitter': 'events.html#events_class_eventemitter', - 'Timer': 'timers.html#timers_timers', + + 'fs.Stats': 'fs.html#fs_class_fs_stats', + 'http.Agent': 'http.html#http_class_http_agent', 'http.ClientRequest': 'http.html#http_class_http_clientrequest', 'http.IncomingMessage': 'http.html#http_class_http_incomingmessage', 'http.Server': 'http.html#http_class_http_server', 'http.ServerResponse': 'http.html#http_class_http_serverresponse', + + 'Handle': 'net.html#net_server_listen_handle_backlog_callback', + 'net.Server': 'net.html#net_class_net_server', + 'net.Socket': 'net.html#net_class_net_socket', + + 'readline.Interface': 'readline.html#readline_class_interface', + + 'Stream': 'stream.html#stream_stream', + 'stream.Duplex': 'stream.html#stream_class_stream_duplex', + 'stream.Readable': 'stream.html#stream_class_stream_readable', + 'stream.Writable': 'stream.html#stream_class_stream_writable', + + 'Immediate': 'timers.html#timers_class_immediate', + 'Timeout': 'timers.html#timers_class_timeout', + 'Timer': 'timers.html#timers_timers', + + 'tls.TLSSocket': 'tls.html#tls_class_tls_tlssocket', + 'URL': 'url.html#url_the_whatwg_url_api', 'URLSearchParams': 'url.html#url_class_urlsearchparams' };