Skip to content

v1.8.0 — Block Index Targeting

Choose a tag to compare

@deligoez deligoez released this 11 Feb 22:43
· 53 commits to master since this release

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 — :1 targets the first PHP block, :2 the 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 — New blockIndices property stores file-to-index mapping
  • DocTestCommand — Parses file:N syntax from CLI arguments before config creation
  • DocTest — 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:N syntax added to CLI options reference
  • Quick reference example — file:N usage 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