API Reference From Code

Generates reference documentation for a module's public surface directly from source: signatures, parameters, return values, errors, and a tested-looking example per symbol.

License: CC0-1.0 · By waxmark · v1 · 2026-11-02

Share on X

Add a trust badge to your README

[![Waxmark](https://waxmark.app/api/badge/api-reference-from-code)](https://waxmark.app/items/api-reference-from-code/scan)
Report
Write API reference documentation for the {{LANGUAGE}} module `{{MODULE_NAME}}` from its source. Reference docs are consulted, not read, so each entry must be complete on its own and say exactly what the code does, including the unpleasant parts.

<source_code>
{{SOURCE_CODE}}
</source_code>

<public_symbols>
{{PUBLIC_SYMBOLS}}
</public_symbols>

<doc_style>
{{DOC_STYLE}}
</doc_style>

<public_symbols> lists what to document. If empty, document everything exported or not prefixed as private by the language's convention, and list what you excluded. <doc_style> may name a convention (Google style, numpydoc, JSDoc, rustdoc, Docusaurus page) or paste an existing page to match; if empty, use the format below.

Rules:

1. Derive everything from <source_code>. Read each function body, not just its signature: document the errors it actually raises, the mutations it actually performs, and the defaults it actually applies. Where the signature says `Optional[str]` but the body treats empty string as absent, say so.
2. Describe parameters by meaning and constraint, not by repeating the type: "`timeout` - seconds to wait before raising `TimeoutError`; must be positive; default 30" rather than "`timeout`: int. The timeout."
3. Return values: state the shape and the conditions under which each shape is returned, including `None`/empty/sentinel cases. If a function returns different things on different paths, list the paths.
4. Errors: list every exception or error value the body can produce, including ones propagated from a called function when the call is unguarded and the callee is in <source_code>. Mark propagated errors as such.
5. Examples: one per symbol, minimal, runnable as written against the documented signature, showing the common case. If a symbol needs setup (a client, a file), include it in the example. If you cannot write an example that you are confident runs, write `Example: TODO(verify)` with the sketch.
6. Flag anything in the code that a docs reader would be surprised by: hidden I/O, global state, thread-unsafety, time complexity worse than a reader would assume. One sentence each, in a "Notes" line on that symbol.

Do not editorialize about code quality. Do not document private helpers unless a public symbol's behavior cannot be explained without them.

## Output format

```
# {{MODULE_NAME}}
One-paragraph module summary: what it is for and the main entry point.

## Overview table
| Symbol | Kind | One-line purpose |

## <Symbol name>                         (one section per symbol, in source order)
`signature as written in source`

Description: 1-3 sentences on what it does.
Parameters:
- `name` (type) - meaning, constraints, default.
Returns: shape and conditions.
Raises / Errors: list, with [propagated] where applicable.
Example:
```<language>
...
```
Notes: surprises from rule 6, or omit the line.
```

After the reference, add **Excluded symbols** (name and reason) and **Verify before publishing** (any example marked TODO and any behavior you inferred rather than read).
API Reference From Code · Waxmark