undici

Documentation source

This directory holds the source for undici’s documentation site. The Markdown files here are built by doc-kit (the same tooling Node.js core uses) into the published site.

Most of the directory is plain Markdown (index.md, getting-started.md, api/*.md, best-practices/*.md). Two JSON files control how that Markdown is turned into a navigable, cross-linked site:

site.json

site.json defines the documentation sidebar. doc-kit reads it to render the left-hand navigation; pages are not auto-discovered, so a Markdown file only appears in the sidebar once it is listed here.

The file has a single top-level sidebar array. Each entry is a group:

{
  "sidebar": [
    {
      "groupName": "Documentation",
      "items": [
        { "link": "/", "label": "Home" },
        { "link": "/getting-started", "label": "Getting Started" }
      ]
    }
  ]
}

Fields

Adding a page to the sidebar

  1. Create the Markdown file (for example api/MyFeature.md).
  2. Add an item under the appropriate group in site.json:
    { "link": "/api/MyFeature", "label": "My Feature" }
    

Order within a group is significant — items appear in the sidebar in the order they are listed.

type-map.json

Throughout the API docs, types are written in curly braces — for example {Dispatcher}, {AgentOptions}, or {Buffer}:

* `options` {AgentOptions} (optional) Extends {PoolOptions}.
  * Returns: {Dispatcher}

This is the Node.js documentation convention for annotating the type of a parameter, option, or return value. type-map.json tells doc-kit what each of those type names should link to, so {Dispatcher} in any page becomes a link to the Dispatcher documentation.

The file is a flat object mapping a type name to a URL:

{
  "Agent": "/api/Agent.md#class-agent",
  "AgentOptions": "/api/Agent.md#new-agentoptions",
  "Buffer": "https://nodejs.org/api/buffer.html#class-buffer"
}

Targets are either internal or external:

Adding or updating a type

When you document a new type, or reference an existing one in {...} form, add an entry so the annotation resolves to a link:

  1. Pick the type name exactly as it appears between the braces in the Markdown (the key is matched verbatim — MockInterceptor.Options and net.Socket are valid keys).
  2. Add "TypeName": "<target>" to type-map.json, pointing at the heading that documents it (internal) or its upstream reference (external).

If a {Type} annotation has no matching key, it renders as plain text instead of a link, so keep this file in sync when headings are renamed or pages move.