Executable Documentation#
Some documents in this repository publish Python that a reader copies: the
Getting Started, the AGENTS.md conventions at the repository root, and the
SKILL.md procedures under skills/. A rename in the library would break
those examples silently, so tests/doc runs every one of them as written.
Which documents run#
tests/doc/doc_examples.py lists them in published_documents():
doc/quickstart.rst, the first code a newcomer runs;AGENTS.md, the conventions a coding agent reads before writing against the package. A one-lineCLAUDE.mdimports it so that Claude Code loads it on its own;every
skills/*/SKILL.md, found by a glob, so a new skill needs no registration..claude/skillsis a relative link toskills/so that Claude Code discovers them; the glob readsskills/alone, so no skill runs twice.
Each Python block runs from the repository root, so a fixture path such as
data/step/holes_types.step is written relative to it. A block tagged python,
py or python3 counts as Python.
Opting a block out#
A block that cannot run unattended, because it opens a viewer or installs something, says so in the document:
.. code-block:: python
:class: doc-only
In Markdown the class follows the language on the opening fence’s info string:
python doc-only.
“Not executed” is then a decision visible in the source rather than an omission.
The positive control#
A reader that silently stopped matching would collect nothing, and every example would pass without a line run. Each document’s blocks are therefore also counted by a plain text search that is deliberately broader than the reader: it counts any code directive in reStructuredText, and any fence line, backtick or tilde, at any indentation, in Markdown. When the reader and the count disagree, the test fails. An executable block with no code in it is refused rather than passing.
One consequence: a Markdown document must not quote a fence inside a longer one. The reader reads it as one block, the counter sees two, and the control fails.
Skill frontmatter#
An agent decides whether to load a skill from its frontmatter alone, so
tests/doc/test_skill_examples.py checks it: name matches the skill’s directory,
description carries a Use when clause and stays within 1024 characters, and every
line is a one-line key: value.
Adding a document#
Add a PublishedDocument for it to published_documents(), with its markup
(RESTRUCTURED_TEXT or MARKDOWN). The control and execution tests in
tests/doc/test_doc_examples.py are parametrized over that list, so nothing else is
needed.