Repository navigation
v1.8.0 — Block Index Targeting
New Feature
Block Index Targeting (file:N)
Run a specific PHP code block within a markdown file using file:N syntax:
vendor/bin/doctest README.md:3 # Run only the 3rd PHP block
vendor/bin/doctest docs/api.md:1 -v # Run 1st block with verbose output- 1-based indexing —
:1targets the first PHP block,:2the second, etc. - Fast iteration — Ideal for debugging or developing a single block without running the entire file
- Exit code 3 — Returned when the specified block index is out of range (no testable blocks found)
- Works with all other options (
-v,-vv,--stop-on-failure, etc.)
Implementation:
DocTestConfig— NewblockIndicesproperty stores file-to-index mappingDocTestCommand— Parsesfile:Nsyntax from CLI arguments before config creationDocTest— Filters extracted blocks by index after extraction, before execution
Documentation
- Cross-language comparison page — New docs page comparing DocTest with doctest tools in Python, Rust, Elixir, and Go
- Block index documentation —
file:Nsyntax added to CLI options reference - Quick reference example —
file:Nusage added to CLI index page
Bug Fix
- VitePress rendering — Escaped mustache syntax (
{{ }}) in comparison docs to prevent template processing errors
Full Changelog: v1.7.0...v1.8.0