Overview
Node.js API documentation is generated using in-house tooling from the nodejs/doc-kit repository. The tooling processes Markdown files fromdoc/api/ and generates both HTML and JSON outputs.
Documentation Tooling
Location
The doc-kit tooling is installed as an npm package in thetools/doc directory of the Node.js repository.
Build Process
Runningmake doc or make doc-only generates:
- HTML: Human-readable documentation in
out/doc/api/*.html - JSON: Machine-readable format in
out/doc/api/*.json
Published Artifacts
Documentation is published to nodejs.org:- HTML: nodejs.org/en/docs
- JSON: nodejs.org/api/all.json
File Structure
1:1 Relationship
There should be a 1:1 relationship between:- Module source:
lib/<module>.js - Documentation:
doc/api/<module>.md
YAML Properties
For new features, useREPLACEME for version numbers:
Documentation Template
Basic Module Structure
Stability Index
Indicate the stability of each module:| Level | Description |
|---|---|
| 0 | Deprecated - Avoid use, may be removed |
| 1 | Experimental - Subject to change |
| 2 | Stable - Production-ready |
| 3 | Legacy - Maintained but not actively developed |
Documenting Functions
Function Signature
- Use backticks for the entire signature
- Square brackets
[]indicate optional parameters - Show default values with
=
Parameters
Return Values
Documenting Classes
Custom classes must be registered in doc-kit constants.mjs to be properly parsed in type fields.
Documenting Events
Module Events
Class Events
YAML Metadata
Version History
Deprecation
Code Examples
CommonJS and ES Modules
Provide examples for both module systems:Promises Example
Type Annotations
Primitive Types
Complex Types
Node.js Types
Union Types
Generic Types
Building Documentation
Build Commands
Using doc-kit Directly
Best Practices
Be Clear and Concise
Use Examples
Provide practical examples that users can copy and use:Document Edge Cases
Link to Related APIs
Documentation Workflow
Adding New Features
- Add documentation alongside code changes
- Use REPLACEME for version numbers
- Add YAML metadata with
added: REPLACEME - Provide examples for both CJS and ESM
- Build and verify documentation renders correctly
Updating Existing Docs
- Add change entry to YAML metadata
- Update examples if API changed
- Mark deprecations clearly
- Update related documentation if necessary
Deprecating APIs
Testing Documentation
Documentation examples are tested as part of the test suite:Related Resources
doc-kit Repository
Documentation tooling source
doc-kit README
Tool usage documentation
API Documentation
Published Node.js API docs
Writing Tests
Test your documentation