Skip to content

[doc] rst-to-myst: add the sphinx-design card-grid mapping - #65471

Closed
dstrodtman wants to merge 2 commits into
doc-1519-rst-myst-skill-fixesfrom
doc-1521-rst-myst-card-mapping
Closed

dstrodtman wants to merge 2 commits into
doc-1519-rst-myst-skill-fixesfrom
doc-1521-rst-myst-card-mapping

Conversation

@dstrodtman

Copy link
Copy Markdown
Contributor

Why are these changes needed?

Stacked on #65469. Converting the seven card-grid front doors in #65470 exercised a part of the rst-to-myst skill that had no mapping at all: grid, grid-item-card, grid-item, button-ref, button-link, and div. The skill covered sphinx-design tabs and dropdowns but stopped short of cards, which are the dominant construct in batches 4 through 8.

It also had no entry for RST named hyperlink targets (`text`_ plus a .. _text: url definition). ray-overview/installation.rst alone has twenty.

What changed

Mapping rows for the six sphinx-design directives above.

A construct note on card grids, covering the two things that aren't obvious:

  • The ^^^ header and +++ footer separators need no translation. sphinx-design matches them with REGEX_HEADER/REGEX_FOOTER in cards.py and splits them out of the raw content lines before anything parses them, so they're format-agnostic.
  • GridDirective, GridItemCardDirective, div, and Ray's own callout/annotations all call self.state.nested_parse, which under MyST parses their content as Markdown. RST left inside a native card doesn't warn — it renders as literal text through a green fail_on_warning build. Everything nested has to convert in the same pass, and the render diff is the only check that catches it.

That second point also fixes a dangling reference: Verification step 4 already said the render diff is "the only step that catches Hard rule 5 or the nested_parse degradation below," and there was no such note below. Now there is.

The note also records that four already-Markdown pages (cluster/vms/index.md, cluster/kubernetes/index.md, ray-overview/index.md, serve/index.md) wrap their grids in {eval-rst}, and says not to copy that into new conversions. A follow-up PR converts those four.

A construct note on named hyperlink targets — inline them as Markdown links, except where an {eval-rst} table's cells reference them, in which case the definitions stay RST inside that same block so no target name is defined twice.

Two verified facts, both checked against the pinned source rather than assumed:

  • sphinx_design==0.7.0 supports MyST first-class. Its own docs are MyST, it ships a snippets/myst/ tree, and its directives register through app.add_directive, so MyST's {name} dispatch reaches them like any other directive.
  • _replace_numbers() in doc/source/_ext/callouts.py discards its own result (content.replace(...) with no assignment), so the <1>-to-① substitution only happens in CalloutIncludePostTransform, over literal blocks. Annotation text keeps literal <1> markers under either parser. Flagging rather than fixing, since it's outside this PR's scope and the rendering is longstanding.

Not a duplicate

gh pr list --repo ray-project/ray --state open --search "rst-to-myst" returns #65469, which this is stacked on and which touches different sections of the same file. No other open PR touches doc/.claude/skills/.

Related issue number

Follow-up to #65469. Motivated by #65470, which deliberately doesn't carry this change, since a rule change buried in a content PR ships unreviewed.

AI assistance was used to prepare this change.

Checks

  • I've signed off every commit (git commit -s).
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for the change.
  • Testing strategy
    • The claims about ^^^/+++ splitting, nested_parse, and directive registration were read off sphinx_design==0.7.0's own source (cards.py, grids.py, extension.py), not inferred. The native-grid pattern the note prescribes is the one [docs] Convert the seven card-grid library front doors from RST to MyST #65470 ships and render-diffs.
    • Release tests: not applicable.
    • This PR touches doc/.claude/ only, which no Bazel target or .buildkite rule references, so it pulls no CI suite.

Batch 1 converted the seven card-grid library front doors, and the skill
had no mapping for `grid`, `grid-item-card`, `button-ref`, `button-link`,
or `div`. It also had no entry for RST named hyperlink targets, which
`installation.rst` uses twenty times.

Adds mapping rows for all of the above, plus two construct notes:

- Card grids convert to native MyST colon fences, widest on the outside.
  `^^^` and `+++` need no translation because sphinx-design splits them
  out of the raw content lines before parsing. The trap is `nested_parse`:
  grid, div, and Ray's own callout/annotations directives all parse their
  content as Markdown under MyST, so RST left inside a card renders as
  literal text through a green build. Step 4's dangling reference to "the
  `nested_parse` degradation below" now points at a real note.

- Named hyperlink targets inline as Markdown links, except where an
  `{eval-rst}` table's cells reference them, in which case the definitions
  stay RST inside that same block.

Also records two verified facts: sphinx-design 0.7.0's MyST support, and
that `_replace_numbers()` in `doc/source/_ext/callouts.py` discards its
own result, so annotation text keeps literal `<1>` markers either way.

Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman
dstrodtman requested review from a team as code owners August 13, 2026 21:06

@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 to include detailed guidelines on converting sphinx-design card grids to native MyST, handling nested elements, and managing RST named hyperlink targets. The review feedback correctly identifies multiple syntax issues where backticks inside code spans are not properly escaped or wrapped, which breaks the Markdown formatting of the document.

| `.. dropdown:: T` (`:open:`) | `:::{dropdown} T` with `:open:` on the next line |
| `.. grid:: 1 2 2 2` (+opts) | `::::{grid} 1 2 2 2` (colon fence, **more colons than the cards it holds**) |
| `.. grid-item-card::` / `.. grid-item::` | `:::{grid-item-card}` / `:::{grid-item}` — keep `^^^` and `+++` on their own lines |
| `.. button-ref:: target` / `.. button-link:: url` | ` ```{button-ref} target ` / ` ```{button-link} url `, options as `:key: val`, blank line, then the label |

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

The backticks inside the code span are not correctly wrapped, which breaks the Markdown formatting. In Markdown, to include backticks inside a code span, you should wrap the span in double backticks (e.g., `` ` ```{button-ref} target ` ``).\n\nHere is the corrected line:\n```markdown\n| `.. button-ref:: target` / `.. button-link:: url` | `` ` ```{button-ref} target ` `` / `` ` ```{button-link} url ` ``, options as `:key: val`, blank line, then the label |\n```

- **sphinx-design `tab-set` / `tab-item` / `dropdown`**: use **colon fences**, not backtick fences — `::::{tab-set}` › `:::{tab-item} Label` › ` ```code ``` `. The outer fence needs **more colons** than the one it contains (4 vs 3), and colon fences nest cleanly around backtick code fences, so you avoid backtick-counting entirely. Put directive options (`:open:`, `:sync:`, …) on their own line right after the opener. (Confirmed against Ray's RtD build.)
- **`linkify` is OFF** (not in `myst_enable_extensions`). A bare URL will **not** autolink — wrap it as `<https://…>` to preserve the hyperlink. This includes URLs in parentheses like `Bazel 7.5.0 (https://…)` → `(<https://…>)`.
- **The `::` literal-block marker**: docutils drops `" ::"` when it's preceded by whitespace (`"…sessions. ::"` → `"…sessions."`) and replaces `"x::"` (no space) with `"x:"`. Reproduce the resulting prose, then put the block in a plain ` ``` ` fence.
- **sphinx-design card grids convert to native MyST — and everything nested inside them has to convert too.** A `grid` of `grid-item-card`s becomes colon fences, widest on the outside: `::::{grid} 1 2 2 2` › `:::{grid-item-card}` › a ` ```{button-ref} ` backtick fence. Add a colon level for each extra layer (`ray-libraries.md` runs `:::::{grid}` › `::::{grid-item-card}` › `:::{div}`). The `^^^` header and `+++` footer separators need no translation at all: sphinx-design matches them with `REGEX_HEADER`/`REGEX_FOOTER` and splits them out of the raw content lines *before* anything parses them, so they're format-agnostic.

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

The backticks inside the code span are not correctly wrapped, which breaks the Markdown formatting and can cause the rest of the document to be parsed as code. In Markdown, to include backticks inside a code span, you should wrap the span in double backticks (e.g., `` ` ```{button-ref} ` ``).\n\nHere is the corrected portion of the line:\n```markdown\n... › `:::{grid-item-card}` › a `` ` ```{button-ref} ` `` backtick fence. ...\n```


- **`list-table`**: keep the directive (` ```{list-table} `), move options to `:key: val` lines, and de-indent the `* -` / ` -` body to column 0. Don't convert it into a native Markdown table.

- **RST named hyperlink targets (`` `text`_ `` plus a `.. _`text`: url` definition) have no MyST equivalent.** Inline each one as `[text](url)` at the point of use and delete the definition block. The exception is a target referenced from inside an `{eval-rst}` block — an RST simple or grid table whose cells carry `` `text`_ `` references. Keep those definitions as RST, in the same `{eval-rst}` block as the table that uses them, so they resolve without duplicating a target name elsewhere in the document (`ray-overview/installation.md` does this for the nightly-wheel table).

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

The backticks inside the code span are not correctly wrapped, which breaks the Markdown formatting. In Markdown, to include backticks inside a code span, you should wrap the span in double backticks (e.g., `` `.. `text`: url` ``).\n\nHere is the corrected portion of the line:\n```markdown\n- **RST named hyperlink targets (`` `text` `` plus a ``.. _`text`: url`` definition) have no MyST equivalent.** ...\n```

@ray-gardener ray-gardener Bot added docs An issue or change related to documentation core Issues that should be addressed in Ray Core labels Aug 14, 2026
docutils and MyST slugify an apostrophe differently, so converting a
heading like "What's Ray Core?" moves its anchor from #what-s-ray-core
to #whats-ray-core. Green build, no warning, dead inbound links.

Adds Hard rule 7: if the heading already carries an explicit label, that
label is the anchor and you add nothing; only a bare heading gets a
compat target with the old docutils slug. Never two targets on one
heading.

Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman

Copy link
Copy Markdown
Contributor Author

Folded into #65469, which is now the single skill PR for this campaign — the card-grid mapping, the apostrophe heading-anchor rule, the ray-soft-wrap skill, and the rst-to-myst soft-wrap wiring all land there together. Nothing here is dropped.

@dstrodtman dstrodtman closed this Aug 14, 2026
dstrodtman added a commit that referenced this pull request Aug 14, 2026
…wrap skill (#65469)

## Why are these changes needed?

This is the single skill PR for the RST-to-MyST conversion campaign.
Everything the conversion taught us about the tooling lands here, so the
content batches stay pure content. It started as the render-diff fix and
grew as batches 0 and 1 exercised it; #65471 was folded in rather than
stacked.

## 1. A green build is not evidence of a faithful conversion

The `rst-to-myst` skill treated a green `fail_on_warning` build as
near-sufficient. It isn't. #65467 produced three regressions that built
clean and emitted no warning anywhere: `doc/source/index.rst`'s `..
title::` didn't set the document title from inside `{eval-rst}`, so the
site root rendered as `<no title>`; an `.. image::` with no `:alt:`
became `![](URL)`, changing a bare `<img>` into an `alt=""` wrapped in a
`<p>`; and single-backtick RST under `default_role = "code"` dropped a
`code` class.

**`render_diff.py`** fetches the RtD PR preview and `/en/master` for
each page, extracts `<article>`, normalizes the host, release string,
and search-highlight params, and diffs.

```bash
python3 doc/.claude/skills/rst-to-myst/render_diff.py \
    https://anyscale-ray--65467.com.readthedocs.build/en/65467/ \
    index.html cluster/key-concepts.html ray-overview/use-cases.html
```

It filters the two differences every MyST page shows against an RST
page, both verified inert: `class="tex2jax_ignore mathjax_ignore"`,
which myst-parser stamps on the root `<section>`, and the missing `code`
class above (no rule for it in `pydata-sphinx-theme.css`, `theme.css`,
or `doc/source/_static/css/`). `--keep-benign` shows them. It also
labels `ray-overview/examples.html`, which differs between *any* two
builds because `custom_directives.py` picks its gallery icons with
`random.randint`.

SKILL.md promotes the render diff from a one-line afterthought to a
required step, corrects the `.. image::` row, adds rows for `..
figure::` and `.. title::`, adds Hard rule 5 covering the three
page-identity constructs, and rewrites the `default_role` note.

The guidance is deliberately "read the diffs," not "expect zero."
Byte-identical isn't always the right bar, so the question is whether
every diff is explainable.

**It has since paid for itself twice.** On #65470 it caught three more
silent regressions: all eight Linux nightly-wheel links resolving as
dead internal anchors instead of S3 URLs, `<no tag>` parsing as an HTML
element, and a Vale spelling failure from link text that RST's
`TokenIgnores` had exempted.

## 2. sphinx-design card grids

Batch 1 (#65470) converted seven pages built on `grid` /
`grid-item-card`, which the skill had no mapping for at all — cards are
the dominant construct in the batches still to come.

Adds mapping rows for `grid`, `grid-item-card`, `grid-item`,
`button-ref`, `button-link`, and `div`, plus a construct note covering
the two non-obvious parts:

- `^^^` and `+++` need no translation. sphinx-design matches them with
`REGEX_HEADER`/`REGEX_FOOTER` in `cards.py` and splits them out of the
raw content lines before anything parses them.
- `GridDirective`, `GridItemCardDirective`, `div`, and Ray's
`callout`/`annotations` all call `self.state.nested_parse`, which under
MyST parses content as **Markdown**. RST left inside a native card
doesn't warn — it renders as literal text. Everything nested converts in
the same pass, and the render diff is the only check that catches a
miss.

That also fixes a dangling reference: step 4 already cited "the
`nested_parse` degradation below" and there was no such note.

Two facts recorded from the pinned source rather than assumed:
`sphinx_design==0.7.0` supports MyST first-class (its own docs are MyST,
it ships `snippets/myst/`, and its directives register via
`app.add_directive`); and the `<1>`-to-① substitution in
`doc/source/_ext/callouts.py` works under MyST, in both of the
independent places it happens — `_replace_numbers()` for annotation text
and `CalloutIncludePostTransform` for `literal_block` code.

That second note is written the way it is to head off a
plausible-looking wrong fix. `_replace_numbers()` discards the return
value of its `.replace()` calls, which reads like a classic
immutable-string no-op. It isn't: `self.content` is a docutils
`StringList`, whose `replace()` mutates in place and returns `None`, and
`/en/master/tune/index.html` renders the circled numerals today. The
real defect is only a misleading signature — the `content: str` hint and
the "returns the formatted string" docstring describe behavior the
function doesn't have, so passing it an actual `str` would silently
no-op. Worth fixing, but not here.

## 3. Apostrophe headings move their anchor

docutils slugifies `What's Ray Core?` to `what-s-ray-core`; MyST
produces `whats-ray-core`. Green build, no warning, dead inbound links.
About 17 headings across 15 of the files still to convert.

Hard rule 7: if the heading already carries an explicit label, that
label is the anchor callers should use and nothing is added. Only a bare
heading gets a compat target with the old docutils slug. Never two
targets on one heading.

## 4. A soft-wrap skill

Converted pages come out hard-wrapped because the RST source is, but
Ray's `.md` prose is soft-wrapped. `ray-soft-wrap` is the deterministic
reflow: `softwrap.py` collapses each paragraph and list item to one
line, and `verify.py` gates a pass on three axes — non-whitespace bytes
byte-identical, CommonMark+GFM render identical, transform idempotent.

`rst-to-myst` now says to keep the source line-wrapping in the
conversion commit, so that diff stays line-aligned and a reviewer can
confirm the words didn't change, and to reflow in a separate
whitespace-only commit.

**`softwrap.py` gains a `--selftest`**, following `sphinx-fix`'s
pattern, with regression cases for the boundaries `verify.py`'s oracle
can't see:

```
$ python3 doc/.claude/skills/ray-soft-wrap/scripts/softwrap.py --selftest
ok    plain prose joins
ok    sphinx-design card separators stay on their own line
ok    RST simple table inside eval-rst is untouched
ok    hard break suppresses the join
ok    pipe table rows keep their lines
```

The card-separator case exists because the engine used to fold a card's
title, its `^^^`, and its body into one line — silently dropping the
header — while all three `verify.py` checks reported `ok`, since the
non-whitespace bytes were intact and CommonMark has no concept of a
card. Nothing had exercised it before: Ray had no native
`{grid-item-card}` until this campaign started emitting them.

**Provenance:** this skill was developed in an Anyscale repo while
building out the conversion campaign, and is moved here so it sits
beside the docs it operates on and beside `rst-to-myst`, which now calls
it. In-repo means contributors get it for free and it stays in sync with
the content that exercises it.

## Not a duplicate

`gh pr list --repo ray-project/ray --state open --search "rst-to-myst"`
returns no other open PR touching `doc/.claude/`. #65471 was folded into
this PR and closed.

## Related issue number

Tooling for the RST-to-MyST conversion of `doc/source/`. Content
batches: #65467, #65470, #65472.

AI assistance was used to prepare this change.

## Checks

- [x] I've signed off every commit (`git commit -s`).
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've included any doc changes needed for the change.
- [x] Testing strategy
- `softwrap.py --selftest` passes, and fails as intended when the
card-separator guard is removed.
- `render_diff.py` run against #65467, #65470, and #65472. On #65472 all
four pages render identically; on #65470 four of seven do, with the
three differences explained in [that PR's
comment](#65470 (comment)).
- The sphinx-design claims were read off `sphinx_design==0.7.0`'s source
(`cards.py`, `grids.py`, `extension.py`).
  - Release tests: not applicable.
- This PR touches `doc/.claude/` only, which
`.buildkite/always.rules.txt` and `test.rules.txt` both exclude from the
build and which defines no Bazel targets, so it pulls no CI suite.

---------

Signed-off-by: Douglas Strodtman <[email protected]>
dstrodtman added a commit that referenced this pull request Aug 14, 2026
…65472)

## Why are these changes needed?

Stacked on #65470. Four pages are already Markdown but keep their
sphinx-design card grids as RST inside an `{eval-rst}` block:

| File | Cards |
| --- | --- |
| `cluster/kubernetes/index.md` | 6 |
| `serve/index.md` | 5 |
| `cluster/vms/index.md` | 4 |
| `ray-overview/index.md` | 3 |

That pattern predates native MyST card support and, until #65470, was
the only card-grid precedent in the tree. Now that the seven
highest-traffic front doors use native fences, these four are the
remainder. Converting them leaves one pattern instead of two, so batches
4 through 8 have an unambiguous model to copy.

## What changed

Each `{eval-rst}` grid becomes native colon fences, widest on the
outside:

```markdown
::::{grid} 1 2 2 2
:gutter: 1
:class-container: container pb-3

:::{grid-item-card}
:class-img-top: pt-2 w-75 d-block mx-auto fixed-height-img

**Getting Started**
^^^
Body text.

+++
```{button-ref} some-label
:color: primary
:outline:
:expand:

Button text
```
:::
::::
```

Format-only. Grid and card options, the `^^^` and `+++` separators, and
every `button-ref` target are preserved verbatim.

**The one non-mechanical part:** a native card's content parses as
Markdown, not RST, so the `:doc:` and `:ref:` roles in the card bodies
had to become `{doc}` and `{ref}` in the same pass. Left as RST they
wouldn't warn — they'd render as literal text through a green build.
`ray-overview/index.md` has six `:doc:` roles in one card and
`serve/index.md` has ten `:ref:` roles across five, so this is the bulk
of the non-whitespace diff.

The separate `{eval-rst}` block in `cluster/kubernetes/index.md` holding
an `.. image::` and a source-document comment is left alone. It isn't a
grid, and folding it in would widen this PR past its stated scope.

## Verification

- Fence balance checked at every colon width on all four files; backtick
fences even; no residual `:doc:`/`:ref:`/``` `` ``` RST outside fences.
- Read the Docs preview under `fail_on_warning: true`.
- `render_diff.py` against `/en/master` for all four pages. **Please
hold the merge until I've posted those results in a comment** — the
render diff is the only check that catches a card whose nested content
silently degraded.

## Not a duplicate

`gh pr list --repo ray-project/ray --state open` shows no other PR
touching these four files.

## Related issue number

Follows #65470. The mapping and the `nested_parse` caveat behind this
change are documented in #65471.

AI assistance was used to prepare this change.

## Checks

- [x] I've signed off every commit (`git commit -s`).
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've included any doc changes needed for the change.
- [x] Testing strategy
- [x] Unit tests: not applicable; no CI or `BUILD.bazel` wiring changes.
  - [x] Release tests: not applicable.
- [x] This PR is not tested (please justify below): the decisive checks
for a format conversion are the RtD preview under `fail_on_warning:
true` and the rendered diff against `/en/master`, both listed above.

---------

Signed-off-by: Douglas Strodtman <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…wrap skill (ray-project#65469)

## Why are these changes needed?

This is the single skill PR for the RST-to-MyST conversion campaign.
Everything the conversion taught us about the tooling lands here, so the
content batches stay pure content. It started as the render-diff fix and
grew as batches 0 and 1 exercised it; ray-project#65471 was folded in rather than
stacked.

## 1. A green build is not evidence of a faithful conversion

The `rst-to-myst` skill treated a green `fail_on_warning` build as
near-sufficient. It isn't. ray-project#65467 produced three regressions that built
clean and emitted no warning anywhere: `doc/source/index.rst`'s `..
title::` didn't set the document title from inside `{eval-rst}`, so the
site root rendered as `<no title>`; an `.. image::` with no `:alt:`
became `![](URL)`, changing a bare `<img>` into an `alt=""` wrapped in a
`<p>`; and single-backtick RST under `default_role = "code"` dropped a
`code` class.

**`render_diff.py`** fetches the RtD PR preview and `/en/master` for
each page, extracts `<article>`, normalizes the host, release string,
and search-highlight params, and diffs.

```bash
python3 doc/.claude/skills/rst-to-myst/render_diff.py \
    https://anyscale-ray--65467.com.readthedocs.build/en/65467/ \
    index.html cluster/key-concepts.html ray-overview/use-cases.html
```

It filters the two differences every MyST page shows against an RST
page, both verified inert: `class="tex2jax_ignore mathjax_ignore"`,
which myst-parser stamps on the root `<section>`, and the missing `code`
class above (no rule for it in `pydata-sphinx-theme.css`, `theme.css`,
or `doc/source/_static/css/`). `--keep-benign` shows them. It also
labels `ray-overview/examples.html`, which differs between *any* two
builds because `custom_directives.py` picks its gallery icons with
`random.randint`.

SKILL.md promotes the render diff from a one-line afterthought to a
required step, corrects the `.. image::` row, adds rows for `..
figure::` and `.. title::`, adds Hard rule 5 covering the three
page-identity constructs, and rewrites the `default_role` note.

The guidance is deliberately "read the diffs," not "expect zero."
Byte-identical isn't always the right bar, so the question is whether
every diff is explainable.

**It has since paid for itself twice.** On ray-project#65470 it caught three more
silent regressions: all eight Linux nightly-wheel links resolving as
dead internal anchors instead of S3 URLs, `<no tag>` parsing as an HTML
element, and a Vale spelling failure from link text that RST's
`TokenIgnores` had exempted.

## 2. sphinx-design card grids

Batch 1 (ray-project#65470) converted seven pages built on `grid` /
`grid-item-card`, which the skill had no mapping for at all — cards are
the dominant construct in the batches still to come.

Adds mapping rows for `grid`, `grid-item-card`, `grid-item`,
`button-ref`, `button-link`, and `div`, plus a construct note covering
the two non-obvious parts:

- `^^^` and `+++` need no translation. sphinx-design matches them with
`REGEX_HEADER`/`REGEX_FOOTER` in `cards.py` and splits them out of the
raw content lines before anything parses them.
- `GridDirective`, `GridItemCardDirective`, `div`, and Ray's
`callout`/`annotations` all call `self.state.nested_parse`, which under
MyST parses content as **Markdown**. RST left inside a native card
doesn't warn — it renders as literal text. Everything nested converts in
the same pass, and the render diff is the only check that catches a
miss.

That also fixes a dangling reference: step 4 already cited "the
`nested_parse` degradation below" and there was no such note.

Two facts recorded from the pinned source rather than assumed:
`sphinx_design==0.7.0` supports MyST first-class (its own docs are MyST,
it ships `snippets/myst/`, and its directives register via
`app.add_directive`); and the `<1>`-to-① substitution in
`doc/source/_ext/callouts.py` works under MyST, in both of the
independent places it happens — `_replace_numbers()` for annotation text
and `CalloutIncludePostTransform` for `literal_block` code.

That second note is written the way it is to head off a
plausible-looking wrong fix. `_replace_numbers()` discards the return
value of its `.replace()` calls, which reads like a classic
immutable-string no-op. It isn't: `self.content` is a docutils
`StringList`, whose `replace()` mutates in place and returns `None`, and
`/en/master/tune/index.html` renders the circled numerals today. The
real defect is only a misleading signature — the `content: str` hint and
the "returns the formatted string" docstring describe behavior the
function doesn't have, so passing it an actual `str` would silently
no-op. Worth fixing, but not here.

## 3. Apostrophe headings move their anchor

docutils slugifies `What's Ray Core?` to `what-s-ray-core`; MyST
produces `whats-ray-core`. Green build, no warning, dead inbound links.
About 17 headings across 15 of the files still to convert.

Hard rule 7: if the heading already carries an explicit label, that
label is the anchor callers should use and nothing is added. Only a bare
heading gets a compat target with the old docutils slug. Never two
targets on one heading.

## 4. A soft-wrap skill

Converted pages come out hard-wrapped because the RST source is, but
Ray's `.md` prose is soft-wrapped. `ray-soft-wrap` is the deterministic
reflow: `softwrap.py` collapses each paragraph and list item to one
line, and `verify.py` gates a pass on three axes — non-whitespace bytes
byte-identical, CommonMark+GFM render identical, transform idempotent.

`rst-to-myst` now says to keep the source line-wrapping in the
conversion commit, so that diff stays line-aligned and a reviewer can
confirm the words didn't change, and to reflow in a separate
whitespace-only commit.

**`softwrap.py` gains a `--selftest`**, following `sphinx-fix`'s
pattern, with regression cases for the boundaries `verify.py`'s oracle
can't see:

```
$ python3 doc/.claude/skills/ray-soft-wrap/scripts/softwrap.py --selftest
ok    plain prose joins
ok    sphinx-design card separators stay on their own line
ok    RST simple table inside eval-rst is untouched
ok    hard break suppresses the join
ok    pipe table rows keep their lines
```

The card-separator case exists because the engine used to fold a card's
title, its `^^^`, and its body into one line — silently dropping the
header — while all three `verify.py` checks reported `ok`, since the
non-whitespace bytes were intact and CommonMark has no concept of a
card. Nothing had exercised it before: Ray had no native
`{grid-item-card}` until this campaign started emitting them.

**Provenance:** this skill was developed in an Anyscale repo while
building out the conversion campaign, and is moved here so it sits
beside the docs it operates on and beside `rst-to-myst`, which now calls
it. In-repo means contributors get it for free and it stays in sync with
the content that exercises it.

## Not a duplicate

`gh pr list --repo ray-project/ray --state open --search "rst-to-myst"`
returns no other open PR touching `doc/.claude/`. ray-project#65471 was folded into
this PR and closed.

## Related issue number

Tooling for the RST-to-MyST conversion of `doc/source/`. Content
batches: ray-project#65467, ray-project#65470, ray-project#65472.

AI assistance was used to prepare this change.

## Checks

- [x] I've signed off every commit (`git commit -s`).
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've included any doc changes needed for the change.
- [x] Testing strategy
- `softwrap.py --selftest` passes, and fails as intended when the
card-separator guard is removed.
- `render_diff.py` run against ray-project#65467, ray-project#65470, and ray-project#65472. On ray-project#65472 all
four pages render identically; on ray-project#65470 four of seven do, with the
three differences explained in [that PR's
comment](ray-project#65470 (comment)).
- The sphinx-design claims were read off `sphinx_design==0.7.0`'s source
(`cards.py`, `grids.py`, `extension.py`).
  - Release tests: not applicable.
- This PR touches `doc/.claude/` only, which
`.buildkite/always.rules.txt` and `test.rules.txt` both exclude from the
build and which defines no Bazel targets, so it pulls no CI suite.

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Signed-off-by: 400Ping <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…ay-project#65472)

## Why are these changes needed?

Stacked on ray-project#65470. Four pages are already Markdown but keep their
sphinx-design card grids as RST inside an `{eval-rst}` block:

| File | Cards |
| --- | --- |
| `cluster/kubernetes/index.md` | 6 |
| `serve/index.md` | 5 |
| `cluster/vms/index.md` | 4 |
| `ray-overview/index.md` | 3 |

That pattern predates native MyST card support and, until ray-project#65470, was
the only card-grid precedent in the tree. Now that the seven
highest-traffic front doors use native fences, these four are the
remainder. Converting them leaves one pattern instead of two, so batches
4 through 8 have an unambiguous model to copy.

## What changed

Each `{eval-rst}` grid becomes native colon fences, widest on the
outside:

```markdown
::::{grid} 1 2 2 2
:gutter: 1
:class-container: container pb-3

:::{grid-item-card}
:class-img-top: pt-2 w-75 d-block mx-auto fixed-height-img

**Getting Started**
^^^
Body text.

+++
```{button-ref} some-label
:color: primary
:outline:
:expand:

Button text
```
:::
::::
```

Format-only. Grid and card options, the `^^^` and `+++` separators, and
every `button-ref` target are preserved verbatim.

**The one non-mechanical part:** a native card's content parses as
Markdown, not RST, so the `:doc:` and `:ref:` roles in the card bodies
had to become `{doc}` and `{ref}` in the same pass. Left as RST they
wouldn't warn — they'd render as literal text through a green build.
`ray-overview/index.md` has six `:doc:` roles in one card and
`serve/index.md` has ten `:ref:` roles across five, so this is the bulk
of the non-whitespace diff.

The separate `{eval-rst}` block in `cluster/kubernetes/index.md` holding
an `.. image::` and a source-document comment is left alone. It isn't a
grid, and folding it in would widen this PR past its stated scope.

## Verification

- Fence balance checked at every colon width on all four files; backtick
fences even; no residual `:doc:`/`:ref:`/``` `` ``` RST outside fences.
- Read the Docs preview under `fail_on_warning: true`.
- `render_diff.py` against `/en/master` for all four pages. **Please
hold the merge until I've posted those results in a comment** — the
render diff is the only check that catches a card whose nested content
silently degraded.

## Not a duplicate

`gh pr list --repo ray-project/ray --state open` shows no other PR
touching these four files.

## Related issue number

Follows ray-project#65470. The mapping and the `nested_parse` caveat behind this
change are documented in ray-project#65471.

AI assistance was used to prepare this change.

## Checks

- [x] I've signed off every commit (`git commit -s`).
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've included any doc changes needed for the change.
- [x] Testing strategy
- [x] Unit tests: not applicable; no CI or `BUILD.bazel` wiring changes.
  - [x] Release tests: not applicable.
- [x] This PR is not tested (please justify below): the decisive checks
for a format conversion are the RtD preview under `fail_on_warning:
true` and the rendered diff against `/en/master`, both listed above.

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Signed-off-by: 400Ping <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…wrap skill (ray-project#65469)

## Why are these changes needed?

This is the single skill PR for the RST-to-MyST conversion campaign.
Everything the conversion taught us about the tooling lands here, so the
content batches stay pure content. It started as the render-diff fix and
grew as batches 0 and 1 exercised it; ray-project#65471 was folded in rather than
stacked.

## 1. A green build is not evidence of a faithful conversion

The `rst-to-myst` skill treated a green `fail_on_warning` build as
near-sufficient. It isn't. ray-project#65467 produced three regressions that built
clean and emitted no warning anywhere: `doc/source/index.rst`'s `..
title::` didn't set the document title from inside `{eval-rst}`, so the
site root rendered as `<no title>`; an `.. image::` with no `:alt:`
became `![](URL)`, changing a bare `<img>` into an `alt=""` wrapped in a
`<p>`; and single-backtick RST under `default_role = "code"` dropped a
`code` class.

**`render_diff.py`** fetches the RtD PR preview and `/en/master` for
each page, extracts `<article>`, normalizes the host, release string,
and search-highlight params, and diffs.

```bash
python3 doc/.claude/skills/rst-to-myst/render_diff.py \
    https://anyscale-ray--65467.com.readthedocs.build/en/65467/ \
    index.html cluster/key-concepts.html ray-overview/use-cases.html
```

It filters the two differences every MyST page shows against an RST
page, both verified inert: `class="tex2jax_ignore mathjax_ignore"`,
which myst-parser stamps on the root `<section>`, and the missing `code`
class above (no rule for it in `pydata-sphinx-theme.css`, `theme.css`,
or `doc/source/_static/css/`). `--keep-benign` shows them. It also
labels `ray-overview/examples.html`, which differs between *any* two
builds because `custom_directives.py` picks its gallery icons with
`random.randint`.

SKILL.md promotes the render diff from a one-line afterthought to a
required step, corrects the `.. image::` row, adds rows for `..
figure::` and `.. title::`, adds Hard rule 5 covering the three
page-identity constructs, and rewrites the `default_role` note.

The guidance is deliberately "read the diffs," not "expect zero."
Byte-identical isn't always the right bar, so the question is whether
every diff is explainable.

**It has since paid for itself twice.** On ray-project#65470 it caught three more
silent regressions: all eight Linux nightly-wheel links resolving as
dead internal anchors instead of S3 URLs, `<no tag>` parsing as an HTML
element, and a Vale spelling failure from link text that RST's
`TokenIgnores` had exempted.

## 2. sphinx-design card grids

Batch 1 (ray-project#65470) converted seven pages built on `grid` /
`grid-item-card`, which the skill had no mapping for at all — cards are
the dominant construct in the batches still to come.

Adds mapping rows for `grid`, `grid-item-card`, `grid-item`,
`button-ref`, `button-link`, and `div`, plus a construct note covering
the two non-obvious parts:

- `^^^` and `+++` need no translation. sphinx-design matches them with
`REGEX_HEADER`/`REGEX_FOOTER` in `cards.py` and splits them out of the
raw content lines before anything parses them.
- `GridDirective`, `GridItemCardDirective`, `div`, and Ray's
`callout`/`annotations` all call `self.state.nested_parse`, which under
MyST parses content as **Markdown**. RST left inside a native card
doesn't warn — it renders as literal text. Everything nested converts in
the same pass, and the render diff is the only check that catches a
miss.

That also fixes a dangling reference: step 4 already cited "the
`nested_parse` degradation below" and there was no such note.

Two facts recorded from the pinned source rather than assumed:
`sphinx_design==0.7.0` supports MyST first-class (its own docs are MyST,
it ships `snippets/myst/`, and its directives register via
`app.add_directive`); and the `<1>`-to-① substitution in
`doc/source/_ext/callouts.py` works under MyST, in both of the
independent places it happens — `_replace_numbers()` for annotation text
and `CalloutIncludePostTransform` for `literal_block` code.

That second note is written the way it is to head off a
plausible-looking wrong fix. `_replace_numbers()` discards the return
value of its `.replace()` calls, which reads like a classic
immutable-string no-op. It isn't: `self.content` is a docutils
`StringList`, whose `replace()` mutates in place and returns `None`, and
`/en/master/tune/index.html` renders the circled numerals today. The
real defect is only a misleading signature — the `content: str` hint and
the "returns the formatted string" docstring describe behavior the
function doesn't have, so passing it an actual `str` would silently
no-op. Worth fixing, but not here.

## 3. Apostrophe headings move their anchor

docutils slugifies `What's Ray Core?` to `what-s-ray-core`; MyST
produces `whats-ray-core`. Green build, no warning, dead inbound links.
About 17 headings across 15 of the files still to convert.

Hard rule 7: if the heading already carries an explicit label, that
label is the anchor callers should use and nothing is added. Only a bare
heading gets a compat target with the old docutils slug. Never two
targets on one heading.

## 4. A soft-wrap skill

Converted pages come out hard-wrapped because the RST source is, but
Ray's `.md` prose is soft-wrapped. `ray-soft-wrap` is the deterministic
reflow: `softwrap.py` collapses each paragraph and list item to one
line, and `verify.py` gates a pass on three axes — non-whitespace bytes
byte-identical, CommonMark+GFM render identical, transform idempotent.

`rst-to-myst` now says to keep the source line-wrapping in the
conversion commit, so that diff stays line-aligned and a reviewer can
confirm the words didn't change, and to reflow in a separate
whitespace-only commit.

**`softwrap.py` gains a `--selftest`**, following `sphinx-fix`'s
pattern, with regression cases for the boundaries `verify.py`'s oracle
can't see:

```
$ python3 doc/.claude/skills/ray-soft-wrap/scripts/softwrap.py --selftest
ok    plain prose joins
ok    sphinx-design card separators stay on their own line
ok    RST simple table inside eval-rst is untouched
ok    hard break suppresses the join
ok    pipe table rows keep their lines
```

The card-separator case exists because the engine used to fold a card's
title, its `^^^`, and its body into one line — silently dropping the
header — while all three `verify.py` checks reported `ok`, since the
non-whitespace bytes were intact and CommonMark has no concept of a
card. Nothing had exercised it before: Ray had no native
`{grid-item-card}` until this campaign started emitting them.

**Provenance:** this skill was developed in an Anyscale repo while
building out the conversion campaign, and is moved here so it sits
beside the docs it operates on and beside `rst-to-myst`, which now calls
it. In-repo means contributors get it for free and it stays in sync with
the content that exercises it.

## Not a duplicate

`gh pr list --repo ray-project/ray --state open --search "rst-to-myst"`
returns no other open PR touching `doc/.claude/`. ray-project#65471 was folded into
this PR and closed.

## Related issue number

Tooling for the RST-to-MyST conversion of `doc/source/`. Content
batches: ray-project#65467, ray-project#65470, ray-project#65472.

AI assistance was used to prepare this change.

## Checks

- [x] I've signed off every commit (`git commit -s`).
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've included any doc changes needed for the change.
- [x] Testing strategy
- `softwrap.py --selftest` passes, and fails as intended when the
card-separator guard is removed.
- `render_diff.py` run against ray-project#65467, ray-project#65470, and ray-project#65472. On ray-project#65472 all
four pages render identically; on ray-project#65470 four of seven do, with the
three differences explained in [that PR's
comment](ray-project#65470 (comment)).
- The sphinx-design claims were read off `sphinx_design==0.7.0`'s source
(`cards.py`, `grids.py`, `extension.py`).
  - Release tests: not applicable.
- This PR touches `doc/.claude/` only, which
`.buildkite/always.rules.txt` and `test.rules.txt` both exclude from the
build and which defines no Bazel targets, so it pulls no CI suite.

---------

Signed-off-by: Douglas Strodtman <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…ay-project#65472)

## Why are these changes needed?

Stacked on ray-project#65470. Four pages are already Markdown but keep their
sphinx-design card grids as RST inside an `{eval-rst}` block:

| File | Cards |
| --- | --- |
| `cluster/kubernetes/index.md` | 6 |
| `serve/index.md` | 5 |
| `cluster/vms/index.md` | 4 |
| `ray-overview/index.md` | 3 |

That pattern predates native MyST card support and, until ray-project#65470, was
the only card-grid precedent in the tree. Now that the seven
highest-traffic front doors use native fences, these four are the
remainder. Converting them leaves one pattern instead of two, so batches
4 through 8 have an unambiguous model to copy.

## What changed

Each `{eval-rst}` grid becomes native colon fences, widest on the
outside:

```markdown
::::{grid} 1 2 2 2
:gutter: 1
:class-container: container pb-3

:::{grid-item-card}
:class-img-top: pt-2 w-75 d-block mx-auto fixed-height-img

**Getting Started**
^^^
Body text.

+++
```{button-ref} some-label
:color: primary
:outline:
:expand:

Button text
```
:::
::::
```

Format-only. Grid and card options, the `^^^` and `+++` separators, and
every `button-ref` target are preserved verbatim.

**The one non-mechanical part:** a native card's content parses as
Markdown, not RST, so the `:doc:` and `:ref:` roles in the card bodies
had to become `{doc}` and `{ref}` in the same pass. Left as RST they
wouldn't warn — they'd render as literal text through a green build.
`ray-overview/index.md` has six `:doc:` roles in one card and
`serve/index.md` has ten `:ref:` roles across five, so this is the bulk
of the non-whitespace diff.

The separate `{eval-rst}` block in `cluster/kubernetes/index.md` holding
an `.. image::` and a source-document comment is left alone. It isn't a
grid, and folding it in would widen this PR past its stated scope.

## Verification

- Fence balance checked at every colon width on all four files; backtick
fences even; no residual `:doc:`/`:ref:`/``` `` ``` RST outside fences.
- Read the Docs preview under `fail_on_warning: true`.
- `render_diff.py` against `/en/master` for all four pages. **Please
hold the merge until I've posted those results in a comment** — the
render diff is the only check that catches a card whose nested content
silently degraded.

## Not a duplicate

`gh pr list --repo ray-project/ray --state open` shows no other PR
touching these four files.

## Related issue number

Follows ray-project#65470. The mapping and the `nested_parse` caveat behind this
change are documented in ray-project#65471.

AI assistance was used to prepare this change.

## Checks

- [x] I've signed off every commit (`git commit -s`).
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've included any doc changes needed for the change.
- [x] Testing strategy
- [x] Unit tests: not applicable; no CI or `BUILD.bazel` wiring changes.
  - [x] Release tests: not applicable.
- [x] This PR is not tested (please justify below): the decisive checks
for a format conversion are the RtD preview under `fail_on_warning:
true` and the rendered diff against `/en/master`, both listed above.

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core docs An issue or change related to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant