Skip to content

CLI Usage

DocTest provides a command-line interface via vendor/bin/doctest.

Basic Usage

bash
# Run with default paths (docs/ and README.md)
vendor/bin/doctest

# Test specific files
vendor/bin/doctest docs/getting-started.md docs/api.md

# Test a directory
vendor/bin/doctest docs/

Quick Reference

bash
vendor/bin/doctest [files...] [options]
OptionShortDescription
--filter-fFilter blocks by content or file name
--excludeExclude files matching pattern
--dry-runParse only, don't execute
--stop-on-failureStop on first failure
--config-cPath to config file
-vShow per-assertion details
-vvAlso show source code on failure

See Options Reference for full details.

Console Output

DocTest reports results in a compact format:

README.md
  :3 ✔ echo 'Hello, World!';  [1/5]  0.02s
  :7 ✔ echo 2 + 3;            [2/5]  0.01s
  :11 ✔ echo date('Y');       [3/5]  0.01s
  :15 ⊘ $config = require...  [4/5]
  :19 ✖ echo $result;         [5/5]  0.02s

----------------------------------------
Blocks: 5  Passed: 3  Failed: 1  Skipped: 1  Duration: 0.12s
SymbolMeaning
Passed
Failed
Skipped (ignored)

Released under the MIT License.