Repository navigation
[doc] Sync the rst-to-myst skill back and convert doctests to testcode - #67593
Conversation
Replace the frozen rst-to-myst skill with its current version, which kept evolving out of tree while the prose pages converted. The skill now ships its converter, doctest parity check, and render diff under scripts/, and its layout section describes what's left as .rst. Hard rule 4 now matches #67432: a converted page rewrites .. doctest:: blocks and >>> prompts as {testcode} plus {testoutput}, so pytest-sphinx owns every executed block. The converter's flag points at that rewrite. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request updates the rst-to-myst skill documentation and introduces several helper scripts, including rst2myst.py for mechanical RST-to-MyST conversion and doctest_parity.py to verify doctest coverage parity. The review feedback highlights several instances where file reading and subprocess execution should explicitly specify utf-8 encoding to prevent platform-dependent decoding errors.
| total = files = 0 | ||
| for p in sorted(q for ext in ("md", "rst") for q in Path(root).rglob(f"*.{ext}")): | ||
| try: | ||
| secs, ex = parse(p.read_text(), p.suffix) |
There was a problem hiding this comment.
Reading files without specifying an encoding can lead to platform-dependent decoding errors (e.g., on Windows where the default encoding might not be UTF-8). It is highly recommended to explicitly specify encoding="utf-8" when reading documentation files.
| secs, ex = parse(p.read_text(), p.suffix) | |
| secs, ex = parse(p.read_text(encoding="utf-8"), p.suffix) |
| bad = 0 | ||
| for md in map(Path, paths): | ||
| try: | ||
| n, leaks = stock_fence_leaks(md.read_text()) |
There was a problem hiding this comment.
Reading files without specifying an encoding can lead to platform-dependent decoding errors. Explicitly specify encoding="utf-8" to ensure consistent behavior across different platforms.
| n, leaks = stock_fence_leaks(md.read_text()) | |
| n, leaks = stock_fence_leaks(md.read_text(encoding="utf-8")) |
| before = subprocess.run( | ||
| ["git", "show", f"{base}:{rst}"], | ||
| check=True, | ||
| capture_output=True, | ||
| text=True, | ||
| ).stdout |
There was a problem hiding this comment.
When running subprocesses that capture text output, using text=True decodes the output using the system's default encoding, which can vary across platforms. Specifying encoding="utf-8" explicitly ensures that the git output is always decoded correctly as UTF-8.
| before = subprocess.run( | |
| ["git", "show", f"{base}:{rst}"], | |
| check=True, | |
| capture_output=True, | |
| text=True, | |
| ).stdout | |
| before = subprocess.run( | |
| ["git", "show", f"{base}:{rst}"], | |
| check=True, | |
| capture_output=True, | |
| encoding="utf-8", | |
| ).stdout |
| except subprocess.CalledProcessError: | ||
| print(f"SKIP {md}: no {rst} at {base}") | ||
| continue | ||
| (sa, ea), (sb, eb) = parse(before, ".rst"), parse(md.read_text(), ".md") |
There was a problem hiding this comment.
Reading files without specifying an encoding can lead to platform-dependent decoding errors. Explicitly specify encoding="utf-8" to ensure consistent behavior across different platforms.
| (sa, ea), (sb, eb) = parse(before, ".rst"), parse(md.read_text(), ".md") | |
| (sa, ea), (sb, eb) = parse(before, ".rst"), parse(md.read_text(encoding="utf-8"), ".md") |
| if len(argv) != 2: | ||
| sys.exit(__doc__) | ||
| c = Converter() | ||
| sys.stdout.write(c.document(open(argv[1]).read())) |
There was a problem hiding this comment.
Opening files without specifying an encoding can lead to platform-dependent decoding errors, especially when documentation files contain non-ASCII characters (such as unicode symbols). Explicitly specify encoding="utf-8" when opening files.
| sys.stdout.write(c.document(open(argv[1]).read())) | |
| sys.stdout.write(c.document(open(argv[1], encoding="utf-8").read())) |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 60a4f0c. Configure here.
- Read files and git output as UTF-8. - doctest_parity.py exits with an error when --base doesn't resolve, instead of skipping every file and passing. - rst2myst.py escapes a leading `%` in prose lines and list-table cells, which MyST would otherwise read as a comment and drop. - rst2myst.py opens a directive with a tilde fence when its argument holds a backtick, since a backtick fence can't carry one. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>

Description
Brings the
rst-to-mystagent skill indoc/.claude/skills/rst-to-myst/up to date. The copy here was frozen on 2026-09-18 while the skill kept evolving outside the repo during the prose conversion. With the prose pages converted, this makes the in-repo copy the only one. The skill isn't documentation and isn't built or tested by CI.What changes:
SKILL.mdgains every rule and construct note that the conversions since mid-September turned up. It ships three scripts underscripts/: therst2myst.pyconverter, thedoctest_parity.pycoverage check, andrender_diff.py, which moves from the skill root with no content change... doctest::blocks or>>>prompts. Real ones become{testcode}plus{testoutput}, and ones that can't run in CI become plainpythonandtextblocks, sopytest-sphinxowns every executed block. The converter still emits a{doctest}fence for.. doctest::, and its flag now points at that rewrite..rstsources remain: the*/api/reference pages, the autosummary templates,_includes/rllib/new_api_stack.rst, andray-observability/reference/cli.rst.def.Related issues
Follows #67432, which converted the last five pages that had
>>>prompts.Additional information
Duplicate check
No open PR touches
doc/.claude/skills/rst-to-myst/. I checked withgh pr list --state openfiltered on that path.Testing
python3 doc/.claude/skills/rst-to-myst/scripts/rst2myst.py --selftest: 80/80 cases pass, before and after formatting.python3 doc/.claude/skills/rst-to-myst/scripts/doctest_parity.py --selftest: 7/7 cases pass.pre-commit run --fileson every changed file passes, including ruff and black..buildkite/test.rules.txtskipsdoc/.claude/, so this PR runs no library tests.This PR changes an agent skill, and it comes from a docs-team session. It was prepared with AI assistance (Claude Code). I reviewed every changed line.
🤖 Generated with Claude Code