On this page
The short answerWhat Read the Docs buildsAdd a narrow example gateWhy examples break after publicationScan the MkDocs sourceCheck Sphinx and MyST coverageTriage findings by reader impactPut build and scan checks togetherWhere DocsAlive fitsThe sources we checkedFAQThe short answer
Build your Read the Docs site and test its examples as separate checks, with explicit coverage for the branches and tags readers see. In engine 0.6.3, DocsAlive detects MkDocs and adds the root README, but it does not read .readthedocs.yaml, run build.jobs, or know which Read the Docs versions are active. A Git URL scan uses the default branch, corresponding to latest; scan a local checkout of the selected tag to check stable. Sphinx is not detected, .rst pages are never scanned, and MyST code-block directives are skipped as not executable.
A Read the Docs build checks whether the configured documentation process can produce a site. It does not automatically run every example a reader can copy. A page can render perfectly while an import is obsolete, a promised value is wrong, or a command depends on an undocumented prerequisite.
The walkthrough uses an illustrative MkDocs project with a small pycon gate, followed by a Sphinx and MyST project. The Read the Docs build itself was not run on the service. The two relevant steps were run locally, and the configuration was validated against the published v2 schema. Those checks provide useful evidence, but they do not establish the result of a hosted build.
What Read the Docs builds
Read the Docs takes its configuration from .readthedocs.yaml. The configuration shown here declares version 2, a build operating system, and a Python tool version. The build.jobs section adds commands at build steps such as pre_build; a command that returns a nonzero exit code fails the build immediately. When using jobs, build.os and build.tools are required. The configuration reference and build customization guide describe these settings.
The mkdocs key can name the MkDocs configuration and request failure on warnings. A Sphinx project can instead use the sphinx key and its configuration setting. The python.install section can install from a requirements file. Keep the environment and dependencies in view when interpreting a test: an example that works on a maintainer's machine may need a dependency or runtime that is absent from the configured build.
Read the Docs versions are based on Git tags and branches. latest points to the default branch. stable tracks the greatest stable semantic-version tag or branch, preferring tags and excluding prereleases. Do not assume that a fix on the default branch has reached the tag currently serving stable. Check the actual version selection for the project when deciding what to test. See the versions documentation.
Pull request previews build a new version when a pull request opens and rebuild on new commits. Read the Docs reports a success or failure status check on the pull request. That status represents the configured build, including any explicit gate you add; it does not by itself promise coverage of every code sample. See pull request builds.
During a Read the Docs build, READTHEDOCS is set to True and READTHEDOCS_VERSION contains the version slug; for a pull request build it contains the pull request number. Use those facts carefully when diagnosing environment-dependent behavior, and avoid assuming that a local run has the same environment. The environment variable reference describes their meaning.
Add a narrow example gate
The following illustrative .readthedocs.yaml was validated against the published v2 JSON schema. Its pre_build job invokes a script that checks pycon blocks. The hosted Read the Docs build was not run for this probe.
version: 2
build:
os: ubuntu-24.04
tools:
python: "3.13"
jobs:
pre_build:
- python scripts/check_pycon.py docs
mkdocs:
configuration: mkdocs.yml
fail_on_warning: true
python:
install:
- requirements: docs/requirements.txt
The illustrative mkdocs.yml names two pages. MkDocs configuration controls the site and navigation; it does not make those pages' code examples executable tests by itself. See the MkDocs configuration guide.
site_name: Example Client
nav:
- Home: index.md
- Usage: usage.md
The illustrative requirements file pins the MkDocs version used in the local check:
mkdocs==1.6.1
The first illustrative page, docs/index.md, contains a shell command and a Python block. They are useful reader instructions, but the narrow doctest gate introduced below does not test either block.
# Example Client
Check your Python version:
```bash
python3 --version
```
Build a settings dictionary:
```python
settings = {"retries": 5, "timeout": 10}
print(settings["retries"])
```
The second illustrative page, docs/usage.md, contains a pycon session with an expected value. That is the format the gate is designed to find.
# Usage
Sort the keys of a settings dictionary:
```pycon
>>> settings = {"timeout": 10, "retries": 3}
>>> sorted(settings)
['retries', 'timeout']
```
The illustrative scripts/check_pycon.py uses Python's doctest module to find and run matching sessions under the supplied directory. It exits with a failure if a doctest fails. The script is intentionally narrow: it matches the fence form shown here in .md files, rather than proving coverage of every page or example format. See the doctest documentation.
import doctest
import re
import sys
from pathlib import Path
FENCE = re.compile(r"^```pycon\n(.*?)^```", re.M | re.S)
parser = doctest.DocTestParser()
runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS)
for page in sorted(Path(sys.argv[1]).rglob("*.md")):
for n, block in enumerate(FENCE.findall(page.read_text()), 1):
test = parser.get_doctest(block, {}, f"{page}#{n}", str(page), 0)
runner.run(test)
failed, attempted = runner.summarize(verbose=False)
print(f"{attempted} pycon examples, {failed} failed")
sys.exit(1 if failed else 0)
Run the same two steps locally before pushing. Both exited successfully in the checked environment, using MkDocs 1.6.1 and Python 3.13.
python scripts/check_pycon.py docs
mkdocs build --strict
The local doctest check reported two attempted examples and no failures:
2 pycon examples, 0 failed
Now consider a deliberately broken expectation. The next block is the local check's result after changing the expected order in usage.md. The check exited 1. If this command returned that status in the configured pre_build job, Read the Docs would fail the build at that point.
**********************************************************************
File "docs/usage.md", line 2, in docs/usage.md#1
Failed example:
sorted(settings)
Expected:
['timeout', 'retries']
Got:
['retries', 'timeout']
**********************************************************************
1 item had failures:
1 of 2 in docs/usage.md#1
***Test Failed*** 1 failure.
2 pycon examples, 1 failed
This is a useful build gate because it has a clear contract: matching pycon sessions must pass before the site build proceeds. It is not a general documentation test. It does not execute the ordinary Python and shell blocks above, inspect .rst files, or establish that a multi-page tutorial works from start to finish. Expand coverage deliberately, with checks appropriate to the formats and reader journeys your project supports.
Why examples break after publication
A common failure starts with a healthy default branch and an older stable tag. A maintainer corrects a page on the branch, the latest build updates, and the stable site continues to serve the tagged copy. If nobody checks that tag again, readers can encounter the old instruction even while the current source looks correct.
Dependencies and runtimes can drift too. A page may describe an API available when the tag was created, but the build or a reader's environment may now install a newer dependency. Conversely, an example for an old release may legitimately need an older artifact. Record the artifact, interpreter, dependencies, fixtures, and network assumptions before deciding whether a failure belongs in the documentation.
A successful site build only establishes what its configured steps check. Sphinx can render a directive as highlighted code without executing it. A page written in .rst can publish successfully without being seen by a Markdown-only scanner. An explicit doctest gate covers the sessions it discovers, but any remaining formats need their own plan. For Sphinx's doctest builder, see testing Sphinx docs; for a wider MkDocs workflow, see testing MkDocs docs.
Scan the MkDocs source
The following command plans an illustrative repository scan:
docsalive scan .
In the checked project, DocsAlive detected MkDocs, collected three pages—the root README and the two files under docs/—and found three blocks. When executed, all passed. With the deliberately wrong pycon expectation above, the engine instead reported that block as a warning in the output-differs category, while the doctest gate exited 1. Both identified the same block, but they assigned different severity.
Only pycon sessions have their printed output compared by the engine. A warning still deserves review when the documented value is central to the reader's task. Conversely, decide whether variable content is intended before treating every difference as a documentation bug.
The scanner does not read .readthedocs.yaml, execute build.jobs, or discover active Read the Docs versions. A scan and a hosted build therefore need separate configuration and separate evidence. Inspect the report's page list and reasons, including skipped blocks, rather than assuming that a successful scan mirrors the site build.
A Git URL target is shallow-cloned at the default branch, which corresponds to what Read the Docs calls latest. To check a stable tag, use a local checkout of the tag. The following illustrative commands created a tag and worktree for the probe, then planned a scan of that checkout:
git tag v1.2
git worktree add ../docs-v1.2 v1.2
docsalive scan ../docs-v1.2
The checked worktree contained the tagged settings, while the default branch had moved on. The scan detected MkDocs and collected three pages at the tagged commit. For an existing project, identify the actual tag selected for stable and scan that checkout; creating a new tag would be a separate release action, not a prerequisite for inspecting an existing one. The Git worktree reference explains the checkout mechanism.
The commands shown plan scans. Use the execution option documented in the CLI reference when the purpose is to run examples, and record the commit and setup with the resulting report. A default-branch scan cannot establish what a different tag serves.
Check Sphinx and MyST coverage
Sphinx creates a different coverage problem in engine 0.6.3. The engine does not detect Sphinx as a framework. It can collect Markdown pages as plain Markdown, but it never collects .rst pages. A MyST directive can render correctly in Sphinx while the engine reads the directive's fence as text and skips it.
The illustrative MyST page below contains both a plain Python fence and a code-block directive. In the checked Sphinx build, both rendered as highlighted Python and the directive's caption appeared.
# Example Client
A plain Python fence:
```python
settings = {"retries": 3, "timeout": 10}
print(settings["retries"])
```
The same code as a MyST code-block directive with a caption:
```{code-block} python
:caption: settings.py
settings = {"retries": 3, "timeout": 10}
print(settings["timeout"])
```
This illustrative docs/usage.rst belongs to the same project. It is a separate coverage gap for the engine because .rst is not a scanned page suffix.
Usage
=====
.. code-block:: python
print("hello from rst")
Build the Sphinx site and plan the scan:
sphinx-build -q -b html docs _build/html
docsalive scan .
The local Sphinx build exited successfully with a warning that usage.rst was not in a toctree. The scan reported framework plain, collected only docs/index.md, and found two blocks. When executed, the plain Python fence passed; the directive was skipped as not executable text. The .rst page received no scan coverage. Rendering is therefore evidence about the site output, not proof that either sample was executed.
Make a scan-ready copy
The illustrative scripts/myst_scan_copy.py below creates a separate Markdown copy for scanning. It changes supported MyST directive fences into plain language fences and drops directive option lines such as a caption. It leaves the source pages in place.
import re
import sys
from pathlib import Path
src, dst = Path(sys.argv[1]), Path(sys.argv[2])
DIRECTIVE = re.compile(r"^(`{3,})\{(?:code-block|code|sourcecode)\}\s+(\S+)\s*$")
for page in sorted(src.rglob("*.md")):
out, lines, i = [], page.read_text().splitlines(), 0
while i < len(lines):
m = DIRECTIVE.match(lines[i])
if m:
out.append(m.group(1) + m.group(2))
i += 1
while i < len(lines) and lines[i].startswith(":"):
i += 1
if i < len(lines) and not lines[i].strip():
i += 1
continue
out.append(lines[i])
i += 1
target = dst / page.relative_to(src)
target.parent.mkdir(parents=True, exist_ok=True)
target.write_text("\n".join(out) + "\n")
print(f"wrote {target}")
Create the copy and plan a scan of it:
python3 scripts/myst_scan_copy.py docs scan-docs
docsalive scan . --docs-dir scan-docs
The checked script completed successfully and reported the copied page:
wrote scan-docs/index.md
The scan-ready copy contained one page and two blocks; when executed, both Python blocks passed. Keep the original path and generated path associated in your test record so a finding can be reviewed against the source. The copied page is a testing aid, not proof that the published Sphinx page has the same execution context.
The script handles only code-block, code, and sourcecode directives whose first line names a language. It does not handle literalinclude, eval-rst, colon fences, or .rst pages. It removes option lines rather than interpreting their meaning. Review generated copies and use a separate Sphinx-aware check for material outside that scope. The MyST code documentation describes the source constructs.
| Read the Docs or Sphinx item | What Read the Docs does | What the engine does in 0.6.3 |
|---|---|---|
.readthedocs.yaml |
Configures the hosted build, including the selected tools and jobs. | Does not read it or execute its jobs. |
| MkDocs project | Builds the site using the configured MkDocs settings. | Detects MkDocs and collects docs/ plus the root README. |
latest |
Builds the default branch. | A Git URL scan shallow-clones the default branch. |
stable |
Tracks the greatest stable semantic-version tag or branch, with tag preference and prereleases excluded. | Does not select the active version; scan a local checkout of the appropriate tag. |
| Pull request preview | Builds on opening and new commits and reports a status check. | A separate scan must be configured for the desired source and scope. |
Pycon gate in pre_build |
Fails the build if the command exits nonzero. | Reports the checked mismatch as a warning categorized output-differs. |
Sphinx and .rst |
Can build Sphinx source, including .rst pages. |
Does not detect Sphinx and never collects .rst pages. |
| MyST code-block directive | Sphinx with MyST can render it as highlighted code. | Skips the directive fence as not executable text unless a suitable scan copy is made. |
| Unknown fence label | A site may render or display the block. | Can report it as passing without running or parsing it; this is a known limitation. |
The table describes the checked engine release. The exact hosted build still depends on the project's configuration, selected version, dependencies, and service environment.
Triage findings by reader impact
A failing gate, a scan warning, and a skipped block carry different evidence. Start with the source version and the reader's intended path. Then reproduce the result using the documented prerequisites and determine whether the problem is in the page, the test environment, or an external dependency.
| Finding | Team response | Evidence to keep |
|---|---|---|
| A stable tag contains an incorrect example. | Fix the applicable source and decide how the correction reaches readers of that release. | Tag, commit, runtime, failure, and release policy decision. |
| Latest is fixed but stable is still wrong. | Decide whether a corrected release or other supported publishing path is needed. | The version each site serves and the tested artifact. |
| A pycon value differs. | Decide whether the expected value is wrong or legitimately variable; choose gate severity accordingly. | The session, environment, and reason for the decision. |
A MyST directive or .rst page is untested. |
Add a suitable separate check and record the gap until it is covered. | Source path, format, and check used. |
| A dependency, fixture, or network condition caused a failure. | Reproduce and assess whether the page states the prerequisite. | Setup supplied by the test and the relevant failure category. |
| A version is no longer supported. | Decide whether to retain or retire it under the team's policy. | Support decision and handling of existing links. |
Do not silently update an old page to describe a newer product if that makes it inaccurate for the version the page claims to cover. Likewise, a warning is not automatically harmless when a reader is told to expect a precise result. The owner of the documentation should make those calls.
Put build and scan checks together
Use the build gate for the narrow checks that must prevent publication, and run DocsAlive beside it to inspect supported examples and classify findings. The scan is not inside Read the Docs. Make the branch or tag, setup, and collected page list visible in both workflows so reviewers can tell what each result covers.
For pull requests, a preview status helps reviewers see whether the configured site build succeeded. A separate example scan can provide findings for the changed source. For releases, identify the tag intended for stable and test that exact checkout. For existing stable releases, schedule a check when dependencies and supported environments can change.
Review skips as carefully as failures. The engine collects only .md, .mdx, and .markdown pages; it cannot cover .rst by itself. Unknown fence labels can appear to pass without being run or parsed. A clean summary is meaningful only when the selected pages and supported block formats match the coverage you intended.
Paste this checklist into a release or documentation issue:
[ ] Identify the default branch and the actual version selected for stable.
[ ] Record the commit, product artifact, runtime, and dependencies for each check.
[ ] Validate the Read the Docs configuration against the published schema.
[ ] Run the configured example gate and site build in a suitable environment.
[ ] Review the pull request preview status and any build warnings.
[ ] Scan the default branch for latest and a local tag checkout for stable.
[ ] Confirm the scan's collected page paths, including the root README for MkDocs.
[ ] Review pycon warnings, failures, skips, and unknown fence labels.
[ ] Inventory Sphinx .rst pages and MyST directives needing separate coverage.
[ ] Inspect any generated scan copy and map findings back to source.
[ ] Decide how fixes reach each supported version.
[ ] Save the build and scan results and record remaining coverage gaps.
Where DocsAlive fits
DocsAlive runs supported examples in isolated page environments and classifies results to help teams separate likely documentation defects from failures that need context. Reports identify the page, line, status, category, and reason. That makes the scan useful beside a build gate, especially when a repository contains examples beyond the gate's narrow pycon pattern.
It does not replace the Read the Docs build, select stable on your behalf, or cover every Sphinx source format in engine 0.6.3. Keep a separate build check, explicitly scan the relevant checkout, and maintain a coverage plan for .rst and directives. See the framework reference, findings reference, and documentation drift guide. For copied release folders rather than Git-based site versions, see testing versioned Docusaurus docs.
The sources we checked
These sources were read on November 13, 2026. Engine behavior was checked against engine 0.6.3 on the same day.
| Source | What it covers |
|---|---|
| Read the Docs configuration reference | Version 2 configuration, build tools, jobs, and documentation builders |
| Read the Docs build customization | Adding commands to build steps and their effect on builds |
| Read the Docs versions | Branches, tags, latest, and stable |
| Read the Docs pull request builds | Preview builds and pull request status |
| Read the Docs environment variables | Build and version environment values |
| MyST code and API syntax | Code directives in MyST source |
| MkDocs configuration | MkDocs site configuration |
| Python doctest | Running and checking interactive Python sessions |
| Git worktree | Creating a separate checkout of a selected commit or tag |
FAQ
Does a successful Read the Docs build test every example?
No. A build runs the configured documentation steps and any checks you explicitly add. A Sphinx directive can render as code without executing it, and a narrow doctest gate only covers the sessions it finds.
Does DocsAlive run Read the Docs build jobs?
No. Engine 0.6.3 does not read .readthedocs.yaml or run build.jobs. Run the scan beside the build gate and review the result of each check separately.
How do I test the documentation served as stable?
Identify the tag or branch actually selected for stable, check it out locally, and scan that checkout with the appropriate setup. A Git URL scan uses the default branch, corresponding to latest, and does not select a tag.
What happens when a pycon value is wrong?
In the checked probe, the doctest gate exited with a failure that would fail its configured pre_build job. The engine reported the same mismatch as a warning in the output-differs category. Review the difference and choose the gate appropriate to the page's promise.
Can the engine scan Sphinx and MyST pages?
It does not detect Sphinx in engine 0.6.3 and never scans .rst pages. It scans MyST Markdown as plain Markdown, but skips code-block directive fences as not executable text. A limited scan-copy transformation can cover some directives; other constructs need separate checks.
Was the example configuration tested on Read the Docs?
The hosted build was not run. The configuration was validated against the published v2 schema, and the doctest and MkDocs build steps were run locally. A hosted run is still needed to verify the project's actual service environment and version settings.




