Skip to content

Commit f2a78de

Browse files
committed
doc: fix optional parameter parsing
The parameter parser specifically looked for the old bracket syntax. This generated a lot of warnings when building the docs. Those warnings have been fixed by changing the parsing logic. Signed-off-by: Trevor Norris <[email protected]>
1 parent 734fb49 commit f2a78de

20 files changed

+99
-82
lines changed

doc/api/assert.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Tests strict equality, as determined by the strict equality operator ( `===` )
3737

3838
Tests strict non-equality, as determined by the strict not equal operator ( `!==` )
3939

40-
## assert.throws(block[, error]\[, message])
40+
## assert.throws(block[, error][, message])
4141

4242
Expects `block` to throw an error. `error` can be constructor, `RegExp` or
4343
validation function.

doc/api/buffer.markdown

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ buffer object. It does not change when the contents of the buffer are changed.
162162
// 1234
163163
// 1234
164164

165-
### buf.write(string[, offset]\[, length]\[, encoding])
165+
### buf.write(string[, offset][, length][, encoding])
166166

167167
* `string` String - data to be written to buffer
168168
* `offset` Number, Optional, Default: 0
@@ -181,7 +181,7 @@ The method will not write partial characters.
181181
console.log(len + " bytes: " + buf.toString('utf8', 0, len));
182182

183183

184-
### buf.toString([encoding]\[, start]\[, end])
184+
### buf.toString([encoding][, start][, end])
185185

186186
* `encoding` String, Optional, Default: 'utf8'
187187
* `start` Number, Optional, Default: 0
@@ -252,7 +252,7 @@ Returns a number indicating whether `this` comes before or after or is
252252
the same as the `otherBuffer` in sort order.
253253

254254

255-
### buf.copy(targetBuffer[, targetStart]\[, sourceStart]\[, sourceEnd])
255+
### buf.copy(targetBuffer[, targetStart][, sourceStart][, sourceEnd])
256256

257257
* `targetBuffer` Buffer object - Buffer to copy into
258258
* `targetStart` Number, Optional, Default: 0
@@ -283,7 +283,7 @@ into `buf2`, starting at the 8th byte in `buf2`.
283283
// !!!!!!!!qrst!!!!!!!!!!!!!
284284

285285

286-
### buf.slice([start]\[, end])
286+
### buf.slice([start][, end])
287287

288288
* `start` Number, Optional, Default: 0
289289
* `end` Number, Optional, Default: `buffer.length`
@@ -703,7 +703,7 @@ Example:
703703
// <Buffer 43 eb d5 b7 dd f9 5f d7>
704704
// <Buffer d7 5f f9 dd b7 d5 eb 43>
705705

706-
### buf.fill(value[, offset]\[, end])
706+
### buf.fill(value[, offset][, end])
707707

708708
* `value`
709709
* `offset` Number, Optional

doc/api/child_process.markdown

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ child process has any open IPC channels with the parent (i.e `fork()`).
303303
These methods follow the common async programming patterns (accepting a
304304
callback or returning an EventEmitter).
305305

306-
### child_process.spawn(command[, args]\[, options])
306+
### child_process.spawn(command[, args][, options])
307307

308308
* `command` {String} The command to run
309309
* `args` {Array} List of string arguments
@@ -531,7 +531,7 @@ amount of data allowed on stdout or stderr - if this value is exceeded then
531531
the child process is killed.
532532

533533

534-
### child_process.execFile(file[, args]\[, options]\[, callback])
534+
### child_process.execFile(file[, args][, options][, callback])
535535

536536
* `file` {String} The filename of the program to run
537537
* `args` {Array} List of string arguments
@@ -555,7 +555,7 @@ subshell but rather the specified file directly. This makes it slightly
555555
leaner than `child_process.exec`. It has the same options.
556556

557557

558-
### child_process.fork(modulePath[, args]\[, options])
558+
### child_process.fork(modulePath[, args][, options])
559559

560560
* `modulePath` {String} The module to run in the child
561561
* `args` {Array} List of string arguments
@@ -598,7 +598,7 @@ Blocking calls like these are mostly useful for simplifying general purpose
598598
scripting tasks and for simplifying the loading/processing of application
599599
configuration at startup.
600600

601-
### child_process.spawnSync(command[, args]\[, options])
601+
### child_process.spawnSync(command[, args][, options])
602602

603603
* `command` {String} The command to run
604604
* `args` {Array} List of string arguments
@@ -629,7 +629,7 @@ until the process has completely exited. That is to say, if the process handles
629629
the `SIGTERM` signal and doesn't exit, your process will wait until the child
630630
process has exited.
631631

632-
### child_process.execFileSync(command[, args]\[, options])
632+
### child_process.execFileSync(command[, args][, options])
633633

634634
* `command` {String} The command to run
635635
* `args` {Array} List of string arguments

doc/api/console.markdown

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ In daily use, the blocking/non-blocking dichotomy is not something you
2222
should worry about unless you log huge amounts of data.
2323

2424

25-
## console.log([data]\[, ...])
25+
## console.log([data][, ...])
2626

2727
Prints to stdout with newline. This function can take multiple arguments in a
2828
`printf()`-like way. Example:
@@ -34,15 +34,15 @@ Prints to stdout with newline. This function can take multiple arguments in a
3434
If formatting elements are not found in the first string then `util.inspect`
3535
is used on each argument. See [util.format()][] for more information.
3636

37-
## console.info([data]\[, ...])
37+
## console.info([data][, ...])
3838

3939
Same as `console.log`.
4040

41-
## console.error([data]\[, ...])
41+
## console.error([data][, ...])
4242

4343
Same as `console.log` but prints to stderr.
4444

45-
## console.warn([data]\[, ...])
45+
## console.warn([data][, ...])
4646

4747
Same as `console.error`.
4848

@@ -82,7 +82,7 @@ Finish timer, record output. Example:
8282
Print to stderr `'Trace :'`, followed by the formatted message and stack trace
8383
to the current position.
8484

85-
## console.assert(value[, message]\[, ...])
85+
## console.assert(value[, message][, ...])
8686

8787
Similar to [assert.ok()][], but the error message is formatted as
8888
`util.format(message...)`.

doc/api/crypto.markdown

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ writable. The written plain text data is used to produce the
214214
encrypted data on the readable side. The legacy `update` and `final`
215215
methods are also supported.
216216

217-
### cipher.update(data[, input_encoding]\[, output_encoding])
217+
### cipher.update(data[, input_encoding][, output_encoding])
218218

219219
Updates the cipher with `data`, the encoding of which is given in
220220
`input_encoding` and can be `'utf8'`, `'ascii'` or `'binary'`. If no
@@ -280,7 +280,7 @@ writable. The written enciphered data is used to produce the
280280
plain-text data on the the readable side. The legacy `update` and
281281
`final` methods are also supported.
282282

283-
### decipher.update(data[, input_encoding]\[, output_encoding])
283+
### decipher.update(data[, input_encoding][, output_encoding])
284284

285285
Updates the decipher with `data`, which is encoded in `'binary'`,
286286
`'base64'` or `'hex'`. If no encoding is provided, then a buffer is
@@ -408,7 +408,7 @@ Creates a Diffie-Hellman key exchange object and generates a prime of
408408
`prime_length` bits and using an optional specific numeric `generator`.
409409
If no `generator` is specified, then `2` is used.
410410

411-
## crypto.createDiffieHellman(prime[, prime_encoding]\[, generator]\[, generator_encoding])
411+
## crypto.createDiffieHellman(prime[, prime_encoding][, generator][, generator_encoding])
412412

413413
Creates a Diffie-Hellman key exchange object using the supplied `prime` and an
414414
optional specific `generator`.
@@ -442,7 +442,7 @@ the public key in the specified encoding. This key should be
442442
transferred to the other party. Encoding can be `'binary'`, `'hex'`,
443443
or `'base64'`. If no encoding is provided, then a buffer is returned.
444444

445-
### diffieHellman.computeSecret(other_public_key[, input_encoding]\[, output_encoding])
445+
### diffieHellman.computeSecret(other_public_key[, input_encoding][, output_encoding])
446446

447447
Computes the shared secret using `other_public_key` as the other
448448
party's public key and returns the computed shared secret. Supplied
@@ -541,7 +541,7 @@ Format specifies point encoding and can be `'compressed'`, `'uncompressed'`, or
541541
Encoding can be `'binary'`, `'hex'`, or `'base64'`. If no encoding is provided,
542542
then a buffer is returned.
543543

544-
### ECDH.computeSecret(other_public_key[, input_encoding]\[, output_encoding])
544+
### ECDH.computeSecret(other_public_key[, input_encoding][, output_encoding])
545545

546546
Computes the shared secret using `other_public_key` as the other
547547
party's public key and returns the computed shared secret. Supplied

doc/api/dgram.markdown

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,8 @@ You have to change it to this:
2222

2323

2424
## dgram.createSocket(type[, callback])
25-
## dgram.createSocket(options[, callback])
2625

2726
* `type` String. Either 'udp4' or 'udp6'
28-
* `options` Object. Should contain a `type` property and could contain
29-
`reuseAddr` property. `false` by default.
30-
When `reuseAddr` is `true` - `socket.bind()` will reuse address, even if the
31-
other process has already bound a socket on it.
3227
* `callback` Function. Attached as a listener to `message` events.
3328
Optional
3429
* Returns: Socket object
@@ -38,9 +33,28 @@ and `udp6`.
3833

3934
Takes an optional callback which is added as a listener for `message` events.
4035

41-
Call `socket.bind` if you want to receive datagrams. `socket.bind()` will bind
42-
to the "all interfaces" address on a random port (it does the right thing for
43-
both `udp4` and `udp6` sockets). You can then retrieve the address and port
36+
Call `socket.bind()` if you want to receive datagrams. `socket.bind()` will
37+
bind to the "all interfaces" address on a random port (it does the right thing
38+
for both `udp4` and `udp6` sockets). You can then retrieve the address and port
39+
with `socket.address().address` and `socket.address().port`.
40+
41+
## dgram.createSocket(options[, callback])
42+
* `options` Object
43+
* `callback` Function. Attached as a listener to `message` events.
44+
* Returns: Socket object
45+
46+
The `options` object should contain a `type` field of either `udp4` or `udp6`
47+
and an optional boolean `reuseAddr` field.
48+
49+
When `reuseAddr` is true `socket.bind()` will reuse the address, even if
50+
another process has already bound a socket on it. `reuseAddr` defaults to
51+
`false`.
52+
53+
Takes an optional callback which is added as a listener for `message` events.
54+
55+
Call `socket.bind()` if you want to receive datagrams. `socket.bind()` will
56+
bind to the "all interfaces" address on a random port (it does the right thing
57+
for both `udp4` and `udp6` sockets). You can then retrieve the address and port
4458
with `socket.address().address` and `socket.address().port`.
4559

4660
## Class: dgram.Socket
@@ -142,7 +156,7 @@ a packet might travel, and that generally sending a datagram greater than
142156
the (receiver) `MTU` won't work (the packet gets silently dropped, without
143157
informing the source that the data did not reach its intended recipient).
144158

145-
### socket.bind(port[, address]\[, callback])
159+
### socket.bind(port[, address][, callback])
146160

147161
* `port` Integer
148162
* `address` String, Optional

doc/api/events.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Returns an array of listeners for the specified event.
104104
console.log(util.inspect(server.listeners('connection'))); // [ [Function] ]
105105

106106

107-
### emitter.emit(event[, arg1]\[, arg2]\[, ...])
107+
### emitter.emit(event[, arg1][, arg2][, ...])
108108

109109
Execute each of the listeners in order with the supplied arguments.
110110

doc/api/fs.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ have effectively stopped watching `filename`.
568568
Calling `fs.unwatchFile()` with a filename that is not being watched is a
569569
no-op, not an error.
570570

571-
## fs.watch(filename[, options]\[, listener])
571+
## fs.watch(filename[, options][, listener])
572572

573573
Stability: 2 - Unstable.
574574

doc/api/http.markdown

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Returns a new web server object.
6464
The `requestListener` is a function which is automatically
6565
added to the `'request'` event.
6666

67-
## http.createClient([port]\[, host])
67+
## http.createClient([port][, host])
6868

6969
This function is **deprecated**; please use [http.request()][] instead.
7070
Constructs a new HTTP client. `port` and `host` refer to the server to be
@@ -160,7 +160,7 @@ If a client connection emits an 'error' event - it will forwarded here.
160160
`socket` is the `net.Socket` object that the error originated from.
161161

162162

163-
### server.listen(port[, hostname]\[, backlog]\[, callback])
163+
### server.listen(port[, hostname][, backlog][, callback])
164164

165165
Begin accepting connections on the specified port and hostname. If the
166166
hostname is omitted, the server will accept connections directed to any
@@ -275,7 +275,7 @@ After this event, no more events will be emitted on the response object.
275275
Sends a HTTP/1.1 100 Continue message to the client, indicating that
276276
the request body should be sent. See the ['checkContinue'][] event on `Server`.
277277

278-
### response.writeHead(statusCode[, statusMessage]\[, headers])
278+
### response.writeHead(statusCode[, statusMessage][, headers])
279279

280280
Sends a response header to the request. The status code is a 3-digit HTTP
281281
status code, like `404`. The last argument, `headers`, are the response headers.
@@ -433,7 +433,7 @@ emit trailers, with a list of the header fields in its value. E.g.,
433433
response.end();
434434

435435

436-
### response.end([data]\[, encoding])
436+
### response.end([data][, encoding])
437437

438438
This method signals to the server that all of the response headers and body
439439
have been sent; that server should consider this message complete.
@@ -878,7 +878,7 @@ The `encoding` argument is optional and only applies when `chunk` is a string.
878878
Defaults to `'utf8'`.
879879

880880

881-
### request.end([data]\[, encoding])
881+
### request.end([data][, encoding])
882882

883883
Finishes sending the request. If any parts of the body are
884884
unsent, it will flush them to the stream. If the request is
@@ -901,7 +901,7 @@ Once a socket is assigned to this request and is connected
901901
Once a socket is assigned to this request and is connected
902902
[socket.setNoDelay()][] will be called.
903903

904-
### request.setSocketKeepAlive([enable]\[, initialDelay])
904+
### request.setSocketKeepAlive([enable][, initialDelay])
905905

906906
Once a socket is assigned to this request and is connected
907907
[socket.setKeepAlive()][] will be called.

doc/api/https.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Or
5555
}).listen(8000);
5656

5757

58-
### server.listen(port[, host]\[, backlog]\[, callback])
58+
### server.listen(port[, host][, backlog][, callback])
5959
### server.listen(path[, callback])
6060
### server.listen(handle[, callback])
6161

0 commit comments

Comments
 (0)