---
title: "Generate reference docs from the code · Agent Wranglers"
url: https://agentwranglers.se/playbook/documentation/reference-and-changelogs/generated-reference
id: DOC-45
level: Recommended
updated: 2026-10-27
build: a2a6bdfed830
tokens: 884
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Generate reference docs from the code

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Reference and changelogs](https://agentwranglers.se/playbook/documentation/reference-and-changelogs.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: DOC-45
- Level: Recommended
- Chapter: [Reference and changelogs](https://agentwranglers.se/playbook/documentation/reference-and-changelogs.md)
- Rule: Build reference docs for every public interface from the code or contract, never by hand.
- Check: The build regenerates the reference docs and fails when the result differs from the committed or published copy. The generator runs with warnings as errors, such as `typedoc --treatValidationWarningsAsErrors` with `validation.notDocumented` on. For Python, add a docstring linter such as Ruff's `D1` rules. A public function without a doc comment then fails.
- How: For HTTP APIs, use the contract, as in [generate docs and clients from the contract](https://agentwranglers.se/playbook/api-design/contracts-and-docs/generated-docs.md). For libraries, generate from types and doc comments with a tool such as TypeDoc, Sphinx autodoc, godoc or Javadoc. For command-line tools, generate the page from the `--help` text. Write by hand only the guides that explain why and in what order. A project with no public interface for other code, such as a plain website, skips this rule.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### TypeScript example

```ts
/**
 * Returns the pickup time for an order placed at `placedAt`.
 * Orders after 15:00 are ready the next morning at 08:00.
 */
export function pickupTime(placedAt: Date): Date { /* ... */ }
```

### Python example

```python
def pickup_time(placed_at: datetime) -> datetime:
    """Return the pickup time for an order placed at placed_at.

    Orders after 15:00 are ready the next morning at 08:00.
    """
```

## Sources

- [OpenAPI Specification 3.2.1](https://spec.openapis.org/oas/v3.2.1.html)

## Related rules

- DOC-1 [Sort every page into one of four kinds](https://agentwranglers.se/playbook/documentation/kinds-of-docs/four-kinds.md) in Documentation
- API-48 [Generate docs and clients from the contract](https://agentwranglers.se/playbook/api-design/contracts-and-docs/generated-docs.md) in API design
- DOC-13 [Generate the settings reference from one schema](https://agentwranglers.se/playbook/documentation/reference-and-changelogs/settings-reference.md) in Documentation

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/documentation/reference-and-changelogs/generated-reference">Agent Wranglers documentation playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Give every error code its own docs page](https://agentwranglers.se/playbook/documentation/reference-and-changelogs/error-pages.md)
- Next: [Generate the settings reference from one schema](https://agentwranglers.se/playbook/documentation/reference-and-changelogs/settings-reference.md)
- [Reference and changelogs](https://agentwranglers.se/playbook/documentation/reference-and-changelogs.md)
