Docs
docs
Documentation tree dump for AI agents.
Discovers README, mkdocs config, and all docs/ markdown files, then formats them as a single concatenated output.
Supports progressive disclosure via detail levels:
toc: heading tree + line count per page (~500 tokens)summary: headings + first sentence per sectionfull: complete content (default, backward-compatible)
Example::
>>> result = discover_docs(Path("."))
>>> print(format_docs(result))
📖 README.md
─────────────
# My Project
...
>>> result = discover_docs(Path("."), detail="toc")
>>> result["pages"][0].keys()
dict_keys(['path', 'headings', 'line_count'])
build_docs_tree(docs_path)
Build an ASCII tree of the docs/ directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
docs_path
|
Path
|
Path to the docs/ directory. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
ASCII tree string, or None if docs/ doesn't exist. |
Source code in packages/axm-ast/src/axm_ast/core/docs.py
discover_docs(root, *, detail='full', pages=None)
Walk project root, find README, mkdocs.yml, and docs/*/.md.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path
|
Project root directory. |
required |
detail
|
str
|
Detail level — |
'full'
|
pages
|
list[str] | None
|
Optional list of page name substrings to filter. Case-insensitive. README and mkdocs are always included. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with readme, mkdocs, tree, and pages. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If detail is not a valid level. |
Source code in packages/axm-ast/src/axm_ast/core/docs.py
extract_headings(content)
Extract H1/H2/H3 headings from markdown content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
Raw markdown text. |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, int | str]]
|
List of dicts with |
Source code in packages/axm-ast/src/axm_ast/core/docs.py
format_docs(result, *, tree_only=False)
Format documentation dump as human-readable text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
dict[str, Any]
|
Dict from discover_docs. |
required |
tree_only
|
bool
|
If True, show only the tree structure. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted text string. |
Source code in packages/axm-ast/src/axm_ast/core/docs.py
format_docs_json(result)
Format documentation dump as JSON-serializable dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
dict[str, Any]
|
Dict from discover_docs. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
JSON-serializable dict. |