Skip to content

v1.9.0 — Update Mode & Shiki Bug Fix

Choose a tag to compare

@deligoez deligoez released this 22 Feb 19:57
· 5 commits to master since this release

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 --update

Mutual 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 <?php crash — CodeGenerator was re-parsing rawCode (unfiltered) instead of using executableCode (ShikiFilter-processed), producing <?php\n<?php\n... syntax errors. Fixed by storing resultComments/debugMarkers on CodeBlock and using the pre-processed executableCode pipeline.
  • Malformed HTML comment protection — MarkdownRewriter now handles malformed multi-line comments without crashing
  • Missing result_comment updates — Executor now collects all assertion details before returning, enabling // => updates
  • --update --stop-on-failure validation — Mutual exclusion enforced at CLI level

Refactoring

  • Batch display block rewrite with pre-computed progress (race condition prevention)
  • Removed dead allAssertions variable in CodeBlockExtractor
  • Removed dead processableIndexMap variable in Executor

Documentation

  • Added --update option to CLI reference and options page
  • Added update feature documentation with workflow guide
  • Added doctest-output to HTML comment types table
  • Added update mode exit codes section
  • Added --parallel to quick reference table
  • Added missing exit code 3 to CI/CD docs
  • Aligned wildcard examples and mutual exclusion cross-references