Skip to content

Commit 7deb259

Browse files
vsemozhetbytMylesBorins
authored andcommitted
doc: prepare js code for eslint-plugin-markdown
This is an initial step to eliminate most of parsing errors. Backport-PR-URL: #14067 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 edbe442 commit 7deb259

File tree

8 files changed

+43
-35
lines changed

8 files changed

+43
-35
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) => {
@@ -183,14 +185,14 @@ The `options` argument may be passed as the second argument to customize how
183185
the process is spawned. The default options are:
184186

185187
```js
186-
{
188+
const defaults = {
187189
encoding: 'utf8',
188190
timeout: 0,
189191
maxBuffer: 200*1024,
190192
killSignal: 'SIGTERM',
191193
cwd: null,
192194
env: null
193-
}
195+
};
194196
```
195197

196198
If `timeout` is greater than `0`, the parent will send the signal
@@ -335,10 +337,10 @@ trigger arbitrary command execution.**
335337
A third argument may be used to specify additional options, with these defaults:
336338

337339
```js
338-
{
340+
const defaults = {
339341
cwd: undefined,
340342
env: process.env
341-
}
343+
};
342344
```
343345

344346
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
@@ -218,7 +218,7 @@ synchronous counterparts are of this type.
218218
For a regular file [`util.inspect(stats)`][] would return a string very
219219
similar to this:
220220

221-
```js
221+
```txt
222222
Stats {
223223
dev: 2114,
224224
ino: 48064969,
@@ -592,13 +592,13 @@ default value of 64 kb for the same parameter.
592592
`options` is an object or string with the following defaults:
593593

594594
```js
595-
{
595+
const defaults = {
596596
flags: 'r',
597597
encoding: null,
598598
fd: null,
599599
mode: 0o666,
600600
autoClose: true
601-
}
601+
};
602602
```
603603

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

650650
```js
651-
{
651+
const defaults = {
652652
flags: 'w',
653653
defaultEncoding: 'utf8',
654654
fd: null,
655655
mode: 0o666,
656656
autoClose: true
657-
}
657+
};
658658
```
659659

660660
`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
@@ -550,7 +550,7 @@ running the `./configure` script.
550550

551551
An example of the possible output looks like:
552552

553-
```js
553+
```txt
554554
{
555555
target_defaults:
556556
{ cflags: [],
@@ -1707,7 +1707,7 @@ to load modules that were compiled against a different module ABI version.
17071707
console.log(process.versions);
17081708
```
17091709

1710-
Will generate output similar to:
1710+
Will generate an object similar to:
17111711

17121712
```js
17131713
{

doc/api/tls.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ stream.
11951195
`tls.TLSSocket()`. For example, the code:
11961196

11971197
```js
1198-
pair = tls.createSecurePair( ... );
1198+
pair = tls.createSecurePair(/* ... */);
11991199
pair.encrypted.pipe(socket);
12001200
socket.pipe(pair.encrypted);
12011201
```

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.
@@ -157,7 +159,7 @@ For example, to reduce the default memory requirements from 256K to 128K, the
157159
options should be set to:
158160

159161
```js
160-
{ windowBits: 14, memLevel: 7 }
162+
const options = { windowBits: 14, memLevel: 7 };
161163
```
162164

163165
This will, however, generally degrade compression.

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)