Module

docs.autodoc

Autodoc — generate API reference from frozen app state.

Introspects the frozenRouter and ToolRegistryto produce DocPageinstances that live alongside hand-written markdown in the sameDocsCollection. All introspection is read-only.

Usage (internal — called byDocsPluginafter freeze)::

from chirp.docs.autodoc import generate_autodoc
pages = generate_autodoc(app)

Functions

generate_autodoc 1 tuple[DocPage, ...]
Generate API reference pages from frozen app state. Must be called after ``app…
def generate_autodoc(app: App) -> tuple[DocPage, ...]

Generate API reference pages from frozen app state.

Must be called afterapp.freeze(). Returns DocPageinstances withsource=DocSource.AUTODOC.

Parameters
Name Type Description
app App
Returns
tuple[DocPage, ...]
introspect_routes 1 tuple[RouteDoc, ...]
Extract ``RouteDoc`` from each registered route.
def introspect_routes(routes: list[Route]) -> tuple[RouteDoc, ...]
Parameters
Name Type Description
routes list[Route]
Returns
tuple[RouteDoc, ...]
_extract_route_params 2 tuple[ParamDoc, ...]
Extract path parameters from route path and handler signature.
def _extract_route_params(path: str, handler: Any) -> tuple[ParamDoc, ...]
Parameters
Name Type Description
path str
handler Any
Returns
tuple[ParamDoc, ...]
introspect_tools 1 tuple[ToolDoc, ...]
Extract ``ToolDoc`` from MCP tool info list.
def introspect_tools(tool_infos: list[McpToolInfo]) -> tuple[ToolDoc, ...]
Parameters
Name Type Description
tool_infos list[McpToolInfo]
Returns
tuple[ToolDoc, ...]
_flatten_schema 1 tuple[ParamDoc, ...]
Flatten JSON Schema properties into ``ParamDoc`` tuples.
def _flatten_schema(schema: dict[str, Any]) -> tuple[ParamDoc, ...]
Parameters
Name Type Description
schema dict[str, Any]
Returns
tuple[ParamDoc, ...]
_slug_for_route 1 str
Generate a URL-safe slug from a route path. ``/contacts/{id}`` → ``api/routes/…
def _slug_for_route(path: str) -> str

Generate a URL-safe slug from a route path.

/contacts/{id}api/routes/contacts-id

Parameters
Name Type Description
path str
Returns
str
_slug_for_tool 1 str
Generate a URL-safe slug from a tool name. ``search_docs`` → ``api/tools/searc…
def _slug_for_tool(name: str) -> str

Generate a URL-safe slug from a tool name.

search_docsapi/tools/search-docs

Parameters
Name Type Description
name str
Returns
str
_route_doc_to_markdown 1 str
Render a RouteDoc as markdown (for agent consumption via raw field).
def _route_doc_to_markdown(rd: RouteDoc) -> str
Parameters
Name Type Description
rd RouteDoc
Returns
str
_tool_doc_to_markdown 1 str
Render a ToolDoc as markdown (for agent consumption via raw field).
def _tool_doc_to_markdown(td: ToolDoc) -> str
Parameters
Name Type Description
td ToolDoc
Returns
str
_markdown_to_html 1 Markup
Simple markdown-to-HTML for autodoc pages. Uses MarkdownRenderer if available,…
def _markdown_to_html(md: str) -> Markup

Simple markdown-to-HTML for autodoc pages.

Uses MarkdownRenderer if available, falls back to minimal rendering.

Parameters
Name Type Description
md str
Returns
Markup
_route_doc_to_page 2 DocPage
Convert a RouteDoc to a DocPage.
def _route_doc_to_page(rd: RouteDoc, *, order: int) -> DocPage
Parameters
Name Type Description
rd RouteDoc
order int
Returns
DocPage
_tool_doc_to_page 2 DocPage
Convert a ToolDoc to a DocPage.
def _tool_doc_to_page(td: ToolDoc, *, order: int) -> DocPage
Parameters
Name Type Description
td ToolDoc
order int
Returns
DocPage