Skip to content

[doc] Replace the notebook template with an end-to-end guide template - #67428

Merged
ronny-anyscale merged 3 commits into
doc-1833-retire-notebook-templatefrom
djs-261026-e2e-guide-template
Oct 26, 2026
Merged

ronny-anyscale merged 3 commits into
doc-1833-retire-notebook-templatefrom
djs-261026-e2e-guide-template

Conversation

@dstrodtman

Copy link
Copy Markdown
Contributor

Description

Stacked on #67426, which retires template.ipynb. That leaves doc/source/_templates/template.md as the only "start from" link in the contributor guide, but the MyST notebook template itself 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. Only the template and docs.md use {code-cell} anywhere under doc/source/.

This PR turns the template into an end-to-end guide written as an ordinary MyST page, and moves the contributor guidance off notebooks to match. Community contributors can't add Anyscale templates, and in-tree notebooks aren't tested or maintained either. So the guidance is honest that a community guide is a Markdown page that its author verified, not a tested asset.

@ronny-anyscale: the intent is for you to merge this into #67426 and rewrite that PR's description to cover both.

What this PR changes

  • doc/source/_templates/template.md: rewritten 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.
  • doc/source/ray-contribute/docs.md:
    • Replaces "Creating a notebook example" (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 it and records the version. It sends tested examples to the template-collections flow, says not to add notebooks or notebook front matter, and gives jupyter nbconvert --to markdown for converting an existing notebook.
    • 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. Code CI can't run goes in a plain fenced block.
  • 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 a plain fenced block isn't run. This matches writing-code-snippets.md after [doc] Show never-run testcode blocks as plain code blocks #66974.
  • 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 only applies to the remaining in-tree notebooks, and this page's link to it would otherwise point at a removed section.
  • doc/source/ray-contribute/publishing-examples.md: repoints its cross-reference to writing-e2e-guide.

Related issues

Stacked on #67426. Follows #66974, which moved never-run testcode blocks to plain code blocks.

Additional information

Duplicate check

I searched open PRs for _templates/template.md, end-to-end guide template, writing-style.md code blocks, and publishing-examples-legacy. Only #67426 touches the template. #67204 edits other hunks of docs.md, writing-style.md, and writing-code-snippets.md. git merge-tree against it reports no conflicts.

Testing

  • The template's example code, run with ray[default] 2.59.0 on Python 3.11, prints [0, 1, 4, 9].
  • I built a copy of the template, with placeholders filled in, using Sphinx 8.2.3, myst-parser 5.1.0, sphinx-design, and the myst_enable_extensions from conf.py. It built without warnings, and the tab set, dropdown, and tip rendered. The template itself stays excluded from the build through _templates/.
  • pre-commit run --files on the changed files passes, including the check that links to files on master resolve.
  • vale on the changed lines: no new alerts except a spelling flag on "doctest", a term the contributor guides already use.
  • Not run: a full Sphinx build of the contributor pages. The Read the Docs preview covers the new label and cross-references.

This PR was prepared with AI assistance (Claude Code). I reviewed every changed line.

🤖 Generated with Claude Code

dstrodtman and others added 2 commits October 26, 2026 12:14
Rewrite doc/source/_templates/template.md as a plain MyST end-to-end
guide that states Ray CI doesn't test it and records the Ray version the
author ran it with. It uses only MyST, sphinx-design, and Sphinx roles,
with no myst-nb notebook syntax.

Move the contributor guidance off notebooks to match:

- docs.md: replace "Creating a notebook example" with "Writing an
  end-to-end guide", and stop describing notebooks as the format for
  new examples.
- writing-style.md: drop the claim that every snippet is tested. Tested
  code goes through literalinclude of a doc_code script; plain fenced
  blocks are untested.
- publishing-examples-legacy.md: take over the cell-tag guidance, which
  only applies to the remaining in-tree notebooks.
- publishing-examples.md: repoint the cross-reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
…ntainer-only

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 26, 2026 16:20

@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 Ray documentation guidelines to deprecate in-tree Jupyter notebooks in favor of MyST Markdown end-to-end guides. It updates the end-to-end guide template, clarifies how code snippets are tested by CI, and documents how to control cell rendering using metadata tags in legacy notebooks. The review feedback suggests correcting mismatched colon-fence blocks in the template's tab-set, replacing hardcoded URLs with Sphinx {doc} cross-references, and using the {doc} role instead of standard Markdown links to reference other documentation pages.

Comment on lines +46 to +66
::::{tab-set}

:::{tab-item} Local machine
```python
import ray

```{code-cell} python3
# Start a local Ray instance.
ray.init()
```
:::

:::{tab-item} Existing cluster
```python
import ray
import ray.rllib.agents.ppo as ppo
from ray import serve

def train_ppo_model():
trainer = ppo.PPOTrainer(
config={"framework": "torch", "num_workers": 0},
env="CartPole-v0",
)
# Train for one iteration
trainer.train()
trainer.save("/tmp/rllib_checkpoint")
return "/tmp/rllib_checkpoint/checkpoint_000001/checkpoint-1"
# Connect to the cluster that `ray start` started on this machine.
ray.init(address="auto")
```
:::

::::

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 nesting of the colon-fence blocks for the tab set is currently mismatched and prone to parsing errors.\n\nIn MyST, nested directives must use a different number of colons for the outer and inner blocks. Since the inner tab-item blocks use 4 colons (::::), the outer tab-set block should use 5 colons (:::::) to ensure clean nesting and avoid rendering issues.\n\nHere is the corrected structure:\n\nmarkdown\n:::::{tab-set}\n\n::::{tab-item} Local machine\npython\nimport ray\n\n# Start a local Ray instance.\nray.init()\n\n::::\n\n::::{tab-item} Existing cluster\npython\nimport ray\n\n# Connect to the cluster that ray start started on this machine.\nray.init(address="auto")\n\n::::\n\n:::::\n

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changing this. The nesting is already correct: the outer tab-set uses four colons and each inner tab-item uses three, so the outer fence is the longer one. It's the same structure as existing pages such as cluster/configure-manage-dashboard.md, and a render of the template with Sphinx 8.2.3, myst-parser 5.1.0, and sphinx-design built without warnings.


- Markup documents, written in MyST or rST. If you don't have a lot of (executable) code to contribute or use more complex features such as {ref}`tabbed content blocks <start-ray>`, this is the right choice. Most of the documents in Ray Tune are written in this way, for instance the [key concepts](https://github.com/ray-project/ray/blob/master/doc/source/tune/key-concepts.md) or [API documentation](https://github.com/ray-project/ray/blob/master/doc/source/tune/api/api.rst).
- Notebooks, written in `.ipynb` format. All Tune examples are written as notebooks. These notebooks render in the browser like `.md` or `.rst` files, but have the added benefit that users can run the code themselves.
- Markup documents, written in MyST or rST. Every new page uses this format, including examples. Most of the documents in Ray Tune are written in this way, for instance the [key concepts](https://github.com/ray-project/ray/blob/master/doc/source/tune/key-concepts.md) or [API documentation](https://github.com/ray-project/ray/blob/master/doc/source/tune/api/api.rst).

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

According to the Ray documentation style guide, you should prefer Sphinx cross-references over hardcoded URLs to other documentation pages in the same repository.\n\nPlease replace the hardcoded GitHub URLs with {doc} cross-references:\n\nmarkdown\n- Markup documents, written in MyST or rST. Every new page uses this format, including examples. Most of the documents in Ray Tune are written in this way, for instance the {doc}`key concepts <../tune/key-concepts>` or {doc}`API documentation <../tune/api/api>`.\n

References
  1. Ray docs use Sphinx cross-references, which resolve at build time and survive page moves. Prefer them over hardcoded URLs to other docs pages. (link)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changing this. These links predate this PR, which only rewords the sentence around them. They point at the source files on purpose, because the sentence is about the format the pages are written in. A {doc} reference would link to the rendered page instead.

Comment thread doc/source/ray-contribute/docs.md Outdated
## Adding code to an `.rST` or `.md` file

Modifying text in an existing documentation file is easy, but you need to be careful when it comes to adding code. The reason is that we want to ensure every code snippet in our documentation is tested. This requires us to have a process for including and testing code snippets in documents. To learn how to write testable code snippets, read [How to write code snippets](writing-code-snippets).
Modifying text in an existing documentation file is easy, but adding code takes more care. To show code that Ray CI tests, use a `testcode` block or include a script that CI runs. Use these only for code that runs as written. To learn how to write tested code snippets, read [How to write code snippets](writing-code-snippets).

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 link to the writing-code-snippets page is currently a standard Markdown link but is missing the .md extension, which can break rendering or parsing.\n\nTo adhere to the style guide, please use the {doc} role for linking to a whole page:\n\nmarkdown\nTo learn how to write tested code snippets, read {doc}`writing-code-snippets`.\n

References
  1. Link to a whole page with the {doc} role: {doc}writing-code-snippets. (link)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 4a0ac03. The style guide links between .md pages with a standard Markdown link that includes the extension, so this is now [How to write code snippets](writing-code-snippets.md). I made the same fix to the identical link earlier on the page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman
dstrodtman added this pull request to stack #67431 October 26, 2026 16:32
@ronny-anyscale
ronny-anyscale merged commit 4a0ac03 into master Oct 26, 2026
5 checks passed
@ronny-anyscale
ronny-anyscale deleted the djs-261026-e2e-guide-template branch October 26, 2026 17:24
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants