Skip to content

Commit

Permalink
doc: make comment indentation consistent
Browse files Browse the repository at this point in the history
Currently, some of the docs use different indentation for comments
in the code examples. This commit makes the indentation consistent
by putting the comments at the beginning of the line (really no
indentation that is).

PR-URL: #9518
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
danbev authored and MylesBorins committed Dec 21, 2016
1 parent fa51a57 commit 8c6ad91
Show file tree
Hide file tree
Showing 15 changed files with 296 additions and 254 deletions.
42 changes: 28 additions & 14 deletions doc/api/addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ Once built, the binary Addon can be used from within Node.js by pointing
// hello.js
const addon = require('./build/Release/addon');
console.log(addon.hello()); // 'world'
console.log(addon.hello());
// Prints: 'world'
```
Please see the examples below for further information or
Expand Down Expand Up @@ -372,7 +373,8 @@ To test it, run the following JavaScript:
const addon = require('./build/Release/addon');
addon((msg) => {
console.log(msg); // 'hello world'
console.log(msg);
// Prints: 'hello world'
});
```

Expand Down Expand Up @@ -423,7 +425,8 @@ const addon = require('./build/Release/addon');
var obj1 = addon('hello');
var obj2 = addon('world');
console.log(obj1.msg, obj2.msg); // 'hello world'
console.log(obj1.msg, obj2.msg);
// Prints: 'hello world'
```


Expand Down Expand Up @@ -480,7 +483,8 @@ To test:
const addon = require('./build/Release/addon');
var fn = addon();
console.log(fn()); // 'hello world'
console.log(fn());
// Prints: 'hello world'
```


Expand Down Expand Up @@ -642,9 +646,12 @@ Test it with:
const addon = require('./build/Release/addon');

var obj = new addon.MyObject(10);
console.log(obj.plusOne()); // 11
console.log(obj.plusOne()); // 12
console.log(obj.plusOne()); // 13
console.log(obj.plusOne());
// Prints: 11
console.log(obj.plusOne());
// Prints: 12
console.log(obj.plusOne());
// Prints: 13
```

### Factory of wrapped objects
Expand Down Expand Up @@ -834,14 +841,20 @@ Test it with:
const createObject = require('./build/Release/addon');

var obj = createObject(10);
console.log(obj.plusOne()); // 11
console.log(obj.plusOne()); // 12
console.log(obj.plusOne()); // 13
console.log(obj.plusOne());
// Prints: 11
console.log(obj.plusOne());
// Prints: 12
console.log(obj.plusOne());
// Prints: 13

var obj2 = createObject(20);
console.log(obj2.plusOne()); // 21
console.log(obj2.plusOne()); // 22
console.log(obj2.plusOne()); // 23
console.log(obj2.plusOne());
// Prints: 21
console.log(obj2.plusOne());
// Prints: 22
console.log(obj2.plusOne());
// Prints: 23
```


Expand Down Expand Up @@ -1013,7 +1026,8 @@ var obj1 = addon.createObject(10);
var obj2 = addon.createObject(20);
var result = addon.add(obj1, obj2);
console.log(result); // 30
console.log(result);
// Prints: 30
```

### AtExit hooks
Expand Down
96 changes: 52 additions & 44 deletions doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ An alias of [`assert.ok()`][] .
```js
const assert = require('assert');

assert(true); // OK
assert(1); // OK
assert(true);
// OK
assert(1);
// OK
assert(false);
// throws "AssertionError: false == true"
// throws "AssertionError: false == true"
assert(0);
// throws "AssertionError: 0 == true"
// throws "AssertionError: 0 == true"
assert(false, 'it\'s false');
// throws "AssertionError: it's false"
// throws "AssertionError: it's false"
```

## assert.deepEqual(actual, expected[, message])
Expand Down Expand Up @@ -75,18 +77,18 @@ const obj3 = {
const obj4 = Object.create(obj1);

assert.deepEqual(obj1, obj1);
// OK, object is equal to itself
// OK, object is equal to itself

assert.deepEqual(obj1, obj2);
// AssertionError: { a: { b: 1 } } deepEqual { a: { b: 2 } }
// values of b are different
// AssertionError: { a: { b: 1 } } deepEqual { a: { b: 2 } }
// values of b are different

assert.deepEqual(obj1, obj3);
// OK, objects are equal
// OK, objects are equal

assert.deepEqual(obj1, obj4);
// AssertionError: { a: { b: 1 } } deepEqual {}
// Prototypes are ignored
// AssertionError: { a: { b: 1 } } deepEqual {}
// Prototypes are ignored
```

If the values are not equal, an `AssertionError` is thrown with a `message`
Expand All @@ -106,11 +108,11 @@ Second, object comparisons include a strict equality check of their prototypes.
const assert = require('assert');

assert.deepEqual({a:1}, {a:'1'});
// OK, because 1 == '1'
// OK, because 1 == '1'

assert.deepStrictEqual({a:1}, {a:'1'});
// AssertionError: { a: 1 } deepStrictEqual { a: '1' }
// because 1 !== '1' using strict equality
// AssertionError: { a: 1 } deepStrictEqual { a: '1' }
// because 1 !== '1' using strict equality
```

If the values are not equal, an `AssertionError` is thrown with a `message`
Expand Down Expand Up @@ -184,14 +186,14 @@ using the equal comparison operator ( `==` ).
const assert = require('assert');

assert.equal(1, 1);
// OK, 1 == 1
// OK, 1 == 1
assert.equal(1, '1');
// OK, 1 == '1'
// OK, 1 == '1'

assert.equal(1, 2);
// AssertionError: 1 == 2
// AssertionError: 1 == 2
assert.equal({a: {b: 1}}, {a: {b: 1}});
//AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
//AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
```

If the values are not equal, an `AssertionError` is thrown with a `message`
Expand All @@ -211,10 +213,10 @@ Otherwise, the error message is the value of `message`.
const assert = require('assert');

assert.fail(1, 2, undefined, '>');
// AssertionError: 1 > 2
// AssertionError: 1 > 2

assert.fail(1, 2, 'whoops', '>');
// AssertionError: whoops
// AssertionError: whoops
```

## assert.ifError(value)
Expand All @@ -228,10 +230,14 @@ argument in callbacks.
```js
const assert = require('assert');

assert.ifError(0); // OK
assert.ifError(1); // Throws 1
assert.ifError('error'); // Throws 'error'
assert.ifError(new Error()); // Throws Error
assert.ifError(0);
// OK
assert.ifError(1);
// Throws 1
assert.ifError('error');
// Throws 'error'
assert.ifError(new Error());
// Throws Error
```

## assert.notDeepEqual(actual, expected[, message])
Expand Down Expand Up @@ -262,16 +268,16 @@ const obj3 = {
const obj4 = Object.create(obj1);

assert.notDeepEqual(obj1, obj1);
// AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
// AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }

assert.notDeepEqual(obj1, obj2);
// OK, obj1 and obj2 are not deeply equal
// OK, obj1 and obj2 are not deeply equal

assert.notDeepEqual(obj1, obj3);
// AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
// AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }

assert.notDeepEqual(obj1, obj4);
// OK, obj1 and obj4 are not deeply equal
// OK, obj1 and obj2 are not deeply equal
```

If the values are deeply equal, an `AssertionError` is thrown with a `message`
Expand All @@ -289,10 +295,10 @@ Tests for deep strict inequality. Opposite of [`assert.deepStrictEqual()`][].
const assert = require('assert');

assert.notDeepEqual({a:1}, {a:'1'});
// AssertionError: { a: 1 } notDeepEqual { a: '1' }
// AssertionError: { a: 1 } notDeepEqual { a: '1' }

assert.notDeepStrictEqual({a:1}, {a:'1'});
// OK
// OK
```

If the values are deeply and strictly equal, an `AssertionError` is thrown
Expand All @@ -311,13 +317,13 @@ Tests shallow, coercive inequality with the not equal comparison operator
const assert = require('assert');

assert.notEqual(1, 2);
// OK
// OK

assert.notEqual(1, 1);
// AssertionError: 1 != 1
// AssertionError: 1 != 1

assert.notEqual(1, '1');
// AssertionError: 1 != '1'
// AssertionError: 1 != '1'
```

If the values are equal, an `AssertionError` is thrown with a `message`
Expand All @@ -336,13 +342,13 @@ Tests strict inequality as determined by the strict not equal operator
const assert = require('assert');

assert.notStrictEqual(1, 2);
// OK
// OK

assert.notStrictEqual(1, 1);
// AssertionError: 1 != 1
// AssertionError: 1 != 1

assert.notStrictEqual(1, '1');
// OK
// OK
```

If the values are strictly equal, an `AssertionError` is thrown with a
Expand All @@ -364,14 +370,16 @@ parameter is `undefined`, a default error message is assigned.
```js
const assert = require('assert');

assert.ok(true); // OK
assert.ok(1); // OK
assert.ok(true);
// OK
assert.ok(1);
// OK
assert.ok(false);
// throws "AssertionError: false == true"
// throws "AssertionError: false == true"
assert.ok(0);
// throws "AssertionError: 0 == true"
// throws "AssertionError: 0 == true"
assert.ok(false, 'it\'s false');
// throws "AssertionError: it's false"
// throws "AssertionError: it's false"
```

## assert.strictEqual(actual, expected[, message])
Expand All @@ -385,13 +393,13 @@ Tests strict equality as determined by the strict equality operator ( `===` ).
const assert = require('assert');

assert.strictEqual(1, 2);
// AssertionError: 1 === 2
// AssertionError: 1 === 2

assert.strictEqual(1, 1);
// OK
// OK

assert.strictEqual(1, '1');
// AssertionError: 1 === '1'
// AssertionError: 1 === '1'
```

If the values are not strictly equal, an `AssertionError` is thrown with a
Expand Down
14 changes: 7 additions & 7 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ Example:
```js
const buf = new Buffer(5);

// Prints (contents may vary): <Buffer 78 e0 82 02 01>
// Prints: (contents may vary): <Buffer 78 e0 82 02 01>
console.log(buf);

buf.fill(0);
Expand Down Expand Up @@ -525,7 +525,7 @@ Example:
```js
const buf = Buffer.allocUnsafe(5);

// Prints (contents may vary): <Buffer 78 e0 82 02 01>
// Prints: (contents may vary): <Buffer 78 e0 82 02 01>
console.log(buf);

buf.fill(0);
Expand Down Expand Up @@ -1757,12 +1757,12 @@ Examples:
```js
const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);

// Prints <Buffer 01 02 03 04 05 06 07 08>
// Prints: <Buffer 01 02 03 04 05 06 07 08>
console.log(buf1);

buf1.swap32();

// Prints <Buffer 04 03 02 01 08 07 06 05>
// Prints: <Buffer 04 03 02 01 08 07 06 05>
console.log(buf1);


Expand All @@ -1787,12 +1787,12 @@ Examples:
```js
const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);

// Prints <Buffer 01 02 03 04 05 06 07 08>
// Prints: <Buffer 01 02 03 04 05 06 07 08>
console.log(buf1);

buf1.swap64();

// Prints <Buffer 08 07 06 05 04 03 02 01>
// Prints: <Buffer 08 07 06 05 04 03 02 01>
console.log(buf1);


Expand Down Expand Up @@ -2372,7 +2372,7 @@ const SlowBuffer = require('buffer').SlowBuffer;

const buf = new SlowBuffer(5);

// Prints (contents may vary): <Buffer 78 e0 82 02 01>
// Prints: (contents may vary): <Buffer 78 e0 82 02 01>
console.log(buf);

buf.fill(0);
Expand Down
Loading

0 comments on commit 8c6ad91

Please sign in to comment.