Write one line in a docs page and the build turns it into the reference for
that Python module, class or function:
No extra tool or build step. The source is read as text (Python's ast), so
ast
the package does not have to be installed and nothing is imported. aiui dev
aiui dev
rebuilds the page when you save a .py file. The reference goes in where the
.py
line is, in the same pass as snippets,
so the page, its agent .md, llms-full.txt, search and aiui validate all see it.
.md
llms-full.txt
aiui validate
| You write | You get |
|---|---|
| ::: mypkg.client | The module docstring, then its public members: __all__ in order when there is one (re-exports followed), else every public class and function |
::: mypkg.client
__all__
| ::: mypkg.client.Client | The class: constructor signature and parameters, bases, attributes (annotated or documented, properties, Field(default=, description=)), then its public methods |
::: mypkg.client.Client
Field(default=, description=)
| ::: mypkg.client.connect | One function or method |
::: mypkg.client.connect
Each object gets a heading anchored by its dotted path with dashes
(#mypkg-client-Client-fetch) and its signature with type hints and defaults.
#mypkg-client-Client-fetch
Names starting with _ are left out. From the docstring:
_
<ParamField>
type and default from the signature, required when there is no default,
required
and the text; documented kwargs keys get rows too. Attributes**:
kwargs
<ResponseField> rows.
<ResponseField>
>>>
::
.. code-block::
Notes, Warnings, .. note::, .. warning::: callouts.
.. note::
.. warning::
Google (Args:), NumPy (Parameters over ----------) and reST (:param x:,
Args:
Parameters
----------
:param x:
:type x:, :returns:, :rtype:, :raises E:) styles all work. reST roles
:type x:
:returns:
:rtype:
:raises E:
become code, and < is escaped so text never turns into a tag.
<
YAML on the indented lines under the block (an options: mapping works too):
options:
| Option | Default | What it does |
|---|---|---|
| members | all public | Only these members, in this order; false: the object alone |
members
false
| private | false | Also _name members (not __dunder__) |
private
_name
__dunder__
| show_source | false | A collapsed "Source code" block under each object |
show_source
| heading_level | 2 | Heading level of the block's own object (1 to 6) |
heading_level
2
1
6
mypkg.client is mypkg/client.py, mypkg/client/__init__.py or a .pyi, in
mypkg.client
mypkg/client.py
mypkg/client/__init__.py
.pyi
src/, then the project folder. Change the folders, searched in order:
src/
A block naming no module or member, a file that is not valid Python, or an
unknown option is 7016 in aiui validate and fails aiui build with the page
aiui build
and line. A ::: line inside a code fence is left alone.
:::
The class behind this page, from ::: praisonaiui.compiler.python_api.PythonApi
::: praisonaiui.compiler.python_api.PythonApi
with members: [markdown] and heading_level: 3:
members: [markdown]
heading_level: 3
Finds and renders the objects `:::` blocks name.
<ParamField name="root" type="Path" required id="praisonaiui-compiler-python_api-PythonApi-root">
The project folder.
</ParamField>
<ParamField name="paths" type="list[str] | tuple[str, ...]" default="DEFAULT_PATHS" id="praisonaiui-compiler-python_api-PythonApi-paths">
Folders under `root` searched in order for a module's file.
root
The Markdown for one `::: target` block.
::: target
<ParamField name="target" type="str" required id="praisonaiui-compiler-python_api-PythonApi-markdown-target">
A dotted module path, optionally followed by a class, function or method.
<ParamField name="opts" type="dict" required id="praisonaiui-compiler-python_api-PythonApi-markdown-opts">
The block's options (`members, private, show_source, heading_level`).
,
Returns
str
Raises
ApiReferenceError
target