Skip to content

[ci][doc] Fail when a BUILD exclude, CODEOWNERS entry, or rule names a missing doc path - #66462

Open
dstrodtman wants to merge 5 commits into
masterfrom
djs-260924-doc-literal-path-guard
Open

dstrodtman wants to merge 5 commits into
masterfrom
djs-260924-doc-literal-path-guard

Conversation

@dstrodtman

@dstrodtman dstrodtman commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Why are these changes needed?

Three config surfaces name doc files by literal path. In each of them, a path that no longer exists is silently ignored instead of raising an error:

  • A glob exclude in a BUILD file under doc/. A missing path excludes nothing, so a moved page silently rejoins the doctest or example target it was excluded from.
  • .github/CODEOWNERS. A missing path matches no file, so the owning team stops being requested on the moved page.
  • .buildkite/*.rules.txt. A missing path matches no changed file, so the moved file falls through to a later, usually broader, rule.

A page rename, a directory move, or an .rst-to-.md conversion changes a path without touching any of these. The docs are in the middle of a full RST-to-MyST conversion, with a round of page and directory renames coming next, so this failure mode is about to get much more common. It has already happened six times. #66461 dropped the first four, the dead doc/BUILD.bazel excludes, and the last two are still on master:

Entry What happened
doctest[serve] excludes deploy-many-models/multi-app.md and production-guide/deploy-vm.md Both pages moved, so they're back inside the target's glob. Neither has testcode or a >>> prompt today, so nothing runs from them.
The serve doc_code test excludes doc_code/llm/llm_yaml_config_example.py and doc_code/llm/qwen_example.py Both moved to source/llm/doc_code/serve/qwen/, outside the target's include, so the entries do nothing.
CODEOWNERS names doc/source/data/working-with-llms.rst #66375 converted the page to .md, so @ray-project/ray-llm hasn't been requested on it since.
test.rules.txt routes doc/test_llms_txt.py to doc The test moved to doc/source/_ext/ in #65461. It now matches the _ext/ directory rule and also emits doc_api, which runs both API-consistency checks for a hermetic Sphinx test that imports no Ray code.

How much this matters

The three surfaces don't fail equally badly. In order of severity:

  1. CODEOWNERS loses a review gate. This one has already happened. Since [docs] Convert Ray Data prose pages from RST to MyST #66375, changes to the Ray Data LLM page haven't requested review from @ray-project/ray-llm. Nothing flags this. Nobody notices until someone asks why the owning team never saw a change.
  2. A BUILD exclude stops keeping unrunnable code out of CI. Excludes exist because the file can't run in CI. doc/BUILD.bazel gives the reasons inline: train/doc_code/hvd_trainer.py needs Horovod, which CI doesn't have; train/doc_code/asynchronous_validation.py is pseudocode; and core/doc_code/cgraph_troubleshooting.py purposefully segfaults. If one of them is renamed within its directory, it rejoins the glob and its test fails, either on the rename PR or on whichever PR next triggers that target. None of the four dead excludes so far caused this, because those files either moved out of the glob or have no runnable code. That was luck, not protection.
  3. A rules entry misroutes CI. The file falls through to a later rule. In the one case so far, that ran more checks than the file needed, so the cost was wasted CI time. A fallthrough to a narrower rule could instead skip tests the file needs, but no case has gone that way yet.

This PR fixes the two that remain and adds a check that makes the next one fail CI.

The check

doc/test_literal_paths.py collects every wildcard-free entry under doc/ from those three surfaces and fails on any path that doesn't exist. It currently checks 98 entries. Details:

  • It reads BUILD files with Python's ast, not regexes, so inline comments and nested glob() calls don't confuse it.
  • It checks only exclude lists. A missing path in srcs, main, or files already fails the Bazel build.
  • Glob patterns that match nothing are left alone, because a pattern is often written before the files it covers.
  • Paths written ahead of their files can go in an ALLOWLIST. It's empty today, because the one pre-routed pair in test.rules.txt ([doc] Add in-repo llms.txt generator, replacing sphinx-llms-txt #64458) has since landed.
  • It needs no Bazel or Ray install and checks the tree rather than a diff.

It runs in the always lint matrix, alongside doc_no_new_rst and ray_repo_links. That matrix is where checks a prose-only diff can fail belong, and a rename PR is prose-only, so it triggers no test steps. The script routes to doc in test.rules.txt alongside test_no_new_rst.py.

CI cost

The script runs in about 0.25 seconds. The cost is the extra job: each lint matrix value gets its own fresh runner_queue_small_pr instance. That instance spends about 57 seconds checking out the repo and about 52 seconds pulling the forge image before the command runs. From Buildkite data for 2026-10-29 through 2026-11-04, measured on the sibling doc_no_new_rst job:

Pipeline Runs in the window Runs per day Job run time, p50 / mean
premerge 468 about 77 118 s / 135 s
microcheck 567 about 93 117 s

That works out to roughly 5.5 to 6.5 instance-hours a day, plus about 40 seconds of queue wait per job. It doesn't add wall-clock time to a build. The prose matrix jobs finish in about 2 minutes, and lint: pre_commit in the same build takes about 9.5 minutes. If the per-job overhead is the concern, the check could run inside the doc_no_new_rst job instead of as its own matrix value. That brings its cost close to zero, at the price of sharing a job label and a failure signal.

It's scoped to paths under doc/. Outside doc/, test.rules.txt has 14 entries that name missing CI files (.buildkite/pipeline.*.yml, ci/docker/*.wanda.yaml, examples/, and others), and CODEOWNERS has one for /python/ray/_private/usage/. Those belong to the CI owners, and some may be deliberate, so this PR leaves them alone.

Commits

  1. Point CODEOWNERS at working-with-llms.md. Give doc/source/_ext/test_llms_txt.py its own doc rule ahead of the _ext/ directory entry, the same way api_sidebar.py has one, and move its test.rules.test.txt case to the new path.
  2. Add the check and wire it into the lint matrix.

Related issue number

None. No open PR adds a check like this (gh pr list --search "CODEOWNERS stale path" and "BUILD exclude").

Checks

  • I've signed off every commit (git commit -s).
  • Pre-commit hooks passed on every commit.
  • python doc/test_literal_paths.py passes on this branch. It fails on master with exactly the two entries that remain.
  • I simulated four failures, restored each afterward, and the check exited 1 on all four: renaming a page doctest[serve] excludes, converting a doctest[data-gpu] page from .rst to .md, moving the CODEOWNERS directory doc/source/serve/llm/, and moving the rules-routed doc/rtd_doctor.py.
  • rayci test-rules, built from ray-project/rayci at c890d24, passes. With only the test.rules.test.txt case moved to the new path, it failed with +doc_api (unexpected), which confirms the rule change is what fixes it.
  • ./ci/lint/lint.sh doc_literal_paths passes.

AI assistance (Claude Code) was used to write the check and find the stale entries.

🤖 Generated with Claude Code

dstrodtman added a commit that referenced this pull request Sep 28, 2026
…ervability pages to MyST (#66461)

## Why are these changes needed?

Converts the last non-API-reference RST pages under `ray-core/`,
`data/`, and `rllib/` to MyST Markdown, plus the `train/` and
`ray-observability/` pages that `doc/BUILD.bazel` names by path. The API
reference trees (`*/api/`, `rllib/package_ref/`, and
`ray-core/compiled-graph/compiled-graph-api`) stay RST for now.

Each page gets its own commit, so you can review one file at a time.
Every commit renames the page's literal `.rst` paths in
`doc/BUILD.bazel` to `.md`. These paths are in `exclude` lists and in
the explicit `files` lists of `doctest[data-gpu]` and
`doctest[train-gpu]`, and they don't glob. Without the edit, an excluded
page would silently join its target once it's `.md`, and an included
page would silently drop out of it.

Conversions are format-only: labels, headings, and prose are unchanged.
A final whitespace-only commit soft-wraps the prose. `ray-soft-wrap`'s
`verify.py` confirms non-whitespace bytes, rendered HTML, and
idempotence for all 11 files.

### `rllib/getting-started`: doctest target removed

The first commit deletes `doctest[rllib2]`, the only target over
`rllib/getting-started.rst`, before the page converts. The target is
tagged `manual` with a hang TODO, so no premerge or postmerge step has
run it, and nothing else references it (`git grep rllib2` is empty). Its
15 `testcode` blocks had no `testoutput`, so they asserted nothing. The
12 visible blocks become display-only `python` code blocks. The three
`:hide:` blocks held `.stop()` cleanups that never rendered, so they're
deleted. `doctest[rllib]` still excludes the page. If these examples
should be validated later, a `doc_code/` script is the better route than
reviving the hanging target. cc @elliot-barn, who owns the TODO.

This commit isn't buildable on its own. It turns a `.. testcode::` that
had no blank line before its body into a `.. code-block:: python`, still
with no blank line, and docutils reads the body as extra arguments to
the directive. The later conversion commit fixes it in the `.md`, and a
squash merge never puts the intermediate commit on master.

### Doctest coverage

Docs-only PRs don't run doctests premerge. This PR edits
`doc/BUILD.bazel`, so every library's docs example step runs, but
premerge can't show the conversion kept the same blocks. For that, I
parsed each `.md` and the `.rst` it replaced with Ray's `pytest-sphinx`
fork, the same parser the doctest macro runs, and asserted identical
sections (directive, body, `:options:`, `:skipif:`) and examples.

| Page | BUILD role | Examples before → after |
| --- | --- | --- |
| `ray-core/handling-dependencies` | `doctest[core]` exclude | 17 → 17 |
| `ray-core/tasks/nested-tasks` | `doctest[core]` exclude | 0 → 0
(`literalinclude` of a tested `doc_code/` file) |
| `data/batch-inference` | `doctest_each` exclude, `doctest[data-gpu]`
files | 7 → 7 |
| `data/transforming-data` | `doctest_each` exclude, `doctest[data-gpu]`
files | 24 → 24 |
| `data/contributing/contributing` | `doctest_each` glob | 0 → 0
(toctree only) |
| `rllib/getting-started` | `doctest[rllib]` exclude, `doctest[rllib2]`
removed | 15 → 0, by the removal commit |
| `ray-observability/user-guides/cli-sdk` | top-level exclude | 16 → 16
|
| `ray-observability/user-guides/ray-tracing` | top-level exclude | 3 →
3 |
| `train/horovod` | `doctest[train]` exclude | 2 → 2 |
| `train/user-guides/data-loading-preprocessing` | `doctest[train]`
exclude, `doctest[train-gpu]` files | 6 → 6 |
| `train/user-guides/using-accelerators` | `doctest[train]` exclude,
`doctest[train-gpu]` files | 10 → 10 |

To show the check would catch a broken conversion, I mutated each page
with examples three ways: dropping a `testcode` block, altering a line
in one, and turning one into a four-backtick fence. The last renders
fine but is never collected. The check failed on all 24 mutations.

### Rendering changes

I ran `render_diff.py` on all 11 pages against `/en/master`. Six render
identically: `nested-tasks`, `data/contributing/contributing`,
`cli-sdk`, `ray-tracing`, `horovod`, and `using-accelerators`. Every
difference on the other five is listed here.

- `rllib/getting-started`: on master, one `.. testcode::` line had no
blank line after it. docutils read the block's first six lines, the
`best_result = results.get_best_result(...)` call, as the directive's
argument and dropped them. So master shows code that uses `best_result`
without showing where it comes from. The converted page renders all six
lines. This is the one place the conversion deliberately doesn't
reproduce master.
- `rllib/getting-started`: the "Farama gymnasium" link now has
`https://`. On master it's a relative link to `gymnasium.farama.org`
that 404s.
- `ray-core/handling-dependencies`: MyST drops the apostrophe when it
slugifies the "can't import the packages" heading, so the section id
changes. That heading had no label, so the page adds a target carrying
the old docutils slug, and existing `#...-can-t-import-...` links still
resolve. An auto-numbered span id, which nothing links to, also changes
from `id4` to `id2`.
- `data/batch-inference` and
`train/user-guides/data-loading-preprocessing`: each renders an RST
comment as an HTML comment, which readers never see.
- `data/transforming-data`: the "When using" definition list's `<dl>`
gains the unstyled `myst` class.

The first preview diff also caught three regressions that the green
build didn't. MyST's `replacements` extension turned two `(c)` list
markers into `©` and an `etc..` into `etc…`. The anchor above had
changed too. A follow-up commit fixes all three. A sweep of the 11 pages
found no other text that extension rewrites.

### Dead `doc/BUILD.bazel` excludes

A final commit drops four `exclude` entries that name files that have
moved: two in `doctest[serve]` and two in the serve `doc_code` test. A
glob exclude naming a missing file excludes nothing, so these had
silently stopped applying. This doesn't change what any target runs.
#66462 carries the same commit, along with a lint check that fails on
this class of stale path, so the two PRs merge cleanly in either order.

### Open PRs that edit these files

Each of these open PRs edits one of the converted `.rst` files, so each
will need to move its change to the `.md`: #66279, #66191, #65956,
#65933, and #65830 (`handling-dependencies`), #65693 (`cli-sdk`), and
#66419, #66420, #66422, and #66423 (`data/batch-inference`,
`train/user-guides/data-loading-preprocessing`). #66096, #64053, and
#63881 also edit `doc/BUILD.bazel`, and only #66096 edits nearby lines.

## Related issue number

None. No open PR converts these pages. I checked `gh pr list` for open
PRs touching each file.

## Checks

- [x] I've signed off every commit (`git commit -s`).
- [x] Pre-commit hooks passed on every commit.
- Doctest parity: `python3 doctest_parity.py <the 11 .md files>` with
`pytest==7.4.4` and `pytest-sphinx @
git+https://github.com/ray-project/pytest-sphinx`. All OK, run again
after the soft-wrap commit.
- Static checks on every `.md`: fences balance, no leftover RST roles or
directives, every label from the `.rst` is present, and directive counts
match.
- Read the Docs preview builds green under `fail_on_warning`, and the
render diff against `/en/master` is in Rendering changes. The first
build hit the known autosummary-import segfault and passed on rebuild.
- Local doctest run: not done. The GPU targets need hardware, and the
CPU targets run in this PR's premerge because of the `BUILD.bazel`
change.

AI assistance (Claude Code) was used for the conversion and the
verification scripts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…ervability pages to MyST (ray-project#66461)

## Why are these changes needed?

Converts the last non-API-reference RST pages under `ray-core/`,
`data/`, and `rllib/` to MyST Markdown, plus the `train/` and
`ray-observability/` pages that `doc/BUILD.bazel` names by path. The API
reference trees (`*/api/`, `rllib/package_ref/`, and
`ray-core/compiled-graph/compiled-graph-api`) stay RST for now.

Each page gets its own commit, so you can review one file at a time.
Every commit renames the page's literal `.rst` paths in
`doc/BUILD.bazel` to `.md`. These paths are in `exclude` lists and in
the explicit `files` lists of `doctest[data-gpu]` and
`doctest[train-gpu]`, and they don't glob. Without the edit, an excluded
page would silently join its target once it's `.md`, and an included
page would silently drop out of it.

Conversions are format-only: labels, headings, and prose are unchanged.
A final whitespace-only commit soft-wraps the prose. `ray-soft-wrap`'s
`verify.py` confirms non-whitespace bytes, rendered HTML, and
idempotence for all 11 files.

### `rllib/getting-started`: doctest target removed

The first commit deletes `doctest[rllib2]`, the only target over
`rllib/getting-started.rst`, before the page converts. The target is
tagged `manual` with a hang TODO, so no premerge or postmerge step has
run it, and nothing else references it (`git grep rllib2` is empty). Its
15 `testcode` blocks had no `testoutput`, so they asserted nothing. The
12 visible blocks become display-only `python` code blocks. The three
`:hide:` blocks held `.stop()` cleanups that never rendered, so they're
deleted. `doctest[rllib]` still excludes the page. If these examples
should be validated later, a `doc_code/` script is the better route than
reviving the hanging target. cc @elliot-barn, who owns the TODO.

This commit isn't buildable on its own. It turns a `.. testcode::` that
had no blank line before its body into a `.. code-block:: python`, still
with no blank line, and docutils reads the body as extra arguments to
the directive. The later conversion commit fixes it in the `.md`, and a
squash merge never puts the intermediate commit on master.

### Doctest coverage

Docs-only PRs don't run doctests premerge. This PR edits
`doc/BUILD.bazel`, so every library's docs example step runs, but
premerge can't show the conversion kept the same blocks. For that, I
parsed each `.md` and the `.rst` it replaced with Ray's `pytest-sphinx`
fork, the same parser the doctest macro runs, and asserted identical
sections (directive, body, `:options:`, `:skipif:`) and examples.

| Page | BUILD role | Examples before → after |
| --- | --- | --- |
| `ray-core/handling-dependencies` | `doctest[core]` exclude | 17 → 17 |
| `ray-core/tasks/nested-tasks` | `doctest[core]` exclude | 0 → 0
(`literalinclude` of a tested `doc_code/` file) |
| `data/batch-inference` | `doctest_each` exclude, `doctest[data-gpu]`
files | 7 → 7 |
| `data/transforming-data` | `doctest_each` exclude, `doctest[data-gpu]`
files | 24 → 24 |
| `data/contributing/contributing` | `doctest_each` glob | 0 → 0
(toctree only) |
| `rllib/getting-started` | `doctest[rllib]` exclude, `doctest[rllib2]`
removed | 15 → 0, by the removal commit |
| `ray-observability/user-guides/cli-sdk` | top-level exclude | 16 → 16
|
| `ray-observability/user-guides/ray-tracing` | top-level exclude | 3 →
3 |
| `train/horovod` | `doctest[train]` exclude | 2 → 2 |
| `train/user-guides/data-loading-preprocessing` | `doctest[train]`
exclude, `doctest[train-gpu]` files | 6 → 6 |
| `train/user-guides/using-accelerators` | `doctest[train]` exclude,
`doctest[train-gpu]` files | 10 → 10 |

To show the check would catch a broken conversion, I mutated each page
with examples three ways: dropping a `testcode` block, altering a line
in one, and turning one into a four-backtick fence. The last renders
fine but is never collected. The check failed on all 24 mutations.

### Rendering changes

I ran `render_diff.py` on all 11 pages against `/en/master`. Six render
identically: `nested-tasks`, `data/contributing/contributing`,
`cli-sdk`, `ray-tracing`, `horovod`, and `using-accelerators`. Every
difference on the other five is listed here.

- `rllib/getting-started`: on master, one `.. testcode::` line had no
blank line after it. docutils read the block's first six lines, the
`best_result = results.get_best_result(...)` call, as the directive's
argument and dropped them. So master shows code that uses `best_result`
without showing where it comes from. The converted page renders all six
lines. This is the one place the conversion deliberately doesn't
reproduce master.
- `rllib/getting-started`: the "Farama gymnasium" link now has
`https://`. On master it's a relative link to `gymnasium.farama.org`
that 404s.
- `ray-core/handling-dependencies`: MyST drops the apostrophe when it
slugifies the "can't import the packages" heading, so the section id
changes. That heading had no label, so the page adds a target carrying
the old docutils slug, and existing `#...-can-t-import-...` links still
resolve. An auto-numbered span id, which nothing links to, also changes
from `id4` to `id2`.
- `data/batch-inference` and
`train/user-guides/data-loading-preprocessing`: each renders an RST
comment as an HTML comment, which readers never see.
- `data/transforming-data`: the "When using" definition list's `<dl>`
gains the unstyled `myst` class.

The first preview diff also caught three regressions that the green
build didn't. MyST's `replacements` extension turned two `(c)` list
markers into `©` and an `etc..` into `etc…`. The anchor above had
changed too. A follow-up commit fixes all three. A sweep of the 11 pages
found no other text that extension rewrites.

### Dead `doc/BUILD.bazel` excludes

A final commit drops four `exclude` entries that name files that have
moved: two in `doctest[serve]` and two in the serve `doc_code` test. A
glob exclude naming a missing file excludes nothing, so these had
silently stopped applying. This doesn't change what any target runs.
ray-project#66462 carries the same commit, along with a lint check that fails on
this class of stale path, so the two PRs merge cleanly in either order.

### Open PRs that edit these files

Each of these open PRs edits one of the converted `.rst` files, so each
will need to move its change to the `.md`: ray-project#66279, ray-project#66191, ray-project#65956,
ray-project#65933, and ray-project#65830 (`handling-dependencies`), ray-project#65693 (`cli-sdk`), and
ray-project#66419, ray-project#66420, ray-project#66422, and ray-project#66423 (`data/batch-inference`,
`train/user-guides/data-loading-preprocessing`). ray-project#66096, ray-project#64053, and
ray-project#63881 also edit `doc/BUILD.bazel`, and only ray-project#66096 edits nearby lines.

## Related issue number

None. No open PR converts these pages. I checked `gh pr list` for open
PRs touching each file.

## Checks

- [x] I've signed off every commit (`git commit -s`).
- [x] Pre-commit hooks passed on every commit.
- Doctest parity: `python3 doctest_parity.py <the 11 .md files>` with
`pytest==7.4.4` and `pytest-sphinx @
git+https://github.com/ray-project/pytest-sphinx`. All OK, run again
after the soft-wrap commit.
- Static checks on every `.md`: fences balance, no leftover RST roles or
directives, every label from the `.rst` is present, and directive counts
match.
- Read the Docs preview builds green under `fail_on_warning`, and the
render diff against `/en/master` is in Rendering changes. The first
build hit the known autosummary-import segfault and passed on rebuild.
- Local doctest run: not done. The GPU targets need hardware, and the
CPU targets run in this PR's premerge because of the `BUILD.bazel`
change.

AI assistance (Claude Code) was used for the conversion and the
verification scripts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Oct 9, 2026
@dstrodtman
dstrodtman force-pushed the djs-260924-doc-literal-path-guard branch from 30b4d94 to 35a4db4 Compare October 20, 2026 14:02
@github-actions github-actions Bot added unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels Oct 21, 2026
dstrodtman and others added 2 commits October 21, 2026 16:01
…heir files

Both entries name files that have moved, so each has silently stopped
applying:

- CODEOWNERS names doc/source/data/working-with-llms.rst, which #66375
  converted to working-with-llms.md. ray-project/ray-llm hasn't been
  requested on the page since.
- test.rules.txt routes doc/test_llms_txt.py to `doc` alone, but the test
  moved to doc/source/_ext/ in #65461. There it matches the _ext/ directory
  rule and also emits doc_api, which runs both API-consistency checks for a
  hermetic Sphinx test that imports no Ray code. It now gets its own rule
  ahead of the directory entry, the same way api_sidebar.py does, and the
  test.rules.test.txt case follows it to the new path.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
…a missing doc path

Three config surfaces name doc files by literal path and ignore a path that
no longer exists instead of erroring: glob `exclude` lists in the BUILD
files under doc/, .github/CODEOWNERS, and the .buildkite rules files. A page
rename, move, or .rst-to-.md conversion changes the path without touching
them, so the exclusion, ownership, or routing quietly stops applying. Four
dead doc/BUILD.bazel excludes and the two entries fixed in the previous
commit accumulated that way.

doc/test_literal_paths.py checks every wildcard-free entry under doc/ in
those three surfaces and fails on any that doesn't exist, with an ALLOWLIST
for paths written ahead of their files. It reads BUILD files with ast, needs
no Bazel or Ray install, and checks the tree rather than a diff. It runs in
the `always` lint matrix next to doc_no_new_rst, because a prose-only rename
can fail it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman
dstrodtman force-pushed the djs-260924-doc-literal-path-guard branch from 35a4db4 to f793af9 Compare October 21, 2026 20:03
dstrodtman added a commit that referenced this pull request Oct 30, 2026
## Description

This PR retires the notebook authoring templates and the contributor
guidance that points new examples at notebooks.

`doc/source/_templates/template.ipynb` is a Jupyter starter for new doc
examples. It isn't a page, because `templates_path` keeps `_templates/`
out of the source files Sphinx reads. Nothing includes it, and no bazel
target runs it. Its MyST sibling, `template.md`, is out of date. It
imports `ray.rllib.agents.ppo`, demos `{eval-rst}` and `{margin}`, and
teaches `{code-cell}` notebooks that no build or test target executes.
The "Creating a notebook example" section of the contributor guide links
both templates, tells contributors to download the page as an `.ipynb`,
and recommends converting their draft to `.ipynb` when they finish.

This PR deletes the Jupyter template and turns `template.md` into a
template for an end-to-end guide written as an ordinary MyST page. The
contributor guidance now says that a guide like this is a Markdown page
its author ran, not a tested asset, and sends examples that need testing
to the template-collections flow. The template and guidance changes come
from #67428, which merged into this branch.

### What this PR changes

- Deletes `doc/source/_templates/template.ipynb`.
- `doc/source/_templates/template.md`: rewrites it as an end-to-end
guide skeleton. It uses only MyST, sphinx-design (`tab-set`,
`dropdown`), colon-fence admonitions, and `{ref}` and `{py:func}` roles,
with no myst-nb notebook syntax. A maintainer-only HTML comment under
the title records that Ray CI doesn't test the guide and which Ray
version its author last ran it with. The example code is a minimal Ray
Core task. Sphinx still excludes the file through `_templates/`.
- `doc/source/ray-contribute/docs.md`:
- Replaces "Creating a notebook example" (label
`creating-notebook-example`) with "Writing an end-to-end guide"
(`writing-e2e-guide`). The new section points to the template and says
Ray CI doesn't run the guide's code, so the author runs every step and
records the Ray version. It sends tested examples to the
template-collections flow and says not to add notebooks or notebook
front matter. To convert an existing notebook, it gives `jupyter
nbconvert --to markdown`.
- Removes what the old section taught: the Jupyter template link,
downloading the page as an `.ipynb`, the Tune Hyperopt notebook as a
model, the kernel specification front matter, `code-cell` examples, cell
tags, reference labels, removed-cell testing, and the `jupytext`
conversions. It also drops the claim that CI tests every notebook placed
in the Tune `examples` folder.
- Updates the format overview and the "two types of documents" list so
they no longer present notebooks as the format for new examples.
- "Adding code to an `.rST` or `.md` file": drops the claim that every
snippet is tested and the `.. code-cell:: python` recommendation. Tested
code uses `testcode` or a `literalinclude` script, and code that CI
can't run goes in a plain fenced block.
  - Links "How to write code snippets" by its `.md` file name.
- "Writing an end-to-end guide": offers an `examples.yml` gallery only
for Ray Data, Ray Serve, and Ray Train, the only libraries that have
one. `conf.py` marks gallery-linked pages as orphans, so the page needs
no `orphan` front matter. It also says what `nbconvert` does with
outputs and images.
- Replaces "Every Python file in the `doc_code` directory is
automatically tested." Some files and directories have no target in
`doc/BUILD.bazel`, so it now tells contributors to check that a target
covers their script.
- `doc/source/ray-contribute/writing-style.md`, "Code blocks": replaces
"Every runnable snippet in the docs is tested." It now names the two
tested forms, a `testcode` block on a page with a doctest target in
`doc/BUILD.bazel` and a `doc_code/` script included with
`literalinclude`. It limits both to code that runs as written and that
CI should test, and says CI doesn't run a plain fenced block. Since
#67432, no documentation page runs a `>>>` example, and #67429 updates
`writing-code-snippets.md` to match.
- `doc/source/ray-contribute/publishing-examples-legacy.md`: takes over
the cell-tag guidance (`hide-*`, `remove-*`, and overriding realistic
values in a removed cell), rewritten for `.ipynb` cell metadata. It
applies only to the remaining in-tree notebooks.
- `doc/source/ray-contribute/publishing-examples.md`: repoints its
cross-reference to `writing-e2e-guide`. No reference to the old label
remains.
- `.buildkite/test.rules.txt`: deletes the `doc/source/_templates/` skip
rule. It existed to keep `template.ipynb` off the `doc/*.ipynb`
catch-all. Every remaining file under `_templates/` (`.html`, `.rst`,
`.md`, `.gitkeep`) gets the same tags without it: `.md` and `.rst` files
hit the leading prose skip first, and the rest fall through to the broad
`doc/` skip.
- `.buildkite/test.rules.test.txt`: replaces the `template.ipynb` case
with `doc/source/_templates/layout.html:`.

### Merge-order note for #67012

#67012 adds `doc/asset_allowlists/notebooks.txt`, which lists
`doc/source/_templates/template.ipynb`, and its check fails on an entry
whose file is gone. Neither PR depends on the other, and they merge
without textual conflicts. Whichever merges second deletes that line. If
this PR merges first, `python doc/test_doc_assets.py --update` on #67012
removes it. With this branch, current master, and #67012 merged
together, the check fails only on that line and passes once it's
deleted.

## Related issues

Includes #67428, which merged into this branch. #67429 is stacked on
this branch, and #67639 is stacked on #67429. #67639 limits the legacy
notebook page to maintaining the two remaining notebook examples.
Follows #67008, which rewrote the same comment blocks in
`test.rules.txt` and `test.rules.test.txt`, and #66974, which moved
never-run `testcode` blocks to plain code blocks.

## Additional information

### Duplicate check

I searched open PRs for `template.ipynb`, `template.md`, `_templates`,
`notebook template`, `end-to-end guide`, `creating-notebook-example`,
`ray-contribute/docs.md`, `writing-style.md`, and `publishing-examples`,
then compared the files each docs PR in the results changes with this
PR's. No open PR removes either template or rewrites these sections. The
open PRs that touch the same files edit other hunks:

- #66462 and #67012 edit `test.rules.txt` and `test.rules.test.txt`.
Each merges with this branch without conflicts. #67204, which edited
`docs.md` and `writing-style.md`, has merged, and this branch is rebased
on it.
- #67018 edits a section of `writing-style.md` about 170 lines below
this PR's hunk.
- #67429 and #67639 are stacked on this branch.

### Testing

On this branch's head, rebased on master on 2026-10-30:

- `rayci test-rules`, using v0.51.0, the version `.rayciversion` pins,
built from `ray-project/rayci`: 197/197 cases pass, and the check also
passes with the branch merged with current master. Changing the new
`layout.html` case to expect `doc` makes it fail, so the case is live.
- Routing equivalence: I added every file under `doc/source/_templates/`
as a case that expects no tags. `rayci test-rules` passes both with and
without the deleted rule. The only file whose routing the rule changes
is `template.ipynb`, which routes to `doc_example` without it.
- `pre-commit run --files` on the changed files passes, including the
check that links to files on master resolve.
- `vale` on the changed pages: `docs.md` goes from 98 alerts to 71, and
the other pages stay level or drop. The only new alerts are spelling
flags on "toctree" and "doctest", terms these guides already use, and a
passive-voice flag on an unchanged sentence in `docs.md`.
- `jupyter nbconvert your-example.ipynb --to markdown`, with nbconvert
7.17.2 on a copy of a Tune notebook, writes a Markdown file with
`python` code fences and no Jupyter front matter.
- The Read the Docs preview renders "Writing an end-to-end guide", the
`writing-e2e-guide` references in `docs.md` and `publishing-examples.md`
resolve to it, and the legacy page renders "Hide and remove cells".

From #67428:

- The template's example code, run with `ray[default]` 2.59.0 on Python
3.11, prints `[0, 1, 4, 9]`.
- A copy of the template with its placeholders filled in builds without
warnings using Sphinx 8.2.3, myst-parser 5.1.0, sphinx-design, and the
`myst_enable_extensions` from `conf.py`. The tab set, dropdown, and tip
render.

This PR was prepared with AI assistance (Claude Code), including the
commits from #67428. Each author reviewed every line they changed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Ronny Roland <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Douglas Strodtman <[email protected]>
…teral-path-guard

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

# Conflicts:
#	.buildkite/test.rules.test.txt
#	.buildkite/test.rules.txt
@dstrodtman
dstrodtman marked this pull request as ready for review November 4, 2026 21:12
@dstrodtman
dstrodtman requested review from a team as code owners November 4, 2026 21:13

@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 introduces a new lint check, doc_literal_paths, which ensures that literal documentation paths referenced in configuration files (such as Bazel BUILD excludes, GitHub CODEOWNERS, and Buildkite rules) actually exist. This prevents silent failures when documentation files are renamed, moved, or converted. Feedback on the new doc/test_literal_paths.py script suggests specifying encoding="utf-8" when opening files to prevent platform-specific decoding errors, and normalizing file paths to use forward slashes to ensure compatibility on Windows systems.

Comment thread doc/test_literal_paths.py Outdated
text=True,
)
for build in out.split():
with open(os.path.join(root, build)) as f:

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

Specify encoding="utf-8" when opening the file to ensure cross-platform compatibility and prevent UnicodeDecodeError on systems where the default encoding is not UTF-8 (e.g., Windows), especially since BUILD files can contain non-ASCII characters in comments.

Suggested change
with open(os.path.join(root, build)) as f:
with open(os.path.join(root, build), encoding="utf-8") as f:

Comment thread doc/test_literal_paths.py
for elt in kw.value.elts:
if isinstance(elt, ast.Constant) and isinstance(elt.value, str):
if _is_literal(elt.value):
yield build, elt.lineno, os.path.join(base, elt.value)

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

On Windows, os.path.join uses backslashes (\\) as the path separator. Since ALLOWLIST and other path comparisons expect forward slashes (/), this can cause matching to fail on Windows. Normalize the path to always use forward slashes.

Suggested change
yield build, elt.lineno, os.path.join(base, elt.value)
yield build, elt.lineno, os.path.join(base, elt.value).replace(os.sep, "/")

Comment thread doc/test_literal_paths.py Outdated

def _codeowners(root: str) -> Iterator[Tuple[str, int, str]]:
name = ".github/CODEOWNERS"
with open(os.path.join(root, name)) as f:

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

Specify encoding="utf-8" when opening the CODEOWNERS file to prevent potential UnicodeDecodeError on platforms with different default encodings, as developer names or comments in CODEOWNERS may contain non-ASCII characters.

Suggested change
with open(os.path.join(root, name)) as f:
with open(os.path.join(root, name), encoding="utf-8") as f:

Comment thread doc/test_literal_paths.py Outdated
if not fnmatch.fnmatch(fname, "*.rules.txt"):
continue
name = f".buildkite/{fname}"
with open(os.path.join(rules_dir, fname)) as f:

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

Specify encoding="utf-8" when opening the rules files to ensure consistent reading across different platforms and avoid encoding issues.

Suggested change
with open(os.path.join(rules_dir, fname)) as f:
with open(os.path.join(rules_dir, fname), encoding="utf-8") as f:

Pass encoding="utf-8" to each open() so the check reads the same
bytes regardless of the platform default encoding.

Signed-off-by: Douglas Strodtman <[email protected]>
@ray-gardener ray-gardener Bot added docs An issue or change related to documentation core Issues that should be addressed in Ray Core devprod labels Nov 5, 2026

This branch has not been deployed

No deployments
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 devprod docs An issue or change related to documentation unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant