Repository navigation
Test that the code examples in the docs run and match their output - #244
Merged
Merged
Conversation
Add DocumentationTests to tests.py: * test_tutorial runs doc/tutorial.rst as a doctest. * test_commandline runs the "$ " shell sessions of the bash code blocks in doc/commandline.rst against the CLI of this checkout and compares stdout with the documented output. "$ cat FILE" provides the example input files. The new tests uncovered several broken examples, which are fixed: * tutorial: multi-line statements lacked "..." continuation prompts, from_string() was called with a placeholder string, results were shown for assignments, and the result of from_string() was discarded. * commandline: jsondiff output used an outdated operation order and key order, jsondiff prints nothing (not "[]") for equal files, and the usage texts were outdated. simplejson is added to the dev requirements for the tutorial examples, and the doc sources are shipped in the sdist, which already includes tests.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PewzpkVb4tA4eWEkCzH9vT
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The changes are focused, preserve existing CLI test behavior, and have no unresolved blocking findings.
No open issues 🎉
What changed in this PR
Adds automated checks for documentation examples so the tutorial and command-line examples stay consistent with the library and CLI.
Changes:
- Runs tutorial examples as doctests and checks documented shell-session output using a shared CLI runner.
- Corrects tutorial examples, CLI output, and usage text.
- Adds the tutorial’s development dependency and includes documentation sources in source distributions.
| File | Description |
|---|---|
tests.py |
Adds documentation tests and extracts a shared CLI runner. |
requirements-dev.txt |
Adds simplejson for tutorial examples. |
MANIFEST.in |
Includes documentation sources in source distributions. |
doc/tutorial.rst |
Makes examples executable and corrects displayed results. |
doc/commandline.rst |
Updates CLI usage text and expected output. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add DocumentationTests to tests.py:
in doc/commandline.rst against the CLI of this checkout and compares
stdout with the documented output. "$ cat FILE" provides the example
input files.
The new tests uncovered several broken examples, which are fixed:
from_string() was called with a placeholder string, results were shown
for assignments, and the result of from_string() was discarded.
order, jsondiff prints nothing (not "[]") for equal files, and the
usage texts were outdated.
simplejson is added to the dev requirements for the tutorial examples, and
the doc sources are shipped in the sdist, which already includes tests.py.
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01PewzpkVb4tA4eWEkCzH9vT