---
title: "Generate reference docs from the code · Agent Wranglers"
url: https://agentwranglers.se/playbook/engineering/documentation/generated-reference
updated: 2026-10-20
licence: "All rights reserved"
---

# Generate reference docs from the code

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Recommended
- Chapter: [Documentation](https://agentwranglers.se/playbook/engineering/documentation)
- Rule: Build reference docs for every public interface from the code or contract, never by hand.
- 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). 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.
- 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.

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
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.
    """
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers engineering playbook: https://agentwranglers.se/playbook/engineering/documentation/generated-reference`.

- Previous: [Keep runbooks next to the code they run](https://agentwranglers.se/playbook/engineering/documentation/runbooks-in-repo)
- Next: [Keep a changelog written for users](https://agentwranglers.se/playbook/engineering/documentation/user-changelog)
- [Documentation](https://agentwranglers.se/playbook/engineering/documentation)
