Repository navigation
v1.9.0 — Update Mode & Shiki Bug Fix
New Features
--update / -u Flag
Automatically updates outdated assertion values in markdown files — inspired by Jest's --updateSnapshot. Instead of manually finding and fixing stale values, run doctest --update and let it rewrite them for you.
Updatable assertion types:
<!-- doctest: value -->(output assertions without wildcards)<!-- doctest-json: {...} -->(JSON assertions)// => value(result comment assertions)
Non-updatable (require human judgment): <!-- doctest-contains -->, <!-- doctest-matches -->, <!-- doctest-expect -->
# Update all stale assertions
vendor/bin/doctest docs/ --update
# Update a specific block
vendor/bin/doctest docs/api.md:42 --updateMutual exclusions: --update cannot be combined with --dry-run or --stop-on-failure.
<!-- doctest-output --> Directive
Marks a display-only output block that gets refreshed on --update but is never asserted against during normal runs. Display output ≠ assertion — they serve different purposes.
\`\`\`php
echo "Hello\nWorld";
\`\`\`
<!-- doctest-output -->
\`\`\`
Hello
World
\`\`\`Options: <!-- doctest-output: lines=5 --> (first N lines), <!-- doctest-output: tail=3 --> (last N lines)
Update Mode Reporter
✎(pencil) symbol for updated assertions- Summary: "Updated: N assertions in M files"
- Exit code 0 on successful update, 1 if non-updatable failures remain
Bug Fixes
- Shiki
<?php // [!code hide]double<?phpcrash —CodeGeneratorwas re-parsingrawCode(unfiltered) instead of usingexecutableCode(ShikiFilter-processed), producing<?php\n<?php\n...syntax errors. Fixed by storingresultComments/debugMarkersonCodeBlockand using the pre-processedexecutableCodepipeline. - Malformed HTML comment protection —
MarkdownRewriternow handles malformed multi-line comments without crashing - Missing result_comment updates —
Executornow collects all assertion details before returning, enabling// =>updates --update --stop-on-failurevalidation — Mutual exclusion enforced at CLI level
Refactoring
- Batch display block rewrite with pre-computed progress (race condition prevention)
- Removed dead
allAssertionsvariable inCodeBlockExtractor - Removed dead
processableIndexMapvariable inExecutor
Documentation
- Added
--updateoption to CLI reference and options page - Added update feature documentation with workflow guide
- Added
doctest-outputto HTML comment types table - Added update mode exit codes section
- Added
--parallelto quick reference table - Added missing exit code 3 to CI/CD docs
- Aligned wildcard examples and mutual exclusion cross-references