Skip to content

Commit 313b205

Browse files
vsemozhetbytevanlucas
authored andcommitted
doc: prepare js code for eslint-plugin-markdown
This is an initial step to eliminate most of parsing errors. PR-URL: #12563 Refs: #12557 (comment) Reviewed-By: Teddy Katz <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]>
1 parent cbdf9a9 commit 313b205

9 files changed

+44
-36
lines changed

doc/api/child_process.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ bat.stderr.on('data', (data) => {
101101
bat.on('exit', (code) => {
102102
console.log(`Child exited with code ${code}`);
103103
});
104+
```
104105

106+
```js
105107
// OR...
106108
const exec = require('child_process').exec;
107109
exec('my.bat', (err, stdout, stderr) => {
@@ -184,14 +186,14 @@ The `options` argument may be passed as the second argument to customize how
184186
the process is spawned. The default options are:
185187

186188
```js
187-
{
189+
const defaults = {
188190
encoding: 'utf8',
189191
timeout: 0,
190192
maxBuffer: 200*1024,
191193
killSignal: 'SIGTERM',
192194
cwd: null,
193195
env: null
194-
}
196+
};
195197
```
196198

197199
If `timeout` is greater than `0`, the parent will send the signal
@@ -348,10 +350,10 @@ trigger arbitrary command execution.**
348350
A third argument may be used to specify additional options, with these defaults:
349351

350352
```js
351-
{
353+
const defaults = {
352354
cwd: undefined,
353355
env: process.env
354-
}
356+
};
355357
```
356358

357359
Use `cwd` to specify the working directory from which the process is spawned.

doc/api/console.md

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ or `console.Console`:
6262

6363
```js
6464
const Console = require('console').Console;
65+
```
66+
67+
```js
6568
const Console = console.Console;
6669
```
6770

doc/api/fs.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ synchronous counterparts are of this type.
217217
For a regular file [`util.inspect(stats)`][] would return a string very
218218
similar to this:
219219

220-
```js
220+
```txt
221221
Stats {
222222
dev: 2114,
223223
ino: 48064969,
@@ -630,13 +630,13 @@ default value of 64 kb for the same parameter.
630630
`options` is an object or string with the following defaults:
631631

632632
```js
633-
{
633+
const defaults = {
634634
flags: 'r',
635635
encoding: null,
636636
fd: null,
637637
mode: 0o666,
638638
autoClose: true
639-
}
639+
};
640640
```
641641

642642
`options` can include `start` and `end` values to read a range of bytes from
@@ -696,13 +696,13 @@ Returns a new [`WriteStream`][] object. (See [Writable Stream][]).
696696
`options` is an object or string with the following defaults:
697697

698698
```js
699-
{
699+
const defaults = {
700700
flags: 'w',
701701
defaultEncoding: 'utf8',
702702
fd: null,
703703
mode: 0o666,
704704
autoClose: true
705-
}
705+
};
706706
```
707707

708708
`options` may also include a `start` option to allow writing data at

doc/api/modules.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,8 @@ object, it is common to also reassign `exports`, for example:
558558

559559
```js
560560
module.exports = exports = function Constructor() {
561-
// ... etc.
561+
// ... etc.
562+
};
562563
```
563564

564565
To illustrate the behavior, imagine this hypothetical implementation of

doc/api/process.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ running the `./configure` script.
529529

530530
An example of the possible output looks like:
531531

532-
```js
532+
```txt
533533
{
534534
target_defaults:
535535
{ cflags: [],
@@ -1695,7 +1695,7 @@ to load modules that were compiled against a different module ABI version.
16951695
console.log(process.versions);
16961696
```
16971697

1698-
Will generate output similar to:
1698+
Will generate an object similar to:
16991699

17001700
```js
17011701
{

doc/api/tls.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,7 @@ stream.
12241224
`tls.TLSSocket()`. For example, the code:
12251225

12261226
```js
1227-
pair = tls.createSecurePair( ... );
1227+
pair = tls.createSecurePair(/* ... */);
12281228
pair.encrypted.pipe(socket);
12291229
socket.pipe(pair.encrypted);
12301230
```

doc/api/zlib.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ request.on('response', (response) => {
8484
break;
8585
}
8686
});
87+
```
8788

89+
```js
8890
// server example
8991
// Running a gzip operation on every request is quite expensive.
9092
// It would be much more efficient to cache the compressed buffer.
@@ -159,7 +161,7 @@ For example, to reduce the default memory requirements from 256K to 128K, the
159161
options should be set to:
160162

161163
```js
162-
{ windowBits: 14, memLevel: 7 }
164+
const options = { windowBits: 14, memLevel: 7 };
163165
```
164166

165167
This will, however, generally degrade compression.

doc/guides/using-internal-errors.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ and appending the new error codes to the end using the utility `E()` method.
5252

5353
```js
5454
E('EXAMPLE_KEY1', 'This is the error value');
55-
E('EXAMPLE_KEY2', (a, b) => return `${a} ${b}`);
55+
E('EXAMPLE_KEY2', (a, b) => `${a} ${b}`);
5656
```
5757

5858
The first argument passed to `E()` is the static identifier. The second

doc/guides/writing-tests.md

+21-21
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,27 @@ Add tests when:
2323
Let's analyze this basic test from the Node.js test suite:
2424

2525
```javascript
26-
1 'use strict';
27-
2 const common = require('../common');
28-
3
29-
4 // This test ensures that the http-parser can handle UTF-8 characters
30-
5 // in the http header.
31-
6
32-
7 const assert = require('assert');
33-
8 const http = require('http');
34-
9
35-
10 const server = http.createServer(common.mustCall((req, res) => {
36-
11 res.end('ok');
37-
12 }));
38-
13 server.listen(0, () => {
39-
14 http.get({
40-
15 port: server.address().port,
41-
16 headers: {'Test': 'Düsseldorf'}
42-
17 }, common.mustCall((res) => {
43-
18 assert.strictEqual(res.statusCode, 200);
44-
19 server.close();
45-
20 }));
46-
21 });
26+
'use strict'; // 1
27+
const common = require('../common'); // 2
28+
// 3
29+
// This test ensures that the http-parser can handle UTF-8 characters // 4
30+
// in the http header. // 5
31+
// 6
32+
const assert = require('assert'); // 7
33+
const http = require('http'); // 8
34+
// 9
35+
const server = http.createServer(common.mustCall((req, res) => { // 10
36+
res.end('ok'); // 11
37+
})); // 12
38+
server.listen(0, () => { // 13
39+
http.get({ // 14
40+
port: server.address().port, // 15
41+
headers: {'Test': 'Düsseldorf'} // 16
42+
}, common.mustCall((res) => { // 17
43+
assert.strictEqual(res.statusCode, 200); // 18
44+
server.close(); // 19
45+
})); // 20
46+
}); // 21
4747
```
4848

4949
### **Lines 1-2**

0 commit comments

Comments
 (0)