Guide

Testing Sphinx docs examples with sphinx.ext.doctest

The Sphinx doctest builder runs directive-marked examples in groups. Plain fences and MyST pycon fences are never run by it, so check those separately.

Published
Updated
November 17, 2026
Reading time
11 min
Facts checked against
The Sphinx doctest page and builders page for 9.2.0, the MyST-Parser directive syntax and the Python doctest docs, with every code block run on Sphinx 9.2.0, MyST-Parser 5.2.0 and Python 3 (November 17, 2026)
Outlined documentation pages with a lime pulse line running out of the stack
On this pageThe short answerHow the doctest builder organizes testsWalk through a MyST projectConfigure the builder deliberatelyKeep reader setup and test setup alignedCompare the builder with the engineTriage a doctest failure or coverage gapA checklist for Sphinx changesWhere DocsAlive fitsThe sources we checkedFAQ

The short answer

The Sphinx doctest builder runs directive-marked examples as grouped tests, including interactive sessions and code paired with expected output. Use it as the gate for those examples. DocsAlive adds a separate scan for plain fences in Markdown pages: engine 0.6.3 skips MyST directive fences as not executable, never reads .rst pages or conf.py, and therefore does not see doctest_global_setup. Names supplied only there can be reported as depends-on-context. It runs recognized plain Python, pycon, and shell fences; its printed-output comparison applies to Python pycon sessions.

The two checks have different boundaries. A passing doctest build does not mean a plain Markdown fence was executed. A scan does not mean a Sphinx directive or a reStructuredText page was tested. Record both boundaries when deciding what a green build covers.

How the doctest builder organizes tests

sphinx.ext.doctest provides a doctest builder that collects marked snippets and runs them as tests. Within each document, snippets belong to groups. A group has zero or more setup blocks and one or more test blocks. Groups run one after another: setup first, then tests in file order.

An omitted group name means the default group. An asterisk selects all groups; otherwise, a comma-separated list names the groups to which a directive belongs. Use groups to make shared setup deliberate. A name defined in one group should not be assumed to exist in another.

There are two main test styles. A doctest block presents an interactive Python session with prompts and expected output. A testcode block holds ordinary code, optionally followed by a testoutput block. testcode executes all at once, so a bare expression does not produce output: use print when output is intended. Doctest cannot combine regular output and an exception message in the same snippet; that limit applies to a testcode and testoutput pair too.

The five directives have distinct roles:

  • testsetup runs before its group’s tests and is not shown by other builders. It accepts skipif.
  • testcleanup supplies cleanup code for a group.
  • doctest accepts hide, doctest options, pyversion, the trim flags, and skipif.
  • testcode accepts hide, the trim flags, and skipif.
  • testoutput supplies output or an exception message for the last testcode; it accepts hide, options, the trim flags, and skipif.

The trim options are trim-doctest-flags and no-trim-doctest-flags. pyversion uses PEP 440 version specifiers. skipif is evaluated as a Python expression; when true, the directive is omitted as if it were absent. A hidden block can still run and fail even though readers cannot see it.

In MyST Markdown, write directives as fenced blocks with a single pair of braces around the directive name, such as {doctest}. Arguments follow the directive name, and option lines go at the top of the block. The examples below show the complete fence form.

Walk through a MyST project

The following files use acme-slug and acme_slug as illustrative names, not a published package. The package is assumed to provide slugify and truncate_slug with the behavior shown in the page.

Install Sphinx and MyST-Parser. The checked example used Sphinx 9.2.0 and MyST-Parser 5.2.0; the Sphinx release requires Python 3.13 or newer.

python -m pip install sphinx myst-parser

The illustrative docs/conf.py does three things: it turns on myst_parser and sphinx.ext.doctest (in the usual list in conf.py, as the sphinx.ext.doctest page in the Sphinx documentation shows; that one line is left out of the excerpt below), adds the project directory to Python’s path, and imports helpers for every group. The global setup is convenient for testing, but a reader copying an example does not automatically receive it.

import os
import sys

sys.path.insert(0, os.path.abspath(".."))

project = "acme-slug"
doctest_global_setup = "from acme_slug import slugify, truncate_slug"

The illustrative MyST page contains a default-group doctest, then a named group with testsetup, testcode, and testoutput. The final plain Python fence is highlighted for readers, but the doctest builder does not run it.

# Usage

A doctest-style block. Readers see a console session:

```{doctest}
>>> slugify("Docs That Run Everywhere")
'docs-that-run-everywhere'
```

Hidden setup comes first, then a code block and its expected lines, all in a group named short.

```{testsetup} short
from acme_slug import truncate_slug

slug = "docs-that-run-everywhere"
```

```{testcode} short
print(truncate_slug(slug, 13))
```

```{testoutput} short
docs-that-run
```

A plain fence is only highlighted. The doctest builder never runs it.

```python
print(slugify("Not Tested"))
```

Run the doctest builder using Sphinx’s make-mode command:

sphinx-build -M doctest docs docs/_build

The builder writes its report under the build directory at doctest/output.txt. In the checked run, the default and named groups each passed one test. The plain Python fence did not contribute a test.

Document: usage
---------------
2 items passed all tests:
   1 test in default
   1 test in short
2 tests in 2 items.
2 passed.
Test passed.

Doctest summary
===============
    2 tests
    0 failures in tests
    0 failures in setup code
    0 failures in cleanup code

The next change is broken on purpose relative to the configuration and page. It changes the separator and renames the imported shortening function.

--- a/acme_slug/__init__.py
+++ b/acme_slug/__init__.py
@@ -1,13 +1,13 @@
 """Tiny slug helpers used in the DocsAlive guides."""


-def slugify(text, sep="-"):
+def slugify(text, sep="_"):
     """Turn a title into a URL slug."""
     keep = "".join(c.lower() if c.isalnum() else " " for c in text)
     return sep.join(keep.split())


-def truncate_slug(slug, limit):
+def shorten_slug(slug, limit):
     """Cut a slug at a word boundary."""
     if len(slug) <= limit:
         return slug

After the change, global setup fails in both groups and the named group’s setup import also fails. The build exits with status 1, with three setup failures and no tests run. A zero test count here is a consequence of setup failure, not evidence that the examples were checked successfully.

***Test Failed*** 3 failures.

Doctest summary
===============
    0 tests
    0 failures in tests
    3 failures in setup code
    0 failures in cleanup code

The following material was appended to a copy of the illustrative page. Both displayed values are wrong on purpose. One is in a plain pycon fence; the other is in a hidden doctest directive.

This pycon fence is wrong on purpose.

```pycon
>>> slugify("A B")
'wrong'
```

This doctest directive is hidden from readers and wrong on purpose.

```{doctest}
:hide:

>>> slugify("A B")
'a_b'
```

The checked builder run reports the hidden directive’s mismatch. It does not run the plain MyST pycon fence. This is a useful reminder that hidden tests can fail where readers see no corresponding code, while visible fences can remain untested.

File "usage.md", line 41, in default
Failed example:
    slugify("A B")
Expected:
    'a_b'
Got:
    'a-b'

Configure the builder deliberately

doctest_default_flags defaults to ELLIPSIS, IGNORE_EXCEPTION_DETAIL, and DONT_ACCEPT_TRUE_FOR_1. Those flags affect comparison behavior, so review them before deciding that a doctest verifies every character of an error or result. A directive’s options can specify doctest flags for the relevant block.

doctest_show_successes defaults to true. doctest_path supplies absolute directories to add to Python’s import path. doctest_global_setup and doctest_global_cleanup supply code treated like setup and cleanup for every file and group. Keep that global code small: a removed import there can prevent many examples from running, as the walkthrough shows.

doctest_test_doctest_blocks defaults to default, enabling testing of standard reStructuredText doctest blocks as well; those blocks cannot contain blank lines. This does not make a plain MyST pycon fence a directive test. doctest_fail_fast, added in Sphinx 9.0, defaults to false and can stop at the first failure when enabled.

You can also select the doctest builder with -b doctest. Preserve and inspect output.txt in CI when diagnosing failures. Separate setup, test, and cleanup counts help identify whether the builder reached the examples at all.

Keep reader setup and test setup aligned

Hidden setup can reduce repetition, but it can also hide a missing import or prerequisite. Review each visible example from a reader’s perspective: what must be installed, which names are already defined, and where did those names come from? If the page describes a continuing session, make that relationship clear.

Global setup in conf.py is especially easy to overlook because it is outside the page. It can make a directive pass while a reader’s copy fails. Conversely, a changed import can make every group fail before individual examples run. Treat setup failures as first-class results and investigate the earliest missing dependency or changed API.

Plain fences need an explicit coverage plan. The builder does not run the plain Python fence or the plain MyST pycon fence in the walkthrough. A separate test or scan can exercise them, but its environment and interpretation may differ from Sphinx’s. For the broader build and publishing context, see Sphinx docs testing and Read the Docs testing.

Compare the builder with the engine

sphinx.ext.doctest feature What the doctest builder does What the engine does in 0.6.3
Directive fences Runs supported marked tests and setup by group Skips MyST directive fences as not executable
Groups Runs setup first, then tests in file order for each group Does not interpret directive groups
Global setup and cleanup Applies configured code to every file and group Never reads conf.py or its global setup
Plain Python fence in MyST Does not run it as a directive test Runs recognized plain Python fences in page order
Plain MyST pycon fence Does not run it as a directive test Runs it and compares printed output
.rst pages Can test marked examples and configured standard doctest blocks Never reads .rst pages
Hidden directive Can execute it even when it is not displayed Skips the directive fence
Work environment Uses the Sphinx build and its configured Python environment Starts each Markdown page in a fresh container with an empty work directory

In the scan probe, the plain Python fence in the illustrative page was reported as depends-on-context because its name came from global setup the engine never reads. The plain pycon fence had the same missing context. Install a package through the page or --setup where appropriate, and make reader-facing imports explicit when the example needs them.

The engine also has a known limitation for unknown fence labels: a label without a checker can be reported as passing without being run or parsed. Inspect the operation and skip reasons in the report. A clean scan is useful evidence about supported Markdown fences, not evidence that the Sphinx builder ran.

Triage a doctest failure or coverage gap

Finding Likely cause What to do
Setup failures and no tests run A global or group import failed Fix or update setup first, then rerun and inspect the test count
A visible plain fence has no doctest result It is not a directive test Add an appropriate separate check or convert it when directive semantics fit
A hidden test fails A hidden directive still executes Locate its source and decide whether it tests a meaningful reader contract
Expected output is missing from testcode A bare expression did not print Use print for output that the test should compare
A directive is unexpectedly absent Its skipif expression evaluated true Review the condition and the environments it excludes
A scan reports depends-on-context A name came from Sphinx setup or another omitted context Make prerequisites explicit or supply appropriate setup, then review the result
A scan skips a directive fence Engine 0.6.3 does not execute that directive Use the doctest builder for it
A scan does not include an .rst page That file type is outside engine scope Keep Sphinx or another suitable check for the page

Use the Python docs testing guide for package and environment choices, and compare Sybil when considering another way to collect documentation examples.

A checklist for Sphinx changes

[ ] Run the doctest builder and inspect its test and setup counts.
[ ] Confirm each intended directive belongs to the right group.
[ ] Review global and hidden setup for imports readers also need.
[ ] Use print when testcode must produce expected output.
[ ] Check skip conditions and hidden tests after dependency changes.
[ ] Inventory plain Markdown fences the builder does not run.
[ ] Test .rst pages with a tool that reads them.
[ ] Run supported plain fences in a clean, documented environment.
[ ] Review depends-on-context findings and unsupported labels.
[ ] Rerun the relevant checks after fixing code or documentation.

Where DocsAlive fits

Use the Sphinx doctest builder for directive-marked examples and reStructuredText doctests in the project’s configured build. Use DocsAlive to scan supported plain fences in Markdown and MyST pages, with a fresh container per page and findings classified for review. The scan cannot replace the builder’s group, directive, or global-setup semantics.

The CLI reference explains page setup and scope, while findings describes categories. For different Markdown testing models, compare pytest-codeblocks and txm. A useful coverage record names each tool, the pages and block styles it checks, and the examples left for another test.

The sources we checked

These sources were read on November 17, 2026. Engine behavior was checked against engine 0.6.3, the engine code in the deployed release, on the same day.

Source What it covers
The sphinx.ext.doctest page in the Sphinx documentation (www.sphinx-doc.org, Usage section) and its source for the v9.2.0 tag Directives, groups, options, and configuration
Sphinx builders documentation Builder selection and build output
MyST directives documentation Directive syntax in Markdown
Python doctest documentation Interactive test behavior and doctest flags

FAQ

What does the Sphinx doctest builder run?

It runs marked doctest and code-output examples in document groups, along with their setup and cleanup. It can also test standard reStructuredText doctest blocks according to configuration.

Does the builder run every Python fence in MyST?

No. A plain Python or pycon fence in MyST is not automatically a directive test. Inventory those fences and give them a separate check when readers depend on them.

Why did setup fail before any tests ran?

Global or group setup can import a name that was removed or is unavailable in the build environment. Inspect setup failures first, correct the environment or import, and rerun to see the individual test results.

Why does a bare expression in testcode show no output?

testcode executes the block all at once rather than as an interactive session. Use print when the example must produce output for a testoutput block.

How does DocsAlive handle Sphinx examples?

Engine 0.6.3 skips MyST directive fences, never reads .rst pages or conf.py, and does not receive doctest_global_setup names; those names can be reported as depends-on-context. It runs recognized plain Python, pycon, and shell fences in Markdown, and compares printed output in pycon sessions.

Should I use both the builder and a scan?

Yes, when the project has both directive-marked tests and plain Markdown fences that matter to readers. The builder checks its directives; the scan covers supported plain fences with a different environment and does not replace the Sphinx build.

Keep reading
Outlined documentation pages with a lime pulse line running out of the stackGuide

Docs Testing: How to Test the Code Samples in Your Docs

Why code examples in documentation break, the ways teams test them (doctest, docs-as-tests, CI runners) and how to run every sample on each release.

Two lenses held over the same documentation page, each bringing a different layer into focusComparison

Vale vs markdownlint: What Each Docs Linter Catches

Vale checks prose style; markdownlint checks Markdown structure. What each catches, sample configs, running both in CI and what neither one tests.

Blueprint of two documentation pages: one with a handwritten test script, one whose code blocks are framed and checkedComparison

Doc Detective vs DocsAlive: Testing the Code in Your Docs

Doc Detective is a free, open-source docs-as-tests framework; DocsAlive is a hosted docs CI for code examples. Features, price, setup and when to use each.

A machine blueprint above a ruled documentation page, with a caliper measuring between themComparison

Promptless Alternative: Promptless vs DocsAlive Compared

Promptless drafts docs updates from what you ship; DocsAlive runs the code examples you've published. Features, pricing, security and when to use each.

A long workbench of outlined testing instruments, each with a small lime light, beside a stack of documentation pagesGuide

Best Free Tools to Test Code Examples in Documentation

Free, open-source tools that run the code examples in your docs: rustdoc, Go examples, doctest, pytest plugins, Sphinx doctest, Doc Detective and byexample.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing SDK Docs Before Every Release: A Release-Gate Guide

Test SDK and client-library docs against the package you ship: build the wheel or npm tarball, install it clean, run every example, and gate the release in CI.

Outlined documentation pages with a lime pulse line running out of the stackGuide

How to Test Quickstarts and Tutorials in Your Docs

Test the onboarding path a new reader follows: run quickstarts in a clean environment, in page order, sort real bugs from credentials and fragments, and wire it into CI.

Outlined documentation pages with a lime pulse line running out of the stackGuide

How to Test CLI Documentation: Commands, Flags and Output

Test the commands a CLI page promises: install in a clean container, run examples in order, compare flags with --help, check exit codes and output, and run it in CI.

Outlined documentation pages with a lime pulse line running out of the stackGuide

How to Test API Reference Docs: Requests, Responses and SDKs

Test API reference pages against the contract they publish: methods, parameters, request and response examples, SDK snippets, status codes and OpenAPI samples.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Docs testing for API-first companies

Keep API quickstarts, SDK snippets and curl examples working across releases.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Docs testing for CLI and developer-tool vendors

Test developer-tool install paths, package managers and command examples across releases.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing README Code Examples: Install, Usage and CI

Keep README install commands and usage examples working with clean environments, output checks and CI.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Notebooks and Executable Docs: Cells, Kernels and Output

Test notebooks in fresh kernels, check meaningful output and manage dependencies, data and drift in CI.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Docs in GitHub Actions: Pull Requests and Scheduled Checks

Run documentation example checks in GitHub Actions with practical guidance on schedules, path filters, caching, secrets and reports.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Code Examples in MkDocs, Docusaurus and Sphinx Sites

Find and test documentation examples in Markdown, MDX and reStructuredText, alongside site builds and link checks.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Python Docs Testing: Doctest, Pytest and Markdown

Test Python documentation with doctest, pytest, Markdown example execution and isolated environments.

Outlined documentation pages with a lime pulse line running out of the stackGuide

JavaScript Docs Testing: Node, TypeScript and Modules

Test Node and TypeScript documentation examples across module formats, package versions and type checks.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Go documentation examples

Test Go example functions and Markdown snippets against the intended module versions in clean environments.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Sphinx Docs Testing: doctest, code-block and MyST

Test Sphinx documentation examples: what the doctest and linkcheck builders prove, code-block and literalinclude, MyST fences, and what a Markdown scan covers.

Outlined documentation pages with a lime pulse line running out of the stackGuide

ReadMe Docs Testing: CLI, OpenAPI and Code Examples

Test ReadMe documentation examples: docs-as-code and bi-directional sync, what lint and oas:validate prove, Tabs variants and runnable code.

Outlined documentation pages with a lime pulse line running out of the stackGuide

TypeScript Docs Testing: tsc --noEmit and Runtime

Test TypeScript documentation examples: type-check snippets with tsc --noEmit in a consumer project, then run them, and what each check proves.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Docusaurus Docs Testing: Code Blocks, Tabs and MDX

Test Docusaurus documentation examples: builds vs runnable code, code block metadata, Tabs install variants, MDX pages and clean-container runs.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Mintlify Docs Testing: CodeGroup, Tabs and the CLI

Test Mintlify documentation examples: docs.json, MDX pages, CodeGroup and Tabs variants, what mint broken-links and mint validate prove, and clean runs.

Outlined documentation pages with a lime pulse line running out of the stackGuide

MkDocs Docs Testing: Code Examples, Tabs and Snippets

Test MkDocs documentation examples: strict builds, Material tabs, Snippets includes, mkdocstrings pages and clean-container runs.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Installation Instructions: pip, npm and Containers

Test documented install steps in clean environments: pip and extras, venv, npm install vs npm ci, containers and the first import.

Outlined documentation pages with a lime pulse line running out of the stackGuide

AI SDK Docs Testing: LLM Examples, Keys and Drift

Test AI and LLM SDK documentation examples: requests, responses, streaming, tool calls, credentials, model retirements and CI.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing migration guides and changelog examples

Test before and after examples against the right releases and make migration documentation part of the release gate.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Docs Testing Checklist: Code Examples Before Release

A practical pre-release checklist for testing documentation examples, reviewing gaps and verifying published packages.

Outlined documentation pages with a lime pulse line running out of the stackGuide

The Cost of Broken Code Examples in Documentation

Understand how broken documentation examples create friction in developer adoption and support, and how to reduce it.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Rust documentation examples

Test Rust rustdoc examples and cargo documentation tests, and keep native Rust checks because compiled Rust fences are recognized but not executed.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing VitePress documentation examples

Test VitePress Markdown examples separately from the site build, including code groups, includes and what a plain Markdown scan covers.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing docs in GitLab CI

Run documentation example checks in GitLab CI jobs, keep site builds separate from execution, and review what a scan covers and skips.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing JSON, TOML and YAML examples in docs

Test JSON, TOML and YAML config examples in documentation: parse, schema and tool checks, honest fence labels, fragments, CI jobs and what a scan covers.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Java documentation examples

Test Java examples in READMEs, SDK docs and Javadoc: the source launcher, javac, JShell scripts, assertions, @snippet files, CI and what a scan covers.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing PHP documentation examples

Test PHP examples in docs: php -l lint, clean-directory runs, assertions with zend.assertions, Composer scratch projects, PHPUnit, CI and scan coverage.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing C# documentation examples

Test C# examples in docs: .NET 10 file-based apps, dotnet build with warnings as errors, test projects, XML doc comments, CI and scan coverage.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Ruby documentation examples

Test Ruby examples in docs: ruby -c syntax checks, clean-directory runs, bundler/inline, minitest assertions, YARD examples, CI and scan coverage.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Kotlin documentation examples

Test Kotlin examples in docs: kotlinc runnable JARs and scripts, -Werror, KDoc @sample in compiled source, kotlinx-knit, fence labels, CI and scan coverage.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Swift documentation examples

Test Swift examples in docs: swift scripts, swiftc -typecheck, DocC snippets compiled by swift build, Swift Testing assertions, CI containers and scan coverage.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing curl and HTTP examples in API docs

Test curl examples in API docs: --fail-with-body, status and JSON checks against a local stub, http fences, credentials and what a docs scan checks.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Astro Starlight documentation examples

Test code examples in Astro Starlight docs: src/content/docs inventory, Tabs and Expressive Code, Markdoc pages, a Node check script, CI and scan coverage.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Nextra documentation examples

Test code examples in Nextra docs: content/ and app/ sources, fence metadata, Tabs and npm2yarn, a Node check script, CI and an honest scan limitation.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Docs testing for open-source projects

Test the code examples in open-source docs and READMEs: pull requests from forks, release and scheduled checks, contributor guidelines, triage and the Open source plan.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Docs testing for technical writers and docs teams

How technical writers and docs teams test the code examples they publish: docs-as-code checks, style-guide rules, reading a report, routing findings to engineers.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Docs testing for DevRel teams

How developer advocates test quickstarts, tutorials, workshops and sample READMEs: an inventory, a launch and release cadence, reading a report, and honest reporting.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Hugo documentation examples

Test the code examples in Hugo docs: fences with brace options, the highlight shortcode, Docsy tabs, drafts and theme example sites, scan scope and CI.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing GitBook documentation examples

Test the code examples in GitBook docs synced to Git: the space root, code tags, tabs, reusable includes, invisible characters, scan scope and CI.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing SQL examples in documentation

Test SQL examples in docs: run fences in page order on a fresh database, assert results, handle dialects, SQLite STRICT typing, psql ON_ERROR_STOP and CI.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing mdBook documentation examples

Test the code in an mdBook: what mdbook test covers, rust attributes, hidden lines, include directives, untagged output fences and a scan-ready copy for CI.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Docsify documentation examples

Test the code examples in Docsify docs: embedded code files and fragments, docsify-tabs tab sets, Prism grammars, scan scope and a CI check.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Jekyll documentation examples

Test the code examples in Jekyll docs: include tags, site variables, highlight tags, posts and _site copies, a scan-ready copy and Ruby hooks.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Antora and AsciiDoc documentation examples

Test the code examples in Antora docs: example includes, tagged regions, attributes, failing the build on missing includes and a Markdown copy to scan.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Fumadocs documentation examples

Test the code examples in Fumadocs docs: npm fences and package-manager tabs, tab groups, the Tabs component, includes, pycon highlighting and a scan-ready copy.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing versioned Docusaurus docs

Test every Docusaurus version readers can reach: versioned_docs copies, versions.json, partials, tabs, per-version scans and old-version triage.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Read the Docs documentation examples

Test the code examples on a Read the Docs site: .readthedocs.yaml build jobs, a pycon gate, latest and stable versions, Sphinx, MyST and .rst coverage.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Eleventy documentation examples

Test the code examples in Eleventy docs: Liquid pre-processing, global data, include tags, ignored drafts, raw tags and a rendered copy to scan.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Zola documentation examples

Test the code examples in Zola docs: Tera content templating, raw tags, config values, hide_lines, drafts, blog posts and a scan-ready copy.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Quarto documentation examples

Test the code examples in Quarto docs: executable cells, display-only fences, freeze and _freeze, a CI profile, cell options and a copy to scan.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Hexo documentation examples

Test the code examples in Hexo docs: posts, drafts, scaffolds, codeblock and include_code tags, a build check and a scan-ready copy.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing pdoc documentation examples

Test the code examples in pdoc docs: doctest for >>> sessions, fenced docstring examples, the README, private items and a copy to scan.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Doxygen documentation examples

Test the code examples in Doxygen docs: compiled example files, snippets, Markdown pages, WARN_AS_ERROR and what a scan can and cannot check.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing TypeDoc documentation examples

Test the code examples in TypeDoc docs: example tags, includeCode regions, project documents, a compiler check of extracted examples and a scan.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing JSDoc documentation examples

Test the code examples in JSDoc docs: example tags, captions, source patterns, tutorials, a doclet export and a scan-ready copy with assertions.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing docs examples with pre-commit hooks

Check docs code examples with pre-commit: local hooks, files filters, always_run, pass_filenames, SKIP and --no-verify, and what to leave for CI.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing documentation examples with Deno

Run docs code examples with deno test --doc: JSDoc and Markdown examples, imports, hashbang permissions, ignored blocks and deno check --doc-only.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing documentation examples with Sybil

Test Python docs examples with Sybil and pytest: Markdown parsers, invisible setup, skips, clear-namespace, docstrings and pycon fences a scan can read.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Markdoc documentation examples

Test the code examples in Markdoc docs: variables in fences, partials, if/else, custom tabs, validate in CI and a scan-ready copy from transform.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Markdown examples with phmdoctest

Test Python examples in README and Markdown files with phmdoctest: sessions, output blocks, directives, --report, generated pytest files and pycon fences.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Markdown code blocks with pytest-markdown-docs

Run Markdown python fences as pytest tests with pytest-markdown-docs: globals hook, fixtures, continuation, notest, retry and pinning the released version.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing command line docs with prysk and Cram

Test CLI docs with prysk and Cram: .t transcripts, exit statuses, (re) and (glob) matches, and generating tests from the console blocks in your Markdown.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Python docstring examples with xdoctest

Run docstring examples with xdoctest: the pytest plugin, google and freeform parsing, permissive output matching, directives, and what it does not check.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing multi-language docs examples with byexample

Test docs examples with byexample: prompt-based language detection, the -l selection, +pass, +skip and timeouts, capture tags, and hidden setup in comments.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Markdown code blocks with mktestdocs

Run Markdown code blocks under pytest with mktestdocs: exact fence labels, memory=True for shared state, bash blocks, custom executors and docstring checks.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing README code blocks with pytest-codeblocks

Run README and Markdown code blocks with pytest-codeblocks: exact python, sh and bash labels, cont, skip and xfail markers, expected output, and gaps.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Markdown code examples in any language with txm

Test annotated Markdown examples with txm: program, in, out, err, check and exit annotations, TAP output, exact matching, and blocks it never runs.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing docs examples that need API keys

Test credential-gated docs examples: honest placeholders, offline stubs and fixtures, live sandbox jobs, CI secrets and fork rules, and how a scan classifies them.

A machine blueprint above a ruled documentation page, with a caliper measuring between themGuide

Documentation Drift: How to Detect It Before Users Do

What documentation drift is, why code examples drift first, and practical ways to detect it: ownership, release checks, link and execution tests.

See which of your code samples still run.

Send us a public repository. Our team runs DocsAlive on its docs and emails you the real report within 2 business days. Free, no signup.