Skip to content

Commit

Permalink
doc: use _Static method_ instead of _Class Method_
Browse files Browse the repository at this point in the history
Our docs describe static methods as Class Methods which seems
idiosyncratic for JavaScript. Align with MDN which calls them static
methods.

Refs: https://developer.mozilla.org/en-US/docs/MDN/Contribute/Structures/API_references/What_does_an_API_reference_need

JSON format for our docs will still use the key name `classMethods` for
this. I would like to change it to `staticMethods` but I don't know if
that will break things for consumers. So, leaving it alone. It's a
machine-consumable label more than a human-readable so I can live with
that.

PR-URL: #34659
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
Trott authored and addaleax committed Sep 22, 2020
1 parent d05f615 commit 14d4bfa
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion doc/api/async_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ class DBQuery extends AsyncResource {
}
```

#### Class Method: `AsyncResource.bind(fn[, type])`
#### Static method: `AsyncResource.bind(fn[, type])`
<!-- YAML
added: REPLACEME
-->
Expand Down
40 changes: 20 additions & 20 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ Additionally, the [`buf.values()`][], [`buf.keys()`][], and
The `Buffer` class is a global type for dealing with binary data directly.
It can be constructed in a variety of ways.

### Class Method: `Buffer.alloc(size[, fill[, encoding]])`
### Static method: `Buffer.alloc(size[, fill[, encoding]])`
<!-- YAML
added: v5.10.0
changes:
Expand Down Expand Up @@ -349,7 +349,7 @@ data that might not have been allocated for `Buffer`s.

A `TypeError` will be thrown if `size` is not a number.

### Class Method: `Buffer.allocUnsafe(size)`
### Static method: `Buffer.allocUnsafe(size)`
<!-- YAML
added: v5.10.0
changes:
Expand Down Expand Up @@ -398,7 +398,7 @@ pool, while `Buffer.allocUnsafe(size).fill(fill)` *will* use the internal
difference is subtle but can be important when an application requires the
additional performance that [`Buffer.allocUnsafe()`][] provides.

### Class Method: `Buffer.allocUnsafeSlow(size)`
### Static method: `Buffer.allocUnsafeSlow(size)`
<!-- YAML
added: v5.12.0
-->
Expand Down Expand Up @@ -446,7 +446,7 @@ socket.on('readable', () => {

A `TypeError` will be thrown if `size` is not a number.

### Class Method: `Buffer.byteLength(string[, encoding])`
### Static method: `Buffer.byteLength(string[, encoding])`
<!-- YAML
added: v0.1.90
changes:
Expand Down Expand Up @@ -485,7 +485,7 @@ When `string` is a `Buffer`/[`DataView`][]/[`TypedArray`][]/[`ArrayBuffer`][]/
[`SharedArrayBuffer`][], the byte length as reported by `.byteLength`
is returned.

### Class Method: `Buffer.compare(buf1, buf2)`
### Static method: `Buffer.compare(buf1, buf2)`
<!-- YAML
added: v0.11.13
changes:
Expand Down Expand Up @@ -513,7 +513,7 @@ console.log(arr.sort(Buffer.compare));
// (This result is equal to: [buf2, buf1].)
```

### Class Method: `Buffer.concat(list[, totalLength])`
### Static method: `Buffer.concat(list[, totalLength])`
<!-- YAML
added: v0.7.11
changes:
Expand Down Expand Up @@ -560,7 +560,7 @@ console.log(bufA.length);
// Prints: 42
```

### Class Method: `Buffer.from(array)`
### Static method: `Buffer.from(array)`
<!-- YAML
added: v5.10.0
-->
Expand All @@ -581,7 +581,7 @@ appropriate for `Buffer.from()` variants.
`Buffer.from(array)` and [`Buffer.from(string)`][] may also use the internal
`Buffer` pool like [`Buffer.allocUnsafe()`][] does.

### Class Method: `Buffer.from(arrayBuffer[, byteOffset[, length]])`
### Static method: `Buffer.from(arrayBuffer[, byteOffset[, length]])`
<!-- YAML
added: v5.10.0
-->
Expand Down Expand Up @@ -632,7 +632,7 @@ A `TypeError` will be thrown if `arrayBuffer` is not an [`ArrayBuffer`][] or a
[`SharedArrayBuffer`][] or another type appropriate for `Buffer.from()`
variants.

### Class Method: `Buffer.from(buffer)`
### Static method: `Buffer.from(buffer)`
<!-- YAML
added: v5.10.0
-->
Expand All @@ -657,7 +657,7 @@ console.log(buf2.toString());
A `TypeError` will be thrown if `buffer` is not a `Buffer` or another type
appropriate for `Buffer.from()` variants.

### Class Method: `Buffer.from(object[, offsetOrEncoding[, length]])`
### Static method: `Buffer.from(object[, offsetOrEncoding[, length]])`
<!-- YAML
added: v8.2.0
-->
Expand Down Expand Up @@ -691,7 +691,7 @@ const buf = Buffer.from(new Foo(), 'utf8');
A `TypeError` will be thrown if `object` does not have the mentioned methods or
is not of another type appropriate for `Buffer.from()` variants.

### Class Method: `Buffer.from(string[, encoding])`
### Static method: `Buffer.from(string[, encoding])`
<!-- YAML
added: v5.10.0
-->
Expand All @@ -717,7 +717,7 @@ console.log(buf1.toString('latin1'));
A `TypeError` will be thrown if `string` is not a string or another type
appropriate for `Buffer.from()` variants.

### Class Method: `Buffer.isBuffer(obj)`
### Static method: `Buffer.isBuffer(obj)`
<!-- YAML
added: v0.1.101
-->
Expand All @@ -727,7 +727,7 @@ added: v0.1.101

Returns `true` if `obj` is a `Buffer`, `false` otherwise.

### Class Method: `Buffer.isEncoding(encoding)`
### Static method: `Buffer.isEncoding(encoding)`
<!-- YAML
added: v0.9.1
-->
Expand Down Expand Up @@ -3198,13 +3198,13 @@ introducing security vulnerabilities into an application.
[RFC 4648, Section 5]: https://tools.ietf.org/html/rfc4648#section-5
[WHATWG Encoding Standard]: https://encoding.spec.whatwg.org/
[`ArrayBuffer`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer
[`Buffer.alloc()`]: #buffer_class_method_buffer_alloc_size_fill_encoding
[`Buffer.allocUnsafe()`]: #buffer_class_method_buffer_allocunsafe_size
[`Buffer.allocUnsafeSlow()`]: #buffer_class_method_buffer_allocunsafeslow_size
[`Buffer.from(array)`]: #buffer_class_method_buffer_from_array
[`Buffer.from(arrayBuf)`]: #buffer_class_method_buffer_from_arraybuffer_byteoffset_length
[`Buffer.from(buffer)`]: #buffer_class_method_buffer_from_buffer
[`Buffer.from(string)`]: #buffer_class_method_buffer_from_string_encoding
[`Buffer.alloc()`]: #buffer_static_method_buffer_alloc_size_fill_encoding
[`Buffer.allocUnsafe()`]: #buffer_static_method_buffer_allocunsafe_size
[`Buffer.allocUnsafeSlow()`]: #buffer_static_method_buffer_allocunsafeslow_size
[`Buffer.from(array)`]: #buffer_static_method_buffer_from_array
[`Buffer.from(arrayBuf)`]: #buffer_static_method_buffer_from_arraybuffer_byteoffset_length
[`Buffer.from(buffer)`]: #buffer_static_method_buffer_from_buffer
[`Buffer.from(string)`]: #buffer_static_method_buffer_from_string_encoding
[`Buffer.poolSize`]: #buffer_class_property_buffer_poolsize
[`DataView`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
[`ERR_INVALID_BUFFER_SIZE`]: errors.html#ERR_INVALID_BUFFER_SIZE
Expand Down
2 changes: 1 addition & 1 deletion doc/api/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));
// OK
```

### Class Method: `ECDH.convertKey(key, curve[, inputEncoding[, outputEncoding[, format]]])`
### Static method: `ECDH.convertKey(key, curve[, inputEncoding[, outputEncoding[, format]]])`
<!-- YAML
added: v10.0.0
-->
Expand Down
16 changes: 8 additions & 8 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2598,10 +2598,10 @@ const moduleParents = Object.values(require.cache)
[`--http-parser=legacy`]: cli.html#cli_http_parser_library
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
[`--throw-deprecation`]: cli.html#cli_throw_deprecation
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array
[`Buffer.from(buffer)`]: buffer.html#buffer_class_method_buffer_from_buffer
[`Buffer.isBuffer()`]: buffer.html#buffer_class_method_buffer_isbuffer_obj
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_static_method_buffer_allocunsafeslow_size
[`Buffer.from(array)`]: buffer.html#buffer_static_method_buffer_from_array
[`Buffer.from(buffer)`]: buffer.html#buffer_static_method_buffer_from_buffer
[`Buffer.isBuffer()`]: buffer.html#buffer_static_method_buffer_isbuffer_obj
[`Cipher`]: crypto.html#crypto_class_cipher
[`Decipher`]: crypto.html#crypto_class_decipher
[`EventEmitter.listenerCount(emitter, eventName)`]: events.html#events_eventemitter_listenercount_emitter_eventname
Expand Down Expand Up @@ -2702,8 +2702,8 @@ const moduleParents = Object.values(require.cache)
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
[WHATWG URL API]: url.html#url_the_whatwg_url_api
[alloc]: buffer.html#buffer_class_method_buffer_alloc_size_fill_encoding
[alloc_unsafe_size]: buffer.html#buffer_class_method_buffer_allocunsafe_size
[from_arraybuffer]: buffer.html#buffer_class_method_buffer_from_arraybuffer_byteoffset_length
[from_string_encoding]: buffer.html#buffer_class_method_buffer_from_string_encoding
[alloc]: buffer.html#buffer_static_method_buffer_alloc_size_fill_encoding
[alloc_unsafe_size]: buffer.html#buffer_static_method_buffer_allocunsafe_size
[from_arraybuffer]: buffer.html#buffer_static_method_buffer_from_arraybuffer_byteoffset_length
[from_string_encoding]: buffer.html#buffer_static_method_buffer_from_string_encoding
[legacy `urlObject`]: url.html#url_legacy_urlobject
2 changes: 1 addition & 1 deletion doc/api/dgram.md
Original file line number Diff line number Diff line change
Expand Up @@ -798,4 +798,4 @@ and `udp6` sockets). The bound address and port can be retrieved using
[`socket.bind()`]: #dgram_socket_bind_port_address_callback
[IPv6 Zone Indices]: https://en.wikipedia.org/wiki/IPv6_address#Scoped_literal_IPv6_addresses
[RFC 4007]: https://tools.ietf.org/html/rfc4007
[byte length]: buffer.html#buffer_class_method_buffer_bytelength_string_encoding
[byte length]: buffer.html#buffer_static_method_buffer_bytelength_string_encoding
2 changes: 1 addition & 1 deletion doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -5710,7 +5710,7 @@ A call to `fs.ftruncate()` or `filehandle.truncate()` can be used to reset
the file contents.

[`AHAFS`]: https://www.ibm.com/developerworks/aix/library/au-aix_event_infrastructure/
[`Buffer.byteLength`]: buffer.html#buffer_class_method_buffer_bytelength_string_encoding
[`Buffer.byteLength`]: buffer.html#buffer_static_method_buffer_bytelength_string_encoding
[`Buffer`]: buffer.html#buffer_buffer
[`FSEvents`]: https://developer.apple.com/documentation/coreservices/file_system_events
[`Number.MAX_SAFE_INTEGER`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
Expand Down
2 changes: 1 addition & 1 deletion doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -2392,7 +2392,7 @@ not abort the request or do anything besides add a `'timeout'` event.
[`'response'`]: #http_event_response
[`'upgrade'`]: #http_event_upgrade
[`Agent`]: #http_class_http_agent
[`Buffer.byteLength()`]: buffer.html#buffer_class_method_buffer_bytelength_string_encoding
[`Buffer.byteLength()`]: buffer.html#buffer_static_method_buffer_bytelength_string_encoding
[`Duplex`]: stream.html#stream_class_stream_duplex
[`TypeError`]: errors.html#errors_class_typeerror
[`URL`]: url.html#url_the_whatwg_url_api
Expand Down
2 changes: 1 addition & 1 deletion doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -2399,7 +2399,7 @@ util.log('Timestamped message.');
[`Array.isArray()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
[`ArrayBuffer.isView()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView
[`ArrayBuffer`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer
[`Buffer.isBuffer()`]: buffer.html#buffer_class_method_buffer_isbuffer_obj
[`Buffer.isBuffer()`]: buffer.html#buffer_static_method_buffer_isbuffer_obj
[`DataView`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
[`Date`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
[`Error`]: errors.html#errors_class_error
Expand Down
2 changes: 1 addition & 1 deletion doc/api/worker_threads.md
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ active handle in the event system. If the worker is already `unref()`ed calling
[`'exit'` event]: #worker_threads_event_exit
[`AsyncResource`]: async_hooks.html#async_hooks_class_asyncresource
[`Buffer`]: buffer.html
[`Buffer.allocUnsafe()`]: buffer.html#buffer_class_method_buffer_allocunsafe_size
[`Buffer.allocUnsafe()`]: buffer.html#buffer_static_method_buffer_allocunsafe_size
[`ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST`]: errors.html#errors_err_missing_message_port_in_transfer_list
[`ERR_WORKER_NOT_RUNNING`]: errors.html#ERR_WORKER_NOT_RUNNING
[`EventEmitter`]: events.html
Expand Down
6 changes: 3 additions & 3 deletions test/doctool/test-doctool-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ function toHTML({ input, filename, nodeVersion, versions }) {
const testData = [
{
file: fixtures.path('order_of_end_tags_5873.md'),
html: '<h3>ClassMethod: Buffer.from(array) <span> ' +
'<a class="mark" href="#foo_class_method_buffer_from_array" ' +
'id="foo_class_method_buffer_from_array">#</a> </span> </h3>' +
html: '<h3>Static method: Buffer.from(array) <span> ' +
'<a class="mark" href="#foo_static_method_buffer_from_array" ' +
'id="foo_static_method_buffer_from_array">#</a> </span> </h3>' +
'<ul><li><code>array</code><a ' +
'href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/' +
'Reference/Global_Objects/Array" class="type">&#x3C;Array></a></li></ul>'
Expand Down
4 changes: 2 additions & 2 deletions test/doctool/test-doctool-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const testData = [
textRaw: 'Subsection',
name: 'subsection',
classMethods: [{
textRaw: 'Class Method: Buffer.from(array)',
textRaw: 'Static method: Buffer.from(array)',
type: 'classMethod',
name: 'from',
signatures: [
Expand Down Expand Up @@ -181,7 +181,7 @@ const testData = [
params: []
}
],
textRaw: 'Class Method: `Fhqwhgads.again()`',
textRaw: 'Static method: `Fhqwhgads.again()`',
type: 'classMethod'
}
],
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/doc_with_backticks_in_headings.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

## Constructor: `new Fhqwhgads()`

## Class Method: `Fhqwhgads.again()`
## Static method: `Fhqwhgads.again()`

## `Fqhqwhgads.fullName`
2 changes: 1 addition & 1 deletion test/fixtures/order_of_end_tags_5873.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

## Subsection

### Class Method: Buffer.from(array)
### Static method: Buffer.from(array)
* `array` {Array}
2 changes: 1 addition & 1 deletion tools/doc/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ const r = String.raw;
const eventPrefix = '^Event: +';
const classPrefix = '^[Cc]lass: +';
const ctorPrefix = '^(?:[Cc]onstructor: +)?`?new +';
const classMethodPrefix = '^Class Method: +';
const classMethodPrefix = '^Static method: +';
const maybeClassPropertyPrefix = '(?:Class Property: +)?';

const maybeQuote = '[\'"]?';
Expand Down

0 comments on commit 14d4bfa

Please sign in to comment.