Skip to content

Commit 14d4bfa

Browse files
Trottaddaleax
authored andcommitted
doc: use _Static method_ instead of _Class Method_
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent d05f615 commit 14d4bfa

14 files changed

+43
-43
lines changed

doc/api/async_hooks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ class DBQuery extends AsyncResource {
733733
}
734734
```
735735

736-
#### Class Method: `AsyncResource.bind(fn[, type])`
736+
#### Static method: `AsyncResource.bind(fn[, type])`
737737
<!-- YAML
738738
added: REPLACEME
739739
-->

doc/api/buffer.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ Additionally, the [`buf.values()`][], [`buf.keys()`][], and
284284
The `Buffer` class is a global type for dealing with binary data directly.
285285
It can be constructed in a variety of ways.
286286

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

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

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

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

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

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

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

516-
### Class Method: `Buffer.concat(list[, totalLength])`
516+
### Static method: `Buffer.concat(list[, totalLength])`
517517
<!-- YAML
518518
added: v0.7.11
519519
changes:
@@ -560,7 +560,7 @@ console.log(bufA.length);
560560
// Prints: 42
561561
```
562562

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

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

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

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

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

720-
### Class Method: `Buffer.isBuffer(obj)`
720+
### Static method: `Buffer.isBuffer(obj)`
721721
<!-- YAML
722722
added: v0.1.101
723723
-->
@@ -727,7 +727,7 @@ added: v0.1.101
727727

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

730-
### Class Method: `Buffer.isEncoding(encoding)`
730+
### Static method: `Buffer.isEncoding(encoding)`
731731
<!-- YAML
732732
added: v0.9.1
733733
-->
@@ -3198,13 +3198,13 @@ introducing security vulnerabilities into an application.
31983198
[RFC 4648, Section 5]: https://tools.ietf.org/html/rfc4648#section-5
31993199
[WHATWG Encoding Standard]: https://encoding.spec.whatwg.org/
32003200
[`ArrayBuffer`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer
3201-
[`Buffer.alloc()`]: #buffer_class_method_buffer_alloc_size_fill_encoding
3202-
[`Buffer.allocUnsafe()`]: #buffer_class_method_buffer_allocunsafe_size
3203-
[`Buffer.allocUnsafeSlow()`]: #buffer_class_method_buffer_allocunsafeslow_size
3204-
[`Buffer.from(array)`]: #buffer_class_method_buffer_from_array
3205-
[`Buffer.from(arrayBuf)`]: #buffer_class_method_buffer_from_arraybuffer_byteoffset_length
3206-
[`Buffer.from(buffer)`]: #buffer_class_method_buffer_from_buffer
3207-
[`Buffer.from(string)`]: #buffer_class_method_buffer_from_string_encoding
3201+
[`Buffer.alloc()`]: #buffer_static_method_buffer_alloc_size_fill_encoding
3202+
[`Buffer.allocUnsafe()`]: #buffer_static_method_buffer_allocunsafe_size
3203+
[`Buffer.allocUnsafeSlow()`]: #buffer_static_method_buffer_allocunsafeslow_size
3204+
[`Buffer.from(array)`]: #buffer_static_method_buffer_from_array
3205+
[`Buffer.from(arrayBuf)`]: #buffer_static_method_buffer_from_arraybuffer_byteoffset_length
3206+
[`Buffer.from(buffer)`]: #buffer_static_method_buffer_from_buffer
3207+
[`Buffer.from(string)`]: #buffer_static_method_buffer_from_string_encoding
32083208
[`Buffer.poolSize`]: #buffer_class_property_buffer_poolsize
32093209
[`DataView`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
32103210
[`ERR_INVALID_BUFFER_SIZE`]: errors.html#ERR_INVALID_BUFFER_SIZE

doc/api/crypto.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));
786786
// OK
787787
```
788788

789-
### Class Method: `ECDH.convertKey(key, curve[, inputEncoding[, outputEncoding[, format]]])`
789+
### Static method: `ECDH.convertKey(key, curve[, inputEncoding[, outputEncoding[, format]]])`
790790
<!-- YAML
791791
added: v10.0.0
792792
-->

doc/api/deprecations.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2598,10 +2598,10 @@ const moduleParents = Object.values(require.cache)
25982598
[`--http-parser=legacy`]: cli.html#cli_http_parser_library
25992599
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
26002600
[`--throw-deprecation`]: cli.html#cli_throw_deprecation
2601-
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
2602-
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array
2603-
[`Buffer.from(buffer)`]: buffer.html#buffer_class_method_buffer_from_buffer
2604-
[`Buffer.isBuffer()`]: buffer.html#buffer_class_method_buffer_isbuffer_obj
2601+
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_static_method_buffer_allocunsafeslow_size
2602+
[`Buffer.from(array)`]: buffer.html#buffer_static_method_buffer_from_array
2603+
[`Buffer.from(buffer)`]: buffer.html#buffer_static_method_buffer_from_buffer
2604+
[`Buffer.isBuffer()`]: buffer.html#buffer_static_method_buffer_isbuffer_obj
26052605
[`Cipher`]: crypto.html#crypto_class_cipher
26062606
[`Decipher`]: crypto.html#crypto_class_decipher
26072607
[`EventEmitter.listenerCount(emitter, eventName)`]: events.html#events_eventemitter_listenercount_emitter_eventname
@@ -2702,8 +2702,8 @@ const moduleParents = Object.values(require.cache)
27022702
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
27032703
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
27042704
[WHATWG URL API]: url.html#url_the_whatwg_url_api
2705-
[alloc]: buffer.html#buffer_class_method_buffer_alloc_size_fill_encoding
2706-
[alloc_unsafe_size]: buffer.html#buffer_class_method_buffer_allocunsafe_size
2707-
[from_arraybuffer]: buffer.html#buffer_class_method_buffer_from_arraybuffer_byteoffset_length
2708-
[from_string_encoding]: buffer.html#buffer_class_method_buffer_from_string_encoding
2705+
[alloc]: buffer.html#buffer_static_method_buffer_alloc_size_fill_encoding
2706+
[alloc_unsafe_size]: buffer.html#buffer_static_method_buffer_allocunsafe_size
2707+
[from_arraybuffer]: buffer.html#buffer_static_method_buffer_from_arraybuffer_byteoffset_length
2708+
[from_string_encoding]: buffer.html#buffer_static_method_buffer_from_string_encoding
27092709
[legacy `urlObject`]: url.html#url_legacy_urlobject

doc/api/dgram.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,4 +798,4 @@ and `udp6` sockets). The bound address and port can be retrieved using
798798
[`socket.bind()`]: #dgram_socket_bind_port_address_callback
799799
[IPv6 Zone Indices]: https://en.wikipedia.org/wiki/IPv6_address#Scoped_literal_IPv6_addresses
800800
[RFC 4007]: https://tools.ietf.org/html/rfc4007
801-
[byte length]: buffer.html#buffer_class_method_buffer_bytelength_string_encoding
801+
[byte length]: buffer.html#buffer_static_method_buffer_bytelength_string_encoding

doc/api/fs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5710,7 +5710,7 @@ A call to `fs.ftruncate()` or `filehandle.truncate()` can be used to reset
57105710
the file contents.
57115711

57125712
[`AHAFS`]: https://www.ibm.com/developerworks/aix/library/au-aix_event_infrastructure/
5713-
[`Buffer.byteLength`]: buffer.html#buffer_class_method_buffer_bytelength_string_encoding
5713+
[`Buffer.byteLength`]: buffer.html#buffer_static_method_buffer_bytelength_string_encoding
57145714
[`Buffer`]: buffer.html#buffer_buffer
57155715
[`FSEvents`]: https://developer.apple.com/documentation/coreservices/file_system_events
57165716
[`Number.MAX_SAFE_INTEGER`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER

doc/api/http.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2392,7 +2392,7 @@ not abort the request or do anything besides add a `'timeout'` event.
23922392
[`'response'`]: #http_event_response
23932393
[`'upgrade'`]: #http_event_upgrade
23942394
[`Agent`]: #http_class_http_agent
2395-
[`Buffer.byteLength()`]: buffer.html#buffer_class_method_buffer_bytelength_string_encoding
2395+
[`Buffer.byteLength()`]: buffer.html#buffer_static_method_buffer_bytelength_string_encoding
23962396
[`Duplex`]: stream.html#stream_class_stream_duplex
23972397
[`TypeError`]: errors.html#errors_class_typeerror
23982398
[`URL`]: url.html#url_the_whatwg_url_api

doc/api/util.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2399,7 +2399,7 @@ util.log('Timestamped message.');
23992399
[`Array.isArray()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
24002400
[`ArrayBuffer.isView()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView
24012401
[`ArrayBuffer`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer
2402-
[`Buffer.isBuffer()`]: buffer.html#buffer_class_method_buffer_isbuffer_obj
2402+
[`Buffer.isBuffer()`]: buffer.html#buffer_static_method_buffer_isbuffer_obj
24032403
[`DataView`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
24042404
[`Date`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
24052405
[`Error`]: errors.html#errors_class_error

doc/api/worker_threads.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ active handle in the event system. If the worker is already `unref()`ed calling
801801
[`'exit'` event]: #worker_threads_event_exit
802802
[`AsyncResource`]: async_hooks.html#async_hooks_class_asyncresource
803803
[`Buffer`]: buffer.html
804-
[`Buffer.allocUnsafe()`]: buffer.html#buffer_class_method_buffer_allocunsafe_size
804+
[`Buffer.allocUnsafe()`]: buffer.html#buffer_static_method_buffer_allocunsafe_size
805805
[`ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST`]: errors.html#errors_err_missing_message_port_in_transfer_list
806806
[`ERR_WORKER_NOT_RUNNING`]: errors.html#ERR_WORKER_NOT_RUNNING
807807
[`EventEmitter`]: events.html

test/doctool/test-doctool-html.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ function toHTML({ input, filename, nodeVersion, versions }) {
6060
const testData = [
6161
{
6262
file: fixtures.path('order_of_end_tags_5873.md'),
63-
html: '<h3>ClassMethod: Buffer.from(array) <span> ' +
64-
'<a class="mark" href="#foo_class_method_buffer_from_array" ' +
65-
'id="foo_class_method_buffer_from_array">#</a> </span> </h3>' +
63+
html: '<h3>Static method: Buffer.from(array) <span> ' +
64+
'<a class="mark" href="#foo_static_method_buffer_from_array" ' +
65+
'id="foo_static_method_buffer_from_array">#</a> </span> </h3>' +
6666
'<ul><li><code>array</code><a ' +
6767
'href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/' +
6868
'Reference/Global_Objects/Array" class="type">&#x3C;Array></a></li></ul>'

test/doctool/test-doctool-json.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const testData = [
6969
textRaw: 'Subsection',
7070
name: 'subsection',
7171
classMethods: [{
72-
textRaw: 'Class Method: Buffer.from(array)',
72+
textRaw: 'Static method: Buffer.from(array)',
7373
type: 'classMethod',
7474
name: 'from',
7575
signatures: [
@@ -181,7 +181,7 @@ const testData = [
181181
params: []
182182
}
183183
],
184-
textRaw: 'Class Method: `Fhqwhgads.again()`',
184+
textRaw: 'Static method: `Fhqwhgads.again()`',
185185
type: 'classMethod'
186186
}
187187
],

test/fixtures/doc_with_backticks_in_headings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88

99
## Constructor: `new Fhqwhgads()`
1010

11-
## Class Method: `Fhqwhgads.again()`
11+
## Static method: `Fhqwhgads.again()`
1212

1313
## `Fqhqwhgads.fullName`

test/fixtures/order_of_end_tags_5873.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
## Subsection
44

5-
### Class Method: Buffer.from(array)
5+
### Static method: Buffer.from(array)
66
* `array` {Array}

tools/doc/json.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ const r = String.raw;
436436
const eventPrefix = '^Event: +';
437437
const classPrefix = '^[Cc]lass: +';
438438
const ctorPrefix = '^(?:[Cc]onstructor: +)?`?new +';
439-
const classMethodPrefix = '^Class Method: +';
439+
const classMethodPrefix = '^Static method: +';
440440
const maybeClassPropertyPrefix = '(?:Class Property: +)?';
441441

442442
const maybeQuote = '[\'"]?';

0 commit comments

Comments
 (0)