The json generator writes one JSON document per source file. Each document
is a tree of the file's headings, in document order, with the metadata,
signature or type, Markdown body, and code examples of every one of them.
The output is described by a JSON schema, published at the URL every document
carries in $schema, and shipped with the package as
@doc-kit/core/generators/json/schema.json.
npx @doc-kit/cli generate -t json -i "doc/api/*.md" -o out
Files keep the input's directory layout: doc/api/some/fs.md becomes out/some/fs.json.
stringbooleanglobal.
Default: true.stringowner/name repository source links resolve
against. Inherited from global; without one, sourceLink.url is null.string{schemaVersion} is
filled in. Default:
'https://doc-kit.nodejs.org/schemas/api-doc/{schemaVersion}.json'.{ "$schema": "https://doc-kit.nodejs.org/schemas/api-doc/1.0.0.json", "id": "fs", "path": "/fs", "type": "module", "module": "fs", "title": "File system", "introducedIn": "v0.10.0", "sourceLink": { "path": "lib/fs.js", "url": "https://github.com/nodejs/node/blob/HEAD/lib/fs.js" }, "stability": { "index": "2", "description": "Stable" }, "added": [], "deprecated": [], "removed": [], "napiVersion": [], "changes": [], "description": "The `node:fs` module enables interacting with the file system in a\nway modeled on standard POSIX functions.\n\n…", "summary": "The `node:fs` module enables interacting with the file system in a way modeled on standard POSIX functions.", "examples": [], "children": [] }
idis the file's path, slugged;pathis that path without extension. Cross-document links in Markdown target<path>.html.typeis the file'stype=directive:module(the default),misc, orglobal.moduleis the module's name, from thename=directive.introducedInandsourceLinkare theintroduced_in=andsource_link=directives.- Everything from
titleon is what every heading carries, described below. childrenare the file's headings, nested by depth.
The document and every node carry:
titleThe heading text as authored, inline Markdown included.stabilityThe stability index, ornull:{ index, description }, whereindexis the text as authored ("1.1") anddescriptionthe Markdown after it.added,deprecated,removedArrays of version strings, as authored.napiVersionAn array of numbers.changesThe change history:{ versions, prUrl, commit, description }.descriptionThe body as Markdown: everything under the heading except its metadata, its stability index, and the typed list a signature or type was taken from. Links are rewritten as they are for HTML output.summaryA plain-text paragraph: thellm_descriptionwhen there is one, else the first paragraph.examplesThe fenced code blocks of the body,{ language, displayName, code }. They stay in the description too.
Every key is always present. What is missing is null or an empty array.
A node is a heading below the title. Its kind says what the heading
documents, and decides which further properties it has:
kind | Heading | Further properties |
|---|---|---|
section | Anything else: prose, DEP0005: …, --flag | none |
class | Class: `net.Server` | extends (Type or null) |
constructor | `new Agent([options])` | signature |
method | `fs.readFile(path[, options], callback)` | signature |
staticMethod | Static method: `Buffer.from(string)` | signature |
property | `buf.length` | type, default |
event | Event: `'close'` | parameters |
Every node also has:
idThe heading's slug, and its anchor in HTML output.nameThe bare identifier:readFile,Server,close. A section's plain heading text. Aname=directive overrides it.scopemodule, orglobalfor entries typedglobal.overloadOfWhen several sibling headings document one callable, theidof the first on the second and later ones; otherwisenull.childrenThe headings nested under it.
"signature": { "parameters": [ { "name": "options", "type": { "text": "Object | string", "links": [{ "name": "Object", "href": "https://developer.mozilla.org/…", "start": 0, "end": 6 }] }, "description": "", "default": null, "optional": true, "rest": false, "properties": [ { "name": "encoding", "type": { "text": "string | null", "links": [] }, "description": "", "default": "null", "optional": true, "rest": false, "properties": [] } ] } ], "returns": { "type": { "text": "Promise", "links": [] }, "description": "Fulfills upon success." } }
- A signature's
parametersare the ones the heading declares, described by the typed list under it.optionalis set for parameters bracketed in the heading or documented with a default;restfor...args.propertiesare the nested list items: the properties of an options object, or the arguments of a callback. returnsis theReturns:item, ornull.- A
Typeis the annotation's TypeScript text, normalised to one line with|between union members, plus the names in it that resolved to documentation, with their character offsets. A type that was not documented isnull, never guessed. - An event's
parametersare the arguments its listeners receive.
schema.json is the source of truth. After changing it, bump its $id and
SCHEMA_VERSION in constants.mjs together, and regenerate the types:
node scripts/generate-json-types.mjs