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)
docs.autodoc
| Name | Type | Default | Description |
|---|---|---|---|
type
|
|
— | |
qualified_name
|
|
— | |
element_type
|
|
— | |
description
|
|
— | |
source_file
|
|
— | |
line_number
|
|
— | |
is_autodoc
|
|
— | |
autodoc_element
|
|
— | |
_autodoc_template
|
|
— | |
_autodoc_url_path
|
|
— | |
_autodoc_page_type
|
|
— | |
title
|
|
— | |
doc_content_hash
|
|
— |
Symbols on this page
Generate API reference pages from frozen app state.
Must be called afterapp.freeze(). Returns DocPageinstances
withsource=DocSource.AUTODOC.
ExtractRouteDocfrom each registered route.
Extract path parameters from route path and handler signature.
ExtractToolDocfrom MCP tool info list.
Flatten JSON Schema properties intoParamDoctuples.
Generate a URL-safe slug from a route path.
/contacts/\{id} → api/routes/contacts-id
Generate a URL-safe slug from a tool name.
search_docs → api/tools/search-docs
Render a RouteDoc as markdown (for agent consumption via raw field).
Render a ToolDoc as markdown (for agent consumption via raw field).
Simple markdown-to-HTML for autodoc pages.
Uses MarkdownRenderer if available, falls back to minimal rendering.
Convert a RouteDoc to a DocPage.
Convert a ToolDoc to a DocPage.
generate_autodoc
function
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 | Default | Description |
|---|---|---|---|
app
|
App
|
— |
introspect_routes
function
def introspect_routes(routes: list[Route]) -> tuple[RouteDoc, ...]
ExtractRouteDocfrom each registered route.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
routes
|
list[Route]
|
— |
_extract_route_params
function
def _extract_route_params(path: str, handler: Any) -> tuple[ParamDoc, ...]
Extract path parameters from route path and handler signature.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
path
|
str
|
— | |
handler
|
Any
|
— |
introspect_tools
function
def introspect_tools(tool_infos: list[McpToolInfo]) -> tuple[ToolDoc, ...]
ExtractToolDocfrom MCP tool info list.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
tool_infos
|
list[McpToolInfo]
|
— |
_flatten_schema
function
def _flatten_schema(schema: dict[str, Any]) -> tuple[ParamDoc, ...]
Flatten JSON Schema properties intoParamDoctuples.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
schema
|
dict[str, Any]
|
— |
_slug_for_route
function
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 | Default | Description |
|---|---|---|---|
path
|
str
|
— |
_slug_for_tool
function
def _slug_for_tool(name: str) -> str
Generate a URL-safe slug from a tool name.
search_docs → api/tools/search-docs
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
name
|
str
|
— |
_route_doc_to_markdown
function
def _route_doc_to_markdown(rd: RouteDoc) -> str
Render a RouteDoc as markdown (for agent consumption via raw field).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
rd
|
RouteDoc
|
— |
_tool_doc_to_markdown
function
def _tool_doc_to_markdown(td: ToolDoc) -> str
Render a ToolDoc as markdown (for agent consumption via raw field).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
td
|
ToolDoc
|
— |
_markdown_to_html
function
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 | Default | Description |
|---|---|---|---|
md
|
str
|
— |
_route_doc_to_page
function
def _route_doc_to_page(rd: RouteDoc, *, order: int) -> DocPage
Convert a RouteDoc to a DocPage.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
rd
|
RouteDoc
|
— | |
order
|
int
|
— |
_tool_doc_to_page
function
def _tool_doc_to_page(td: ToolDoc, *, order: int) -> DocPage
Convert a ToolDoc to a DocPage.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
td
|
ToolDoc
|
— | |
order
|
int
|
— |
View source · /home/runner/work/chirp/chirp/site/../src/chirp/docs/autodoc.py:1