Skip to content

[doc] Sync the rst-to-myst skill back and convert doctests to testcode - #67593

Merged
dstrodtman merged 2 commits into
masterfrom
doc-1696-rst-to-myst-sync-back
Oct 30, 2026
Merged

dstrodtman merged 2 commits into
masterfrom
doc-1696-rst-to-myst-sync-back

Conversation

@dstrodtman

Copy link
Copy Markdown
Contributor

Description

Brings the rst-to-myst agent skill in doc/.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:

  • The current skill. SKILL.md gains every rule and construct note that the conversions since mid-September turned up. It ships three scripts under scripts/: the rst2myst.py converter, the doctest_parity.py coverage check, and render_diff.py, which moves from the skill root with no content change.
  • Hard rule 4 matches [doc] Convert the remaining page doctests to testcode and plain code blocks #67432. A converted page no longer keeps .. doctest:: blocks or >>> prompts. Real ones become {testcode} plus {testoutput}, and ones that can't run in CI become plain python and text blocks, so pytest-sphinx owns every executed block. The converter still emits a {doctest} fence for .. doctest::, and its flag now points at that rewrite.
  • A status section. It records which .rst sources remain: the */api/ reference pages, the autosummary templates, _includes/rllib/new_api_stack.rst, and ray-observability/reference/cli.rst.
  • Lint fixes. Ray's black reformats the two new scripts, and ruff E731 turns one lambda into a 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 with gh pr list --state open filtered 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 --files on every changed file passes, including ruff and black.

.buildkite/test.rules.txt skips doc/.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

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]>
@dstrodtman
dstrodtman requested review from a team as code owners October 30, 2026 13:07

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
n, leaks = stock_fence_leaks(md.read_text())
n, leaks = stock_fence_leaks(md.read_text(encoding="utf-8"))

Comment on lines +124 to +129
before = subprocess.run(
["git", "show", f"{base}:{rst}"],
check=True,
capture_output=True,
text=True,
).stdout

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
(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()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
sys.stdout.write(c.document(open(argv[1]).read()))
sys.stdout.write(c.document(open(argv[1], encoding="utf-8").read()))

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

❌ 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.

@dstrodtman dstrodtman added the go add ONLY when ready to merge, run all tests label Oct 30, 2026
- 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]>
@dstrodtman
dstrodtman merged commit b0271fd into master Oct 30, 2026
6 checks passed
@dstrodtman
dstrodtman deleted the doc-1696-rst-to-myst-sync-back branch October 30, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants