Correct the stale README examples and fill the documentation gaps - #146
Merged
Merged
Conversation
The PyPI description listed seven of the ten formats Graphtage registers, omitting JSON5, HTML, and Python pickle. Match README.md and docs/index.rst, which both already list all ten. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GypKU5KdLfs2Cf8kS2TzJa
Pull request #132 changed the edit tie-break order to emit removals before insertions, and DictNode.from_dict sorts keys when it builds a tree, so every JSON example printed something other than what it claimed. Each block is now the verbatim output of the command above it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GypKU5KdLfs2Cf8kS2TzJa
The Matching Options section opened by describing `--dict-strategy match`, contradicting the list below it and graphtage/__main__.py, where `auto` is the default. The copyright notice trailed docs/conf.py by three years. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GypKU5KdLfs2Cf8kS2TzJa
The Installation section was a bare pip command. It now states the supported Python versions from pyproject.toml, names both console scripts the package installs, and points at the dev extra. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GypKU5KdLfs2Cf8kS2TzJa
Adds the file type overrides, the short forms of --dict-strategy and --no-key-edits, --debug, and a section on --match-if and --match-unless, which were the only user-facing surface of graphtage.expressions and graphtage.constraints and appeared in neither the README nor the docs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GypKU5KdLfs2Cf8kS2TzJa
The README documented the exit statuses of the diff driver but never those of graphtage itself, which is what a script or CI job needs. Also documents --version and -dumpversion. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GypKU5KdLfs2Cf8kS2TzJa
The MIME registration snippet no longer matched the code: the pickle module dropped it when register_mimetypes() centralized the registrations in graphtage/__main__.py. Following the old snippet from an out-of-tree filetype silently failed, because register_mimetypes() opens with mimetypes.init(), which discards any earlier add_type() call. The Filetype sketch raised IndentationError as written, since two methods had comment-only bodies, and used os and PickleDecodeError without importing them. It is now the real implementation, verified to build a tree. The page also described only the Filetype subclass, omitting the module import, the MIME entry, and the four formatter rules that a working format needs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GypKU5KdLfs2Cf8kS2TzJa
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GypKU5KdLfs2Cf8kS2TzJa
Collaborator
Author
|
The code defects noted in the PR description are now tracked:
|
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.
Corrects the stale and missing documentation in
README.md,docs/filetypes.rst,docs/index.rst, and the PyPI description inpyproject.toml. No source file changes.What was stale
Every JSON output example in the README printed something other than what it claimed. Two changes had invalidated them:
DictNode.from_dict(graphtage/graphtage.py:548-550) sorts keys when it builds a tree, so output orders keys alphabetically regardless of input order."bar"renaming to"zab"renders as"b̶z̟ar̶b̟", not"z̟b̶ab̟r̶".Regenerated: the headline example, all four Output Formatting examples, and the marked-up key in the
git diffexample. The YAML block in the Git Integration section still reproduces byte for byte and is unchanged.Two factual errors. The Matching Options section opened by describing
--dict-strategy matchwhile the list three lines below correctly namedautoas the default (graphtage/__main__.py:293-304). The copyright notice read 2023 whiledocs/conf.pyread 2026.docs/filetypes.rstdocumented code that no longer exists. The MIME registration snippet was moved out ofgraphtage/pickle.pyinto the centralizedregister_mimetypes()ingraphtage/__main__.py. Worse, an out-of-treeFiletypethat followed the old snippet failed silently:register_mimetypes()opens withmimetypes.init(), which rebuilds the globaltypes_mapand discards anyadd_type()call made earlier at import time. The page now says where registration has to happen, and gives the working sequence for a filetype defined outside the package.The
Filetypesketch on that page was not valid Python:build_treeandget_default_formatterhad comment-only bodies (IndentationError), andosandPickleDecodeErrorwere used without imports. It is now the realgraphtage.pickleimplementation with absolute imports, verified to build a tree.What was missing
README:
--from-<type>/--to-<type>overrides (20 generated flags),--from-mime/--to-mime,-ds,--no-key-edits/-k,--debug,--version/-v, and-dumpversion, none of which appeared anywhere in the README or the docs.--match-ifand--match-unless, the only user-facing surface ofgraphtage.expressionsandgraphtage.constraints, with a worked example.graphtageitself. The README stated it for the diff driver but not for the command a script or CI job calls, where1means "the inputs differ", not "an error occurred".devextra. The Git Integration section previously assumedgraphtage-git-diffexisted without saying where it came from.docs/filetypes.rstdocumented only theFiletypesubclass. It now also covers importing the module ingraphtage/__init__.py, adding the extension toregister_mimetypes(), and the four rules governing formatters: routing sequence printing throughSequenceFormatter.print_SequenceNode, aliasingprint_UnorderedListNodetoprint_ListNode, marking helper formattersis_partial = True, and defining eachprint_<NodeType>once per formatter tree.pyproject.toml's description, which is what shows on PyPI, listed seven of the ten registered formats, dropping JSON5, HTML, and Python pickle.Verification
docs/filetypes.rstsketch runs: with its identifiers renamed to avoid colliding with the shippedgraphtage.pickle, it registers, builds a tree from a real.pklfile, and returns its formatter.sphinx-build -W --keep-going -E -b html docs docs/_build/htmlproduces the same two warnings asmaster(both ingraphtage/__init__.pydocstrings, owned by another PR in this series) and no new ones.ruff check graphtage test docs bindistpasses.Defects found, not fixed
These are behaviors observed while verifying the examples. No source file was changed.
--match-ifcannot be used as its--helptext describes.MatchIfbindsfromandtoto rawTreeNodeobjects, whileMatchUnlessbinds them toto_obj()results (graphtage/constraints.py:24,35). The constraint is applied to every node in the tree (__main__.py:338-342), andMatchIfreturns aReplacewhen the expression raises, so the help text's own example,--match-if "from['foo'] == to['bar']", refuses every pair including the two roots and collapses the whole diff into one replacement. Confirmed withfrom['id'] == to['id'],from['id'].value == to['id'].value, andfrom.to_obj()['id'] == to.to_obj()['id'], all of which replace the entire tree.--match-unlessworks because its failure mode is "leave the pair unconstrained". The README documents the working option and warns about the other; the underlying inconsistency is worth fixing separately.A
Replaceedit inside a list prints its replacement twice. Diffing[1, {"a": 1}]against[1, [2, 3]]prints{...} -> [2, 3] -> [2, 3]. The sameReplaceas a dictionary value ({"x": {"a": 1}}against{"x": [2, 3]}) prints correctly, so this is specific to sequence rendering.-dumpversionprints0 . 3 . 1.__main__.py:219is' '.join(map(str, version.__version__)), butversion.__version__is now the string"0.3.1"(graphtage/version.py:7), so the join iterates characters. It looks like a leftover from when__version__was a tuple;__version_tuple__still exists for that.--join-dict-itemsindents oddly. With-jd, a nested list is printed with an 8-space item indent and a 4-space closing bracket even though the enclosing dictionary is on one line:{"bar": "baz","foo": [\n 1,\n 2,\n 3\n ]}. The README now documents what the tool prints rather than what it ought to print.A closed stdout raises rather than exiting quietly. Piping output to a command that exits early (
graphtage a.json b.json | head -3) produces three chainedBrokenPipeErrortracebacks instead of a clean exit.🤖 Generated with Claude Code
https://claude.ai/code/session_01GypKU5KdLfs2Cf8kS2TzJa