Browse Source

doc: prepare js code for eslint-plugin-markdown

This is an initial step to eliminate most of parsing errors.

Backport-PR-URL: https://github.com/nodejs/node/pull/14067
PR-URL: https://github.com/nodejs/node/pull/12563
Refs: https://github.com/nodejs/node/pull/12557#issuecomment-296015032
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
v6.x
Vse Mozhet Byt 8 years ago
committed by Myles Borins
parent
commit
7deb259ccb
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 10
      doc/api/child_process.md
  2. 3
      doc/api/console.md
  3. 10
      doc/api/fs.md
  4. 1
      doc/api/modules.md
  5. 4
      doc/api/process.md
  6. 2
      doc/api/tls.md
  7. 4
      doc/api/zlib.md
  8. 42
      doc/guides/writing-tests.md

10
doc/api/child_process.md

@ -101,7 +101,9 @@ bat.stderr.on('data', (data) => {
bat.on('exit', (code) => { bat.on('exit', (code) => {
console.log(`Child exited with code ${code}`); console.log(`Child exited with code ${code}`);
}); });
```
```js
// OR... // OR...
const exec = require('child_process').exec; const exec = require('child_process').exec;
exec('my.bat', (err, stdout, stderr) => { exec('my.bat', (err, stdout, stderr) => {
@ -183,14 +185,14 @@ The `options` argument may be passed as the second argument to customize how
the process is spawned. The default options are: the process is spawned. The default options are:
```js ```js
{ const defaults = {
encoding: 'utf8', encoding: 'utf8',
timeout: 0, timeout: 0,
maxBuffer: 200*1024, maxBuffer: 200*1024,
killSignal: 'SIGTERM', killSignal: 'SIGTERM',
cwd: null, cwd: null,
env: null env: null
} };
``` ```
If `timeout` is greater than `0`, the parent will send the signal If `timeout` is greater than `0`, the parent will send the signal
@ -335,10 +337,10 @@ trigger arbitrary command execution.**
A third argument may be used to specify additional options, with these defaults: A third argument may be used to specify additional options, with these defaults:
```js ```js
{ const defaults = {
cwd: undefined, cwd: undefined,
env: process.env env: process.env
} };
``` ```
Use `cwd` to specify the working directory from which the process is spawned. Use `cwd` to specify the working directory from which the process is spawned.

3
doc/api/console.md

@ -62,6 +62,9 @@ or `console.Console`:
```js ```js
const Console = require('console').Console; const Console = require('console').Console;
```
```js
const Console = console.Console; const Console = console.Console;
``` ```

10
doc/api/fs.md

@ -218,7 +218,7 @@ synchronous counterparts are of this type.
For a regular file [`util.inspect(stats)`][] would return a string very For a regular file [`util.inspect(stats)`][] would return a string very
similar to this: similar to this:
```js ```txt
Stats { Stats {
dev: 2114, dev: 2114,
ino: 48064969, ino: 48064969,
@ -592,13 +592,13 @@ default value of 64 kb for the same parameter.
`options` is an object or string with the following defaults: `options` is an object or string with the following defaults:
```js ```js
{ const defaults = {
flags: 'r', flags: 'r',
encoding: null, encoding: null,
fd: null, fd: null,
mode: 0o666, mode: 0o666,
autoClose: true autoClose: true
} };
``` ```
`options` can include `start` and `end` values to read a range of bytes from `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][]).
`options` is an object or string with the following defaults: `options` is an object or string with the following defaults:
```js ```js
{ const defaults = {
flags: 'w', flags: 'w',
defaultEncoding: 'utf8', defaultEncoding: 'utf8',
fd: null, fd: null,
mode: 0o666, mode: 0o666,
autoClose: true autoClose: true
} };
``` ```
`options` may also include a `start` option to allow writing data at `options` may also include a `start` option to allow writing data at

1
doc/api/modules.md

@ -559,6 +559,7 @@ object, it is common to also reassign `exports`, for example:
```js ```js
module.exports = exports = function Constructor() { module.exports = exports = function Constructor() {
// ... etc. // ... etc.
};
``` ```
To illustrate the behavior, imagine this hypothetical implementation of To illustrate the behavior, imagine this hypothetical implementation of

4
doc/api/process.md

@ -550,7 +550,7 @@ running the `./configure` script.
An example of the possible output looks like: An example of the possible output looks like:
```js ```txt
{ {
target_defaults: target_defaults:
{ cflags: [], { cflags: [],
@ -1707,7 +1707,7 @@ to load modules that were compiled against a different module ABI version.
console.log(process.versions); console.log(process.versions);
``` ```
Will generate output similar to: Will generate an object similar to:
```js ```js
{ {

2
doc/api/tls.md

@ -1195,7 +1195,7 @@ stream.
`tls.TLSSocket()`. For example, the code: `tls.TLSSocket()`. For example, the code:
```js ```js
pair = tls.createSecurePair( ... ); pair = tls.createSecurePair(/* ... */);
pair.encrypted.pipe(socket); pair.encrypted.pipe(socket);
socket.pipe(pair.encrypted); socket.pipe(pair.encrypted);
``` ```

4
doc/api/zlib.md

@ -84,7 +84,9 @@ request.on('response', (response) => {
break; break;
} }
}); });
```
```js
// server example // server example
// Running a gzip operation on every request is quite expensive. // Running a gzip operation on every request is quite expensive.
// It would be much more efficient to cache the compressed buffer. // 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
options should be set to: options should be set to:
```js ```js
{ windowBits: 14, memLevel: 7 } const options = { windowBits: 14, memLevel: 7 };
``` ```
This will, however, generally degrade compression. This will, however, generally degrade compression.

42
doc/guides/writing-tests.md

@ -23,27 +23,27 @@ Add tests when:
Let's analyze this basic test from the Node.js test suite: Let's analyze this basic test from the Node.js test suite:
```javascript ```javascript
1 'use strict'; 'use strict'; // 1
2 const common = require('../common'); const common = require('../common'); // 2
3 // 3
4 // This test ensures that the http-parser can handle UTF-8 characters // This test ensures that the http-parser can handle UTF-8 characters // 4
5 // in the http header. // in the http header. // 5
6 // 6
7 const assert = require('assert'); const assert = require('assert'); // 7
8 const http = require('http'); const http = require('http'); // 8
9 // 9
10 const server = http.createServer(common.mustCall((req, res) => { const server = http.createServer(common.mustCall((req, res) => { // 10
11 res.end('ok'); res.end('ok'); // 11
12 })); })); // 12
13 server.listen(0, () => { server.listen(0, () => { // 13
14 http.get({ http.get({ // 14
15 port: server.address().port, port: server.address().port, // 15
16 headers: {'Test': 'Düsseldorf'} headers: {'Test': 'Düsseldorf'} // 16
17 }, common.mustCall((res) => { }, common.mustCall((res) => { // 17
18 assert.strictEqual(res.statusCode, 200); assert.strictEqual(res.statusCode, 200); // 18
19 server.close(); server.close(); // 19
20 })); })); // 20
21 }); }); // 21
``` ```
### **Lines 1-2** ### **Lines 1-2**

Loading…
Cancel
Save