Skip to content

Commit 1ef2cf8

Browse files
foxxyzdanielleadams
authored andcommitted
doc: anchor link parity between markdown and html-generated docs
Main changes: - Replace current HTML anchor generation to match header anchor generation in Github markdown. - Remove unnecessary double namespacing on generated anchors/links (E.G. `esm.md#loaders` instead of `esm.md#esm_loaders`). - Anchors/links are automatically prefixed with their respective modules when concatenated for usage in `all.html`. Benefits: - All anchor links within and between markdown API docs actually work. - Adding new anchor links no longer requires contributors to generate the HTML docs first to look up the correct anchors. - Anchors are much shorter. - All previous anchor links are preserved by generating hidden legacy anchors. PR-URL: #39304 Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 6d80a5e commit 1ef2cf8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1498
-1435
lines changed

doc/api/addons.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ in the Node-API are used.
457457

458458
Creating and maintaining an addon that benefits from the ABI stability
459459
provided by Node-API carries with it certain
460-
[implementation considerations](n-api.md#n_api_implications_of_abi_stability).
460+
[implementation considerations][].
461461

462462
To use Node-API in the above "Hello world" example, replace the content of
463463
`hello.cc` with the following. All other instructions remain the same.
@@ -1367,15 +1367,16 @@ console.log(result);
13671367

13681368
[Electron]: https://electronjs.org/
13691369
[Embedder's Guide]: https://github.com/v8/v8/wiki/Embedder's%20Guide
1370-
[Linking to libraries included with Node.js]: #addons_linking_to_libraries_included_with_node_js
1370+
[Linking to libraries included with Node.js]: #linking-to-libraries-included-with-nodejs
13711371
[Native Abstractions for Node.js]: https://github.com/nodejs/nan
13721372
[V8]: https://v8.dev/
1373-
[`Worker`]: worker_threads.md#worker_threads_class_worker
1373+
[`Worker`]: worker_threads.md#class-worker
13741374
[bindings]: https://github.com/TooTallNate/node-bindings
13751375
[download]: https://github.com/nodejs/node-addon-examples
13761376
[examples]: https://github.com/nodejs/nan/tree/HEAD/examples/
1377+
[implementation considerations]: n-api.md#implications-of-abi-stability
13771378
[installation instructions]: https://github.com/nodejs/node-gyp#installation
13781379
[libuv]: https://github.com/libuv/libuv
13791380
[node-gyp]: https://github.com/nodejs/node-gyp
1380-
[require]: modules.md#modules_require_id
1381+
[require]: modules.md#requireid
13811382
[v8-docs]: https://v8docs.nodesource.com/

doc/api/assert.md

+23-22
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ assert.deepEqual([[[1, 2, 3]], 4, 5], [[[1, 2, '3']], 4, 5]);
9999
To deactivate the colors, use the `NO_COLOR` or `NODE_DISABLE_COLORS`
100100
environment variables. This will also deactivate the colors in the REPL. For
101101
more on color support in terminal environments, read the tty
102-
[getColorDepth()](tty.md#tty_writestream_getcolordepth_env) documentation.
102+
[`getColorDepth()`][] documentation.
103103

104104
## Legacy assertion mode
105105

@@ -2420,34 +2420,35 @@ argument.
24202420
[Object.prototype.toString()]: https://tc39.github.io/ecma262/#sec-object.prototype.tostring
24212421
[SameValue Comparison]: https://tc39.github.io/ecma262/#sec-samevalue
24222422
[Strict Equality Comparison]: https://tc39.github.io/ecma262/#sec-strict-equality-comparison
2423-
[`AssertionError`]: #assert_class_assert_assertionerror
2424-
[`CallTracker`]: #assert_class_assert_calltracker
2423+
[`AssertionError`]: #class-assertassertionerror
2424+
[`CallTracker`]: #class-assertcalltracker
24252425
[`Class`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
2426-
[`ERR_INVALID_RETURN_VALUE`]: errors.md#errors_err_invalid_return_value
2427-
[`Error.captureStackTrace`]: errors.md#errors_error_capturestacktrace_targetobject_constructoropt
2428-
[`Error`]: errors.md#errors_class_error
2426+
[`ERR_INVALID_RETURN_VALUE`]: errors.md#err_invalid_return_value
2427+
[`Error.captureStackTrace`]: errors.md#errorcapturestacktracetargetobject-constructoropt
2428+
[`Error`]: errors.md#class-error
24292429
[`Map`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
24302430
[`Object.is()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
24312431
[`RegExp`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
24322432
[`Set`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
24332433
[`Symbol`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol
2434-
[`TypeError`]: errors.md#errors_class_typeerror
2434+
[`TypeError`]: errors.md#class-typeerror
24352435
[`WeakMap`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap
24362436
[`WeakSet`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet
2437-
[`assert.deepEqual()`]: #assert_assert_deepequal_actual_expected_message
2438-
[`assert.deepStrictEqual()`]: #assert_assert_deepstrictequal_actual_expected_message
2439-
[`assert.doesNotThrow()`]: #assert_assert_doesnotthrow_fn_error_message
2440-
[`assert.equal()`]: #assert_assert_equal_actual_expected_message
2441-
[`assert.notDeepEqual()`]: #assert_assert_notdeepequal_actual_expected_message
2442-
[`assert.notDeepStrictEqual()`]: #assert_assert_notdeepstrictequal_actual_expected_message
2443-
[`assert.notEqual()`]: #assert_assert_notequal_actual_expected_message
2444-
[`assert.notStrictEqual()`]: #assert_assert_notstrictequal_actual_expected_message
2445-
[`assert.ok()`]: #assert_assert_ok_value_message
2446-
[`assert.strictEqual()`]: #assert_assert_strictequal_actual_expected_message
2447-
[`assert.throws()`]: #assert_assert_throws_fn_error_message
2448-
[`process.on('exit')`]: process.md#process_event_exit
2449-
[`tracker.calls()`]: #assert_tracker_calls_fn_exact
2450-
[`tracker.verify()`]: #assert_tracker_verify
2437+
[`assert.deepEqual()`]: #assertdeepequalactual-expected-message
2438+
[`assert.deepStrictEqual()`]: #assertdeepstrictequalactual-expected-message
2439+
[`assert.doesNotThrow()`]: #assertdoesnotthrowfn-error-message
2440+
[`assert.equal()`]: #assertequalactual-expected-message
2441+
[`assert.notDeepEqual()`]: #assertnotdeepequalactual-expected-message
2442+
[`assert.notDeepStrictEqual()`]: #assertnotdeepstrictequalactual-expected-message
2443+
[`assert.notEqual()`]: #assertnotequalactual-expected-message
2444+
[`assert.notStrictEqual()`]: #assertnotstrictequalactual-expected-message
2445+
[`assert.ok()`]: #assertokvalue-message
2446+
[`assert.strictEqual()`]: #assertstrictequalactual-expected-message
2447+
[`assert.throws()`]: #assertthrowsfn-error-message
2448+
[`getColorDepth()`]: tty.md#writestreamgetcolordepthenv
2449+
[`process.on('exit')`]: process.md#event-exit
2450+
[`tracker.calls()`]: #trackercallsfn-exact
2451+
[`tracker.verify()`]: #trackerverify
24512452
[enumerable "own" properties]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties
24522453
[prototype-spec]: https://tc39.github.io/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots
2453-
[strict assertion mode]: #assert_strict_assertion_mode
2454+
[strict assertion mode]: #strict-assertion-mode

doc/api/async_context.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -786,8 +786,8 @@ const server = createServer((req, res) => {
786786
}).listen(3000);
787787
```
788788
789-
[`AsyncResource`]: #async_context_class_asyncresource
790-
[`EventEmitter`]: events.md#events_class_eventemitter
791-
[`Stream`]: stream.md#stream_stream
792-
[`Worker`]: worker_threads.md#worker_threads_class_worker
793-
[`util.promisify()`]: util.md#util_util_promisify_original
789+
[`AsyncResource`]: #class-asyncresource
790+
[`EventEmitter`]: events.md#class-eventemitter
791+
[`Stream`]: stream.md#stream
792+
[`Worker`]: worker_threads.md#class-worker
793+
[`util.promisify()`]: util.md#utilpromisifyoriginal

doc/api/async_hooks.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -841,14 +841,14 @@ The documentation for this class has moved [`AsyncResource`][].
841841
842842
The documentation for this class has moved [`AsyncLocalStorage`][].
843843
844-
[Hook Callbacks]: #async_hooks_hook_callbacks
844+
[Hook Callbacks]: #hook-callbacks
845845
[PromiseHooks]: https://docs.google.com/document/d/1rda3yKGHimKIhg5YeoAmCOtyURgsbTH_qaYR79FELlk/edit
846-
[`AsyncLocalStorage`]: async_context.md#async_context_class_asynclocalstorage
847-
[`AsyncResource`]: async_context.md#async_context_class_asyncresource
848-
[`Worker`]: worker_threads.md#worker_threads_class_worker
849-
[`after` callback]: #async_hooks_after_asyncid
850-
[`before` callback]: #async_hooks_before_asyncid
851-
[`destroy` callback]: #async_hooks_destroy_asyncid
852-
[`init` callback]: #async_hooks_init_asyncid_type_triggerasyncid_resource
853-
[`promiseResolve` callback]: #async_hooks_promiseresolve_asyncid
854-
[promise execution tracking]: #async_hooks_promise_execution_tracking
846+
[`AsyncLocalStorage`]: async_context.md#class-asynclocalstorage
847+
[`AsyncResource`]: async_context.md#class-asyncresource
848+
[`Worker`]: worker_threads.md#class-worker
849+
[`after` callback]: #afterasyncid
850+
[`before` callback]: #beforeasyncid
851+
[`destroy` callback]: #destroyasyncid
852+
[`init` callback]: #initasyncid-type-triggerasyncid-resource
853+
[`promiseResolve` callback]: #promiseresolveasyncid
854+
[promise execution tracking]: #promise-execution-tracking

doc/api/buffer.md

+26-26
Original file line numberDiff line numberDiff line change
@@ -5195,19 +5195,19 @@ introducing security vulnerabilities into an application.
51955195
[WHATWG Encoding Standard]: https://encoding.spec.whatwg.org/
51965196
[`ArrayBuffer`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer
51975197
[`Blob`]: https://developer.mozilla.org/en-US/docs/Web/API/Blob
5198-
[`Buffer.alloc()`]: #buffer_static_method_buffer_alloc_size_fill_encoding
5199-
[`Buffer.allocUnsafe()`]: #buffer_static_method_buffer_allocunsafe_size
5200-
[`Buffer.allocUnsafeSlow()`]: #buffer_static_method_buffer_allocunsafeslow_size
5201-
[`Buffer.concat()`]: #buffer_static_method_buffer_concat_list_totallength
5202-
[`Buffer.from(array)`]: #buffer_static_method_buffer_from_array
5203-
[`Buffer.from(arrayBuf)`]: #buffer_static_method_buffer_from_arraybuffer_byteoffset_length
5204-
[`Buffer.from(buffer)`]: #buffer_static_method_buffer_from_buffer
5205-
[`Buffer.from(string)`]: #buffer_static_method_buffer_from_string_encoding
5206-
[`Buffer.poolSize`]: #buffer_class_property_buffer_poolsize
5198+
[`Buffer.alloc()`]: #static-method-bufferallocsize-fill-encoding
5199+
[`Buffer.allocUnsafe()`]: #static-method-bufferallocunsafesize
5200+
[`Buffer.allocUnsafeSlow()`]: #static-method-bufferallocunsafeslowsize
5201+
[`Buffer.concat()`]: #static-method-bufferconcatlist-totallength
5202+
[`Buffer.from(array)`]: #static-method-bufferfromarray
5203+
[`Buffer.from(arrayBuf)`]: #static-method-bufferfromarraybuffer-byteoffset-length
5204+
[`Buffer.from(buffer)`]: #static-method-bufferfrombuffer
5205+
[`Buffer.from(string)`]: #static-method-bufferfromstring-encoding
5206+
[`Buffer.poolSize`]: #class-property-bufferpoolsize
52075207
[`DataView`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
5208-
[`ERR_INVALID_ARG_VALUE`]: errors.md#ERR_INVALID_ARG_VALUE
5209-
[`ERR_INVALID_BUFFER_SIZE`]: errors.md#ERR_INVALID_BUFFER_SIZE
5210-
[`ERR_OUT_OF_RANGE`]: errors.md#ERR_OUT_OF_RANGE
5208+
[`ERR_INVALID_ARG_VALUE`]: errors.md#err_invalid_arg_value
5209+
[`ERR_INVALID_BUFFER_SIZE`]: errors.md#err_invalid_buffer_size
5210+
[`ERR_OUT_OF_RANGE`]: errors.md#err_out_of_range
52115211
[`JSON.stringify()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
52125212
[`SharedArrayBuffer`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer
52135213
[`String.prototype.indexOf()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf
@@ -5219,20 +5219,20 @@ introducing security vulnerabilities into an application.
52195219
[`TypedArray.prototype.subarray()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray
52205220
[`TypedArray`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
52215221
[`Uint8Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
5222-
[`buf.buffer`]: #buffer_buf_buffer
5223-
[`buf.compare()`]: #buffer_buf_compare_target_targetstart_targetend_sourcestart_sourceend
5224-
[`buf.entries()`]: #buffer_buf_entries
5225-
[`buf.fill()`]: #buffer_buf_fill_value_offset_end_encoding
5226-
[`buf.indexOf()`]: #buffer_buf_indexof_value_byteoffset_encoding
5227-
[`buf.keys()`]: #buffer_buf_keys
5228-
[`buf.length`]: #buffer_buf_length
5229-
[`buf.slice()`]: #buffer_buf_slice_start_end
5230-
[`buf.toString()`]: #buffer_buf_tostring_encoding_start_end
5231-
[`buf.values()`]: #buffer_buf_values
5232-
[`buffer.constants.MAX_LENGTH`]: #buffer_buffer_constants_max_length
5233-
[`buffer.constants.MAX_STRING_LENGTH`]: #buffer_buffer_constants_max_string_length
5234-
[`buffer.kMaxLength`]: #buffer_buffer_kmaxlength
5235-
[`util.inspect()`]: util.md#util_util_inspect_object_options
5222+
[`buf.buffer`]: #bufbuffer
5223+
[`buf.compare()`]: #bufcomparetarget-targetstart-targetend-sourcestart-sourceend
5224+
[`buf.entries()`]: #bufentries
5225+
[`buf.fill()`]: #buffillvalue-offset-end-encoding
5226+
[`buf.indexOf()`]: #bufindexofvalue-byteoffset-encoding
5227+
[`buf.keys()`]: #bufkeys
5228+
[`buf.length`]: #buflength
5229+
[`buf.slice()`]: #bufslicestart-end
5230+
[`buf.toString()`]: #buftostringencoding-start-end
5231+
[`buf.values()`]: #bufvalues
5232+
[`buffer.constants.MAX_LENGTH`]: #bufferconstantsmax_length
5233+
[`buffer.constants.MAX_STRING_LENGTH`]: #bufferconstantsmax_string_length
5234+
[`buffer.kMaxLength`]: #bufferkmaxlength
5235+
[`util.inspect()`]: util.md#utilinspectobject-options
52365236
[`v8::TypedArray::kMaxLength`]: https://v8.github.io/api/head/classv8_1_1TypedArray.html#a54a48f4373da0850663c4393d843b9b0
52375237
[base64url]: https://tools.ietf.org/html/rfc4648#section-5
52385238
[binary strings]: https://developer.mozilla.org/en-US/docs/Web/API/DOMString/Binary

doc/api/child_process.md

+38-38
Original file line numberDiff line numberDiff line change
@@ -1772,42 +1772,42 @@ Therefore, this feature requires opting in by setting the
17721772
`serialization` option to `'advanced'` when calling [`child_process.spawn()`][]
17731773
or [`child_process.fork()`][].
17741774

1775-
[Advanced serialization]: #child_process_advanced_serialization
1776-
[Default Windows shell]: #child_process_default_windows_shell
1775+
[Advanced serialization]: #advanced-serialization
1776+
[Default Windows shell]: #default-windows-shell
17771777
[HTML structured clone algorithm]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
1778-
[Shell requirements]: #child_process_shell_requirements
1779-
[Signal Events]: process.md#process_signal_events
1780-
[`'disconnect'`]: process.md#process_event_disconnect
1781-
[`'error'`]: #child_process_event_error
1782-
[`'exit'`]: #child_process_event_exit
1783-
[`'message'`]: process.md#process_event_message
1784-
[`ChildProcess`]: #child_process_class_childprocess
1785-
[`Error`]: errors.md#errors_class_error
1786-
[`EventEmitter`]: events.md#events_class_eventemitter
1787-
[`child_process.exec()`]: #child_process_child_process_exec_command_options_callback
1788-
[`child_process.execFile()`]: #child_process_child_process_execfile_file_args_options_callback
1789-
[`child_process.execFileSync()`]: #child_process_child_process_execfilesync_file_args_options
1790-
[`child_process.execSync()`]: #child_process_child_process_execsync_command_options
1791-
[`child_process.fork()`]: #child_process_child_process_fork_modulepath_args_options
1792-
[`child_process.spawn()`]: #child_process_child_process_spawn_command_args_options
1793-
[`child_process.spawnSync()`]: #child_process_child_process_spawnsync_command_args_options
1794-
[`maxBuffer` and Unicode]: #child_process_maxbuffer_and_unicode
1795-
[`net.Server`]: net.md#net_class_net_server
1796-
[`net.Socket`]: net.md#net_class_net_socket
1797-
[`options.detached`]: #child_process_options_detached
1798-
[`process.disconnect()`]: process.md#process_process_disconnect
1799-
[`process.env`]: process.md#process_process_env
1800-
[`process.execPath`]: process.md#process_process_execpath
1801-
[`process.send()`]: process.md#process_process_send_message_sendhandle_options_callback
1802-
[`stdio`]: #child_process_options_stdio
1803-
[`subprocess.connected`]: #child_process_subprocess_connected
1804-
[`subprocess.disconnect()`]: #child_process_subprocess_disconnect
1805-
[`subprocess.kill()`]: #child_process_subprocess_kill_signal
1806-
[`subprocess.send()`]: #child_process_subprocess_send_message_sendhandle_options_callback
1807-
[`subprocess.stderr`]: #child_process_subprocess_stderr
1808-
[`subprocess.stdin`]: #child_process_subprocess_stdin
1809-
[`subprocess.stdio`]: #child_process_subprocess_stdio
1810-
[`subprocess.stdout`]: #child_process_subprocess_stdout
1811-
[`util.promisify()`]: util.md#util_util_promisify_original
1812-
[synchronous counterparts]: #child_process_synchronous_process_creation
1813-
[v8.serdes]: v8.md#v8_serialization_api
1778+
[Shell requirements]: #shell-requirements
1779+
[Signal Events]: process.md#signal-events
1780+
[`'disconnect'`]: process.md#event-disconnect
1781+
[`'error'`]: #event-error
1782+
[`'exit'`]: #event-exit
1783+
[`'message'`]: process.md#event-message
1784+
[`ChildProcess`]: #class-childprocess
1785+
[`Error`]: errors.md#class-error
1786+
[`EventEmitter`]: events.md#class-eventemitter
1787+
[`child_process.exec()`]: #child_processexeccommand-options-callback
1788+
[`child_process.execFile()`]: #child_processexecfilefile-args-options-callback
1789+
[`child_process.execFileSync()`]: #child_processexecfilesyncfile-args-options
1790+
[`child_process.execSync()`]: #child_processexecsynccommand-options
1791+
[`child_process.fork()`]: #child_processforkmodulepath-args-options
1792+
[`child_process.spawn()`]: #child_processspawncommand-args-options
1793+
[`child_process.spawnSync()`]: #child_processspawnsynccommand-args-options
1794+
[`maxBuffer` and Unicode]: #maxbuffer-and-unicode
1795+
[`net.Server`]: net.md#class-netserver
1796+
[`net.Socket`]: net.md#class-netsocket
1797+
[`options.detached`]: #optionsdetached
1798+
[`process.disconnect()`]: process.md#processdisconnect
1799+
[`process.env`]: process.md#processenv
1800+
[`process.execPath`]: process.md#processexecpath
1801+
[`process.send()`]: process.md#processsendmessage-sendhandle-options-callback
1802+
[`stdio`]: #optionsstdio
1803+
[`subprocess.connected`]: #subprocessconnected
1804+
[`subprocess.disconnect()`]: #subprocessdisconnect
1805+
[`subprocess.kill()`]: #subprocesskillsignal
1806+
[`subprocess.send()`]: #subprocesssendmessage-sendhandle-options-callback
1807+
[`subprocess.stderr`]: #subprocessstderr
1808+
[`subprocess.stdin`]: #subprocessstdin
1809+
[`subprocess.stdio`]: #subprocessstdio
1810+
[`subprocess.stdout`]: #subprocessstdout
1811+
[`util.promisify()`]: util.md#utilpromisifyoriginal
1812+
[synchronous counterparts]: #synchronous-process-creation
1813+
[v8.serdes]: v8.md#serialization-api

0 commit comments

Comments
 (0)