Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
200 commits
Select commit Hold shift + click to select a range
b2e6048
child_process: validate arguments for null bytes
RaisinTen Oct 14, 2022
824dcfc
src: return void in InitializeInspector()
joyeecheung Oct 14, 2022
c45b6ae
bootstrap: merge main thread and worker thread initializations
joyeecheung Oct 14, 2022
c3dd696
events: add unique events benchmark
anonrig Sep 15, 2022
8199841
lib: support more attributes for early hint link
anonrig Oct 14, 2022
edb92f4
doc: add anonrig to collaborators
anonrig Oct 14, 2022
c59d3b7
test: refactor promises to async/await
sonimadhuri Oct 14, 2022
ffba321
doc: add info on fixup to security release process
mhdawson Sep 27, 2022
a618dc3
test: use CHECK instead of EXPECT where necessary
tniessen Sep 26, 2022
f0c18f0
doc: fix undici version in changelog
mhdawson Oct 12, 2022
4825786
test: improve test coverage in `test-child-process-spawn-argv0.js`
juanarbol Oct 14, 2022
ea0cfc9
test: add test to improve coverage in http2-compat-serverresponse
Cesar-M-Diaz Oct 14, 2022
17ef1bb
lib: make properties on Blob and URL enumerable
KhafraDev Oct 14, 2022
cc2393c
lib: promise version of streams.finished call clean up
ntedgi Oct 15, 2022
5fce8e3
src: iwyu in cleanup_queue.cc
codebytere Oct 15, 2022
3519d74
test: improve test coverage for `os` package
juanarbol Oct 15, 2022
43677e5
test: skip test depending on `overlapped-checker` when not available
aduh95 Oct 15, 2022
e6bbc50
doc: improve the workflow to test release binaries
RafaelGSS Oct 15, 2022
7900810
meta: update AUTHORS
nodejs-github-bot Oct 16, 2022
025e616
tools: update lint-md-dependencies
nodejs-github-bot Oct 16, 2022
02cff4a
url: improve url.parse() compliance with WHATWG URL
Trott Oct 17, 2022
d47f832
doc: run license-builder
github-actions[bot] Oct 17, 2022
84e7388
url: improve port validation
Trott Oct 17, 2022
c1ca19f
test: update WPT resources
XadillaX Oct 10, 2022
a27c994
benchmark: add blob benchmark
anonrig Oct 17, 2022
5fbccae
doc: fix http and http2 writeEarlyHints() parameter
meyfa Oct 17, 2022
8b4a41e
lib: fix typo in `pre_execution.js`
aduh95 Oct 17, 2022
e8103fd
doc: updated security stewards
mhdawson Oct 14, 2022
24e24bd
build: add version info to timezone update PR
RaisinTen Oct 18, 2022
dbc696d
test: remove unnecessary noop function args to mustCall()
Trott Oct 18, 2022
3bfba6d
deps: patch V8 to 10.7.193.16
targos Oct 18, 2022
71b8d50
test: improve assertions in `test-repl-unsupported-option.js`
juanarbol Oct 18, 2022
2f7518a
deps: update timezone
nodejs-github-bot Oct 18, 2022
8662399
test: remove mentions of `--experimental-async-stack-tagging-api` flag
szuend Oct 18, 2022
2105f09
node-api,test: fix test_reference_double_free crash
vmoroz Oct 8, 2022
9ed9aa8
lib: add ability to add separate event name to defineEventHandler
jasnell Oct 19, 2022
d41f8ff
util: add MIME utilities (#21128)
bmeck Oct 19, 2022
a70b276
tools: do not use the set-output command in workflows
lpinca Oct 19, 2022
2ccc03e
tools: update gr2m/create-or-update-pull-request-action
lpinca Oct 19, 2022
8abc3f7
http: add priority to common http headers
jasnell Oct 17, 2022
17349a2
build: restore Windows resource file
richardlau Oct 19, 2022
2e5d8e7
esm: protect ESM loader from prototype pollution
aduh95 Oct 19, 2022
3db37e7
inspector: refactor `inspector/promises` to be more robust
aduh95 Oct 19, 2022
ec86830
meta: move one or more collaborators to emeritus
nodejs-github-bot Oct 19, 2022
9dc21a1
src: simplify ALPN code, remove indirection
bnoordhuis Oct 3, 2022
e5b1179
src: optimize ALPN callback
bnoordhuis Oct 3, 2022
b4bedde
doc: fix typo in parseArgs default value
tniessen Oct 20, 2022
26a2ae2
test: wrap missing `common.mustCall`
MoLow Oct 20, 2022
82e6043
test: mark test-watch-mode* as flaky on all platforms
pbo-linaro Oct 20, 2022
f0480d6
test: remove unnecessary noop function args to `mustCall()`
aduh95 Oct 20, 2022
17e86e4
test: remove experimental-wasm-threads flag
targos Oct 20, 2022
162bf0d
src: fix test runner coverage
MoLow Oct 20, 2022
a8412f5
src: forbid running watch mode in REPL
MoLow Oct 20, 2022
93a34fa
doc: update Node.js 16 End-of-Life date
richardlau Oct 21, 2022
c7b7f2b
lib: add lint rule to protect against `Object.prototype.then` pollution
aduh95 Oct 21, 2022
36acf8a
net: remove _readableState from debug statement
Trott Oct 21, 2022
66e1dc4
report,doc: define report version semantics
gireeshpunathil Oct 21, 2022
533e38b
doc: mark Node.js v17.x as EOL
climba03003 Oct 21, 2022
3e4033a
doc: fix display of "problematic" ASCII characters
Alhadis Oct 21, 2022
ee34a3a
doc: mention v18.x openssl maintaining guide
RafaelGSS Oct 21, 2022
9d449d3
doc: add note about latest GitHub release
targos Oct 22, 2022
809e8dc
doc: fix v14.x link maintaining openssl guide
RafaelGSS Oct 19, 2022
1655532
stream: don't push null from closed promise #42694
davedoesdev Oct 22, 2022
2b3b291
test: watch mode inspect restart repeatedly
MoLow Oct 22, 2022
5190021
doc: add major version note to release guide
ruyadorno Oct 18, 2022
c23e023
doc: be more definite and present tense-y
bnoordhuis Oct 23, 2022
7a31ae8
src,lib: retrieve parsed source map url from v8
legendecas Sep 26, 2022
732f9a7
trace_events: fix getCategories
theanarkh Oct 24, 2022
a2620ac
report: add rss and use/kernel cpu usage fields
theanarkh Oct 24, 2022
4e14ed8
src: remove unused `contextify_global_private_symbol`
daeyeon Oct 24, 2022
85cb4d7
doc: update mark release line lts on release guide
ruyadorno Oct 24, 2022
1bc84ce
url: remove \t \n \r in url.parse() similar to WHATWG
Trott Oct 24, 2022
0a6ed6f
Revert "deps: V8: forward declaration of `Rtl*FunctionTable`"
targos Oct 25, 2022
94b7f53
http2: fix debugStream method
santigimeno Oct 25, 2022
fabed9b
test: add test for Module._stat
RaisinTen Oct 25, 2022
c43bc21
tools: fix `create-or-update-pull-request-action` hash on GHA
aduh95 Oct 25, 2022
1635140
http2: fix crash on Http2Stream::diagnostic_name()
santigimeno Oct 25, 2022
8cda730
deps: update ICU to 72.1
targos Oct 25, 2022
b5baaa6
dns: fix port validation
aduh95 Oct 25, 2022
3a26347
doc: add lukekarrys to collaborators
lukekarrys Oct 25, 2022
b39dcde
test: remove a snapshot blob from test-inspect-address-in-use.js
daeyeon Oct 26, 2022
ff174b0
test_runner: add extra fields in AssertionError YAML
bengl Oct 26, 2022
3a1ee94
build: add GitHub token to auto-start-ci workflow
richardlau Oct 26, 2022
316354e
http2: improve session close/destroy procedures
santigimeno Oct 26, 2022
3c7ea23
test: fix typo in `test/parallel/test-fs-rm.js`
TimShilov Oct 26, 2022
54d8068
doc: mark Node.js 12 as End-of-Life
RafaelGSS Oct 26, 2022
bc0ae3e
stream: fix web streams have no Symbol.toStringTag
MrJithil Oct 26, 2022
a415869
tools: update V8 gypfiles for RISC-V
andreas-schwab Oct 26, 2022
8d56822
src: remap invalid file descriptors using `dup2`
obiwac Oct 26, 2022
d89ca1b
fs: trace more fs api
theanarkh Oct 26, 2022
916e876
doc: add link to triage guide
bmuenzenmeyer Oct 26, 2022
afa8291
test_runner: call {before,after}Each() on suites
cjihrig Oct 27, 2022
f589961
Revert "deps: make V8 compilable with older glibc"
targos Oct 27, 2022
5335e29
src: let http2 streams end after session close
santigimeno Oct 27, 2022
29b9f4f
build: remove unused language files
bnoordhuis Oct 23, 2022
36c5927
test,crypto: update WebCryptoAPI WPT
panva Oct 25, 2022
de2df55
doc: update process.release
panva Oct 25, 2022
8f8d7e7
doc: add bmuenzenmeyer to triagers
bmuenzenmeyer Oct 24, 2022
243c141
src: clarify OptionEnvvarSettings member names
legendecas Oct 27, 2022
f9bc40a
test: use uv_sleep() where possible
santigimeno Oct 27, 2022
f598edb
build: fix icu-small build with ICU 72.1
srl295 Oct 27, 2022
6e30d22
tools: update actions/setup-python to v4
anonrig Oct 27, 2022
40a5e22
esm: protect ESM loader from prototype pollution
aduh95 Oct 27, 2022
58bec56
doc: add more lts update steps to release guide
ruyadorno Oct 27, 2022
e60d905
stream: fix duplexify premature destroy
ronag Oct 23, 2022
dfe4237
perf_hooks: align toStringTag with other Web Performance implementations
daeyeon Oct 27, 2022
7225a7d
doc, http: add Uint8Array as allowed type
Flarna Oct 27, 2022
c179c14
doc: change make lint to make lint-md
RafaelGSS Oct 27, 2022
75e0a2d
build: workaround for node-core-utils
gengjiawen Oct 28, 2022
ad9a5bb
meta: move a collaborator to emeritus
Trott Oct 28, 2022
49be13c
tools: keep Emeriti lists case-insensitive alphabetic
Trott Oct 28, 2022
02ebde3
test: use common/tmpdir in watch-mode ipc test
richardlau Oct 28, 2022
0738d14
tools: fix `request-ci-failed` comment
aduh95 Oct 28, 2022
d9163f1
doc: clarify moderation in `onboarding.md`
benjamingr Oct 28, 2022
ddb7df7
test: deflake test-http2-empty-frame-without-eof
santigimeno Oct 27, 2022
7b938df
build: support Python 3.11
lpinca Oct 26, 2022
786f086
tools: use Python 3.11 in GitHub Actions workflows
lpinca Oct 26, 2022
069747b
test: fix timeout of test-heap-prof.js in riscv devices
Oct 29, 2022
b9039a5
doc: add history section to `fetch`-related globals
aduh95 Oct 29, 2022
aa4152a
src: fix `crypto.privateEncrypt` fails first time
liuxingbaoyu Oct 29, 2022
eed799b
test: improve test coverage in `test-event-capture-rejections.js`
juanarbol Oct 29, 2022
0040030
test_runner: report tap subtest in order
MoLow Oct 28, 2022
0d24163
deps: update undici to 5.12.0
nodejs-github-bot Oct 30, 2022
0d41df9
deps: update corepack to 0.15.0
nodejs-github-bot Oct 30, 2022
b41b5ba
meta: update AUTHORS
nodejs-github-bot Oct 30, 2022
42db849
src: call uv_library_shutdown before DisposePlatform
theanarkh Oct 28, 2022
0d58bb9
meta: remove dont-land-on-v12 auto labeling
MoLow Oct 30, 2022
f10f2c1
test: fix textdecoder test for small-icu builds
richardlau Oct 30, 2022
d7470ad
lib: fix `AbortSignal.timeout` parameter validation
dnalborczyk Oct 31, 2022
ccb1c1e
stream: add compose operator
rluvaton Oct 31, 2022
bfbfaca
meta: fix email address typo in README
Trott Oct 31, 2022
ba89cea
tools: update lint-md-dependencies
nodejs-github-bot Oct 31, 2022
1a04881
http: headers(Distinct), trailers(Distinct) setters to be no-op
sonimadhuri Oct 31, 2022
738144c
module: ensure relative requires work from deleted directories
bmeck Oct 31, 2022
97547bc
src: lock-free init_process_flags
kapouer Oct 31, 2022
34bfef9
fs: add recursive watch to linux
anonrig Oct 31, 2022
3369120
buffer: fix validation of options in `Blob` constructor
aduh95 Oct 31, 2022
670def3
fs: fix opts.filter issue in cpSync
thoqbk Nov 1, 2022
3e46ebd
src: trace threadpool event
theanarkh Nov 1, 2022
a866e8c
meta: update collaborator email address in README
Trott Nov 1, 2022
7428651
test: convert test-debugger-pid to async/await
lukekarrys Nov 1, 2022
e118dd8
tools: refactor dynamic strings creation in shell scripts
aduh95 Nov 1, 2022
daff3b8
fs: update todo message
anonrig Nov 1, 2022
8d7aa53
build,win: pass --debug-nghttp2 to configure
santigimeno Oct 27, 2022
5d48011
src: print nghttp2 logs when using --debug-nghttp2
santigimeno Oct 27, 2022
d5f4d98
test: make `test-eventemitter-asyncresource.js` shorter
juanarbol Nov 1, 2022
d172669
lib: fix TypeError when converting a detached buffer source
cola119 Nov 1, 2022
9d15da3
report: add more memory info
theanarkh Nov 2, 2022
7d7e7c3
doc: fix "task_processor.js" typo
Nov 3, 2022
2ee052f
tools: fix `request-ci-failed` comment
aduh95 Nov 3, 2022
b4b6b95
doc: update name of Node.js core Slack channel
Trott Nov 3, 2022
4e45585
src: revert is_release to 0
RafaelGSS Nov 4, 2022
9f3d2f6
lib: drop fetch experimental warning
mcollina Nov 5, 2022
2fcf851
os: convert uid and gid to 32-bit signed integers
lpinca Mar 16, 2022
43db0fb
test: fix test-socket-write-after-fin-error
lpinca Jul 12, 2022
7435284
lib: use process.nextTick() instead of setImmediate()
lpinca Sep 29, 2022
66e7821
test: defer invocation checks
lpinca Oct 25, 2022
bfe3819
deps: upgrade to libuv 1.44.2
lpinca Mar 15, 2022
4d38bf2
doc: add `node:` prefix for examples
daeyeon Nov 5, 2022
eda4ae5
tools: add automation for updating base64 dependency
facutuesca Nov 6, 2022
88c3bb6
meta: update AUTHORS
nodejs-github-bot Nov 6, 2022
44de232
deps: patch V8 to 10.7.193.20
targos Nov 6, 2022
5a1252d
doc: use module names in stability overview table
panva Nov 6, 2022
3de1257
doc: add more info for timer.setInterval
theanarkh Nov 6, 2022
97fe8ba
tools: increase macOS cores to 3 on GitHub CI
Trott Nov 6, 2022
0deed8d
util: improve textdecoder decode performance
anonrig Nov 6, 2022
326d19a
src: resolve TODO related to inspector CVEs
tniessen Nov 6, 2022
e275859
tools: fix stability index generation
aduh95 Nov 7, 2022
f35d562
deps: update corepack to 0.15.1
nodejs-github-bot Nov 7, 2022
a7c5f31
doc: run license-builder
github-actions[bot] Nov 7, 2022
63267df
tools: update lint-md-dependencies to [email protected]
nodejs-github-bot Nov 7, 2022
8e7f9de
test_runner: fix afterEach not running on test failures
MrJithil Nov 7, 2022
13fb05e
crypto: handle unsupported AES ciphers in webcrypto
panva Nov 7, 2022
1f0edde
crypto: handle more webcrypto errors with OperationError
panva Nov 7, 2022
a8e9015
lib: fix JSDoc issues
Trott Oct 30, 2022
4b71db1
tools: update eslint to 8.26.0
nodejs-github-bot Oct 30, 2022
920804d
test_runner: avoid swallowing of asynchronously thrown errors
fossamagna Nov 7, 2022
1432474
deps: upgrade npm to 8.19.3
npm-cli-bot Nov 7, 2022
4a80aff
test: fix catching failed assertion
pavelhoral Nov 7, 2022
d5e5c75
doc: fix test runner's only tests section header
cjihrig Nov 7, 2022
717db1d
test: skip test-fs-largefile if not enough disk space
Trott Nov 6, 2022
86e22b4
src: track contexts in the Environment instead of AsyncHooks
joyeecheung Nov 7, 2022
6158d74
test_runner: support function mocking
cjihrig Apr 4, 2022
aa875a4
tools: update eslint to 8.27.0
nodejs-github-bot Nov 8, 2022
c168cbf
deps: V8: cherry-pick 56816d76c121
shipujin Nov 8, 2022
ba45373
doc: fix email for Ashley
mhdawson Nov 8, 2022
0478e40
lib: add options to the heap snapshot APIs
joyeecheung Oct 13, 2022
d4aabb9
doc: include last security release date
juanarbol Nov 7, 2022
0e9bad9
doc: allow for holidays in triage response
mhdawson Nov 1, 2022
bf868fd
tls: add "ca" property to certificate object
bnoordhuis Nov 9, 2022
79f6bb0
benchmark: fix text-decoder benchmark
anonrig Nov 7, 2022
c9cf399
benchmark: add parameters to text-decoder benchmark
anonrig Nov 7, 2022
89390a6
util: improve text-decoder performance
anonrig Nov 7, 2022
76cbc07
tools: allow scripts to run from anywhere
lpinca Nov 9, 2022
9aa305f
tools: add documentation regarding our api tooling
ovflowd Nov 1, 2022
aaca54c
node-api: handle no support for external buffers
mhdawson Oct 25, 2022
58334a3
doc, async_hooks: improve and add migration hints
Flarna Nov 10, 2022
e8075fd
tools: add automation for updating acorn dependency
facutuesca Nov 10, 2022
e2181e0
lib: fix eslint early return
RafaelGSS Nov 10, 2022
0237cff
2022-11-14, Version 19.1.0 (Current)
RafaelGSS Nov 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tools: add documentation regarding our api tooling
Introduces a proper imperative description of how the
current API documentation build system works.

Refs: nodejs/next-10#169

PR-URL: #45270
Reviewed-By: Michael Dawson <[email protected]>
  • Loading branch information
ovflowd authored and RafaelGSS committed Nov 10, 2022
commit 9aa305ff3e70ba3920cfea4de486bca010e332d9
296 changes: 296 additions & 0 deletions doc/contributing/api-documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
# Node.js API Documentation Tooling

The Node.js API documentation is generated by an in-house tooling that resides
within the [tools/doc](https://github.com/nodejs/node/tree/main/tools/doc)
directory.

The build process (using `make doc`) uses this tooling to parse the markdown
files in [doc/api](https://github.com/nodejs/node/tree/main/doc/api) and
generate the following:

1. Human-readable HTML in `out/doc/api/*.html`
2. A JSON representation in `out/doc/api/*.json`

These are published to nodejs.org for multiple versions of Node.js. As an
example the latest version of the human-readable HTML is published to
[nodejs.org/en/doc](https://nodejs.org/en/docs/), and the latest version
of the json documentation is published to
[nodejs.org/api/all.json](https://nodejs.org/api/all.json)

<!-- TODO: Add docs about how the publishing process happens -->

**The key things to know about the tooling include:**

1. The entry-point is `tools/doc/generate.js`.
2. The tooling supports the CLI arguments listed in the table below.
3. The tooling processes one file at a time.
4. The tooling uses a set of dependencies as described in the dependencies
section.
5. The tooling parses the input files and does several transformations to the
AST (Abstract Syntax Tree).
6. The tooling generates a JSON output that contains the metadata and content of
the Markdown file.
7. The tooling generates a HTML output that contains a human-readable and ready
to-view version of the file.

This documentation serves the purpose of explaining the existing tooling
processes, to allow easier maintenance and evolution of the tooling. It is not
meant to be a guide on how to write documentation for Node.js.

#### Vocabulary & Good to Know's

* AST means "Abstract Syntax Tree" and it is a data structure that represents
the structure of a certain data format. In our case, the AST is a "graph"
representation of the contents of the Markdown file.
* MDN means [Mozilla Developer Network](https://developer.mozilla.org/en-US/)
and it is a website that contains documentation for web technologies. We use
it as a reference for the structure of the documentation.
* The
[Stability Index](https://nodejs.org/dist/latest/docs/api/documentation.html#stability-index)
is used to community the Stability of a given Node.js module. The Stability
levels include:
* Stability 0: Deprecated. (This module is Deprecated)
* Stability 1: Experimental. (This module is Experimental)
* Stability 2: Stable. (This module is Stable)
* Stability 3: Legacy. (This module is Legacy)
* Within Remark YAML snippets `<!-- something -->` are considered HTML nodes,
that's because YAML isn't valid Markdown content. (Doesn't abide by the
Markdown spec)
* "New Tooling" references to the (written from-scratch) API build tooling
introduced in `nodejs/nodejs.dev` that might replace the current one from
`nodejs/node`

## CLI Arguments

The tooling requires a `filename` argument and supports extra arguments (some
also required) as shown below:

| Argument | Description | Required | Example |
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------- | ---------------------------------- |
| `--node-version=` | The version of Node.js that is being documented. It defaults to `process.version` which is supplied by Node.js itself | No | v19.0.0 |
| `--output-directory=` | The directory where the output files will be generated. | Yes | `./out/api/` |
| `--apilinks=` | This file is used as an index to specify the source file for each module | No | `./out/doc/api/apilinks.json` |
| `--versions-file=` | This file is used to specify an index of all previous versions of Node.js. It is used for the Version Navigation on the API docs page. | No | `./out/previous-doc-versions.json` |

**Note:** both of the `apilinks` and `versions-file` parameters are generated by
the Node.js build process (Makefile). And they're files containing a JSON
object.

### Basic Usage

```bash
# cd tools/doc
npm run node-doc-generator ${filename}
```

**OR**

```bash
# nodejs/node root directory
make doc
```

## Dependencies and how the Tooling works internally

The API tooling uses an-AST-alike library called
[unified](https://github.com/unifiedjs/unified) for processing the Input file as
a Graph that supports easy modification and update of its nodes.

In addition to `unified` we also use
[Remark](https://github.com/remarkjs/remark) for manipulating the Markdown part,
and [Rehype](https://github.com/rehypejs/rehype)to help convert to and from
Markdown.

### What are the steps of the internal tooling?

The tooling uses `unified` pipe-alike engine to pipe each part of the process.
(The description below is a simplified version)

* Starting from reading the Frontmatter section of the Markdown file with
[remark-frontmatter](https://www.npmjs.com/package/remark-frontmatter).
* Then the tooling goes to parse the Markdown by using `remark-parse` and adds
support to [GitHub Flavoured Markdown](https://github.github.com/gfm/).
* The tooling proceeds by parsing some of the Markdown nodes and transforming
them to HTML.
* The tooling proceeds to generate the JSON output of the file.
* Finally it does its final node transformations and generates a stringified
HTML.
* It then stores the output to a JSON file and adds extra styling to the HTML
and then stores the HTML file.

### What each file is responsible for?

The files listed below are the ones referenced and actually used during the
build process of the API docs as we see on <https://nodejs.org/api>. The
remaining files from the directory might be used by other steps of the Node.js
Makefile or might even be deprecated/remnant of old processes and might need to
be revisited/removed.

* **`html.mjs`**: Responsible for transforming nodes by decorating them with
visual artifacts for the HTML pages;
* For example, transforming man or JS doc references to links correctly
referring to respective External documentation.
* **`json.mjs`**: Responsible for generating the JSON output of the file;
* It is mostly responsible for going through the whole Markdown file and
generating a JSON object that represent the Metadata of a specific Module.
* For example, for the FS module, it will generate an object with all its
methods, events, classes and use several regular expressions (ReGeX) for
extracting the information needed.
* **`generate.mjs`**: Main entry-point of doc generation for a specific file. It
does e2e processing of a documentation file;
* **`allhtml.mjs`**: A script executed after all files are generated to create a
single "all" page containing all the HTML documentation;
* **`alljson.mjs`**: A script executed after all files are generated to create a
single "all" page containing all the JSON entries;
* **`markdown.mjs`**: Contains utility to replace Markdown links to work with
the <https://nodejs.org/api/> website.
* **`common.mjs`**: Contains a few utility functions that are used by the other
files.
* **`type-parser.mjs`**: Used to replace "type references" (e.g. "String", or
"Buffer") to the correct Internal/External documentation pages (i.e. MDN or
other Node.js documentation pages).

**Note:** It is important to mention that other files not mentioned here might
be used during the process but are not relevant to the generation of the API
docs themselves. You will notice that a lot of the logic within the build
process is **specific** to the current <https://nodejs.org/api/> infrastructure.
Just as adding some JavaScript snippets, styles, transforming certain Markdown
elements into HTML, and adding certain HTML classes or such things.

**Note:** Regarding the previous **Note** it is important to mention that we're
currently working on an API tooling that is generic and independent of the
current Nodejs.org Infrastructure.
[The new tooling that is functional is available at the nodejs.dev repository](https://github.com/nodejs/nodejs.dev/blob/main/scripts/syncApiDocs.js)
and uses plain ReGeX (No AST) and [MDX](https://mdxjs.com/).

## The Build Process

The build process that happens on `generate.mjs` follows the steps below:

* Links within the Markdown are replaced directly within the source Markdown
(AST) (`markdown.replaceLinks`)
* This happens within `markdown.mjs` and basically it adds suffixes or
modifies link references within the Markdown
* This is necessary for the `https://nodejs.org` infrastructure as all pages
are suffixed with `.html`
* Text (and some YAML) Nodes are transformed/modified through
`html.preprocessText`
* JSON output is generated through `json.jsonAPI`
* The title of the page is inferred through `html.firstHeader`
* Nodes are transformed into HTML Elements through `html.preprocessElements`
* The HTML Table of Contents (ToC) is generated through `html.buildToc`

### `html.mjs`

This file is responsible for doing node AST transformations that either update
Markdown nodes to decorate them with more data or transform them into HTML Nodes
that attain a certain visual responsibility; For example, to generate the "Added
at" label, or the Source Links or the Stability Index, or the History table.

**Note:** Methods not listed below are either not relevant or utility methods
for string/array/object manipulation (e.g.: are used by the other methods
mentioned below).

#### `preprocessText`

**New Tooling:** Most of the features within this method are available within
the new tooling.

This method does two things:

* Replaces the Source Link YAML entry `<-- source_link= -->` into a "Source
Link" HTML anchor element.
* Replaces type references within the Markdown (text) (i.e.: "String", "Buffer")
into the correct HTML anchor element that links to the correct documentation
page.
* The original node then gets mutated from text to HTML.
* It also updates references to Linux "MAN" pages to Web versions of them.

#### `firstHeader`

**New Tooling:** All features within this method are available within the new
Tooling.

Is used to attempt to extract the first heading of the page (recursively) to
define the "title" of the page.

**Note:** As all API Markdown files start with a Heading, this could possibly be
improved to a reduced complexity.

#### `preprocessElements`

**New Tooling:** All features within this method are available within the new
tooling.

This method is responsible for doing multiple transformations within the AST
Nodes, in majority, transforming the source node in respective HTML elements
with diverse responsibilities, such as:

* Updating Markdown `code` blocks by adding Language highlighting
* It also adds the "CJS"/"MJS" switch to Nodes that are followed by their
CJS/ESM equivalents.
* Increasing the Heading level of each Heading
* Parses YAML blocks and transforms them into HTML elements (See more at the
`parseYAML` method)
* Updates BlockQuotes that are prefixed by the "Stability" word into a Stability
Index HTML element.

#### `parseYAML`

**New Tooling:** Most of the features within this method are available within
the new tooling.

This method is responsible for parsing the `<--YAML snippets -->` and
transforming them into HTML elements.

It follows a certain kind of "schema" that basically constitues in the following
options:

| YAML Key | Description | Example | Example Result | Available on new tooling |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | --------------------------- | ------------------------ |
| `added` | It's used to reference when a certain "module", "class" or "method" was added on Node.js | `added: v0.1.90` | `Added in: v0.1.90` | Yes |
| `deprecated` | It's used to reference when a certain "module", "class" or "method" was deprecated on Node.js | `deprecated: v0.1.90` | `Deprecated since: v0.1.90` | Yes |
| `removed` | It's used to reference when a certain "module", "class" or "method" was removed on Node.js | `removed: v0.1.90` | `Removed in: v0.1.90` | No |
| `changes` | It's used to describe all the changes (historical ones) that happened within a certain "module", "class" or "method" in Node.js | `[{ version: v0.1.90, pr-url: '', description: '' }]` | -- | Yes |
| `napiVersion` | It's used to describe in which version of the N-API this "module", "class" or "method" is available within Node.js | `napiVersion: 1` | `N-API version: 1` | Yes |

**Note:** The `changes` field gets prepended with the `added`, `deprecated` and
`removed` fields if they exist. The table only gets generated if a `changes`
field exists. In the new tooling only "added" is prepended for now.

#### `buildToc`

**New Tooling:** This feature is natively available within the new tooling
through MDX.

This method generates the Table of Contents based on all the Headings of the
Markdown file.

#### `altDocs`

**New Tooling:** All features within this method are available within the new
tooling.

This method generates a version picker for the current page to be shown in older
versions of the API docs.

### `json.mjs`

This file is responsible for generating a JSON object that (supposedly) is used
for IDE-Intellisense or for indexing of all the "methods", "classes", "modules",
"events", "constants" and "globals" available within a certain Markdown file.

It attempts a best effort extraction of the data by using several regular
expression patterns (ReGeX).

**Note:** JSON output generation is currently not supported by the new tooling,
but it is in the pipeline for development.

#### `jsonAPI`

This method traverses all the AST Nodes by iterating through each one of them
and infers the kind of information each node contains through ReGeX. Then it
mutate the data and appends it to the final JSON object.

For a more in-depth information we recommend to refer to the `json.mjs` file as
it contains a lot of comments.