Skip to content

[docs] Group the Serve and Train API references and align API landing pages - #66744

Merged
dstrodtman merged 2 commits into
masterfrom
doc-1651-api-landing-pages
Oct 6, 2026
Merged

dstrodtman merged 2 commits into
masterfrom
doc-1651-api-landing-pages

Conversation

@dstrodtman

Copy link
Copy Markdown
Contributor

Why are these changes needed?

The APIs tab sidebar is built from each library's API landing-page toctree. Data, Tune, RLlib, and Core land on hub pages, so their sidebars open into 10 to 15 groups. Serve and Train landed on monolithic content pages with every autosummary table inline, so their sidebars listed 109 and 61 symbols flat. Ambiguous names had no context: RayTrainReportCallback appeared four times and prepare_trainer twice, with nothing to say which framework each belonged to.

This PR does the following:

  • Splits Serve and Train into hub landing pages with one sub-page per API group. Groups follow the public module each API is imported from, such as ray.serve.config, ray.serve.schema, ray.train.torch, and ray.train.lightning, as determined from each package's __init__ exports and @PublicAPI/@DeveloperAPI annotations.
    • Serve: Writing applications, Deployment handles, Running applications, Configuration, Runtime context, Request router, Schemas, Exceptions, Observability, LLM API, CLI, REST API.
    • Train: PyTorch, PyTorch Lightning, Hugging Face Transformers, TensorFlow and Keras, XGBoost, LightGBM, JAX, Configuration, Training function utilities, Results, Exceptions, Ray Tune integration, Developer APIs.
  • Aligns all six library API landing pages on one shape: a description, a label, an H1, a one-sentence intro, and a toctree of groups. Library-specific notices stay (the Train V2 notice and the RLlib new API stack include). The generic feedback tip and "open an issue" boilerplate on Tune and RLlib are removed.
  • Repoints the /serve/llm/api.html redirect from /serve/api/index.html#llm-api to the new /serve/api/llm.html.
  • Adds the new thin group pages to llms_txt_exclude, matching how conf.py already treats thin API hub pages. The REST API page has real prose and stays in.

What doesn't change

  • Per-symbol URLs. Autosummary entries, templates, and :toctree: doc/ paths are moved verbatim, so every generated stub page keeps its URL.
  • Labels. Every existing label (serve-api, core-apis, serve-rest-api, serve-rest-api-config-schema, serve-rest-api-response-schema, serve-llm-api, train-api, train-pytorch-integration, train-loop-api, train-backend, and the rest) moves with its content, so {ref} links resolve as before. core-apis is only used to link serve.start(), so it now lives on the Running applications page.
  • API-consistency check coverage. ci/ray_ci/doc/autodoc.py's walker, run from the unchanged head_doc_file paths, finds the same 109 Serve and 61 Train APIs before and after, with no duplicates.

Fragment links into the old monolithic Serve page, such as serve/api/index.html#serve-rest-api, now land on the hub, since a redirect can't target an anchor. No in-repo links use these fragments except a version-pinned releases-2.7.0 link, which is unaffected.

Verification

  • make -C doc rtd-build (RtD-faithful clean build, -W --keep-going): build succeeded., exit 0.
  • The generated _static/api-nav.html now shows top-level groups for every library: Data 14, Train 13, Tune 15, Serve 12, RLlib 13, Core 10.
  • rtd-redirects validate doc/redirects/current.yaml: 0 errors, 0 warnings.

🤖 Generated with Claude Code

@dstrodtman
dstrodtman requested review from a team as code owners October 5, 2026 19: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 reorganizes and modularizes the API reference documentation for Ray Serve and Ray Train by splitting the large index pages into individual sub-pages (such as application, config, context, exceptions, and framework-specific integrations) and updating the table of contents accordingly. It also adds HTML metadata descriptions to several API index files. The review feedback is minimal, pointing out a minor grammatical typo in a comment within the newly created application.md file.

## Deployments and applications

<!---
NOTE: `serve.deployment` and `serve.Deployment` have an autosummary-generated filename collision due to case insensitivity. This is fixed by added custom filename mappings in `source/conf.py` (look for "autosummary_filename_map"). --->

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

There is a minor grammatical typo in this comment: "fixed by added custom filename mappings" should be "fixed by adding custom filename mappings" or "fixed by the added custom filename mappings".

@dstrodtman
dstrodtman force-pushed the doc-1651-api-landing-pages branch from 83eda99 to b1aac76 Compare October 5, 2026 19:52
@ray-gardener ray-gardener Bot added serve Ray Serve Related Issue docs An issue or change related to documentation labels Oct 6, 2026
dstrodtman added a commit that referenced this pull request Oct 6, 2026
…nto doctrees (#66784)

## Why are these changes needed?

Every Markdown page with an `{eval-rst}` block pickles a full copy of
the Sphinx `BuildEnvironment` into its doctree. On master that's 25
doctrees at 28 to 40 MB each, about 0.78 GB, where the same pages are
tens of KB without the leak. The parallel HTML writer loads those
doctrees back into memory, which pushes the Read the Docs build close to
the builder's memory limit.

#66744 splits the Serve and Train API pages into 23 Markdown pages with
`{eval-rst}` blocks. Its preview build was killed for running out of
memory twice, at the start of the write phase
([4526993](https://app.readthedocs.com/projects/anyscale-ray/builds/4526993/),
[4527163](https://app.readthedocs.com/projects/anyscale-ray/builds/4527163/)).
Measured locally with RtD's command (`sphinx-build -a -E -W -j 2`), peak
memory across the Sphinx processes was 9.4 GB on master and 11.5 GB on
that PR. The ongoing RST-to-MyST conversion adds `{eval-rst}` pages with
most files it converts, so master would hit the same limit on its own.

### Cause

`myst_parser.mdit_to_docutils.base.render_restructuredtext` parses the
block into a throwaway docutils document that shares the page's
`settings` object, then moves the parsed nodes into the page with
`extend()`. docutils' `setup_child` re-points `node.document` only on
the direct children it appends. Deeper nodes that docutils gave an
explicit `document` reference during parsing, such as bullet list items,
Python domain signatures, and autosummary table rows, keep pointing at
the throwaway document. That document's `settings.env` is the live
`BuildEnvironment`.

Sphinx sets `settings.env = None` on the page's own doctree before
pickling it, but not on the throwaway document. Pickling the page
therefore pickles the whole environment, including
`sphinx.ext.viewcode`'s cache of Python module sources.

myst-parser 5.1.0, the version Ray pins, is the latest release. The
closest upstream report, executablebooks/MyST-Parser#953, covers the
same incomplete merge after `eval-rst` but only its footnote symptom.

### Fix

A new in-repo extension, `doc/source/_ext/myst_eval_rst_doctree.py`,
connects to `doctree-read`, the last event before Sphinx pickles a
doctree. It points every node that still references another document at
the page's own doctree. The nodes are part of that doctree by then, so
this is the reference docutils would have set had it re-pointed the
whole subtree.

Re-pointing the nodes in saved doctrees from a full build shrinks them
as follows:

| Doctree | Before | After |
|---|---|---|
| `ray-contribute/stability` | 39.6 MB | 50 KB |
| `cluster/vms/user-guides/community/spark` | 28.0 MB | 115 KB |
| `serve/api/exceptions` (from #66744) | 32.2 MB | 12 KB |

`doc/source/_ext/test_myst_eval_rst_doctree.py` is a hermetic test,
following the pattern of `test_llms_txt.py`. It builds a one-page MyST
project and checks the following:

- Without the extension, nodes reference the throwaway document and the
pickle carries a `BuildEnvironment`. If a MyST release fixes the leak,
this half fails, which flags the extension for removal.
- With the extension, every node references the page's doctree and the
pickle carries no `BuildEnvironment`.

It runs in a new `doc_test_myst_eval_rst_doctree` step next to
`doc_test_llms_txt`.

## Verification

- `python doc/source/_ext/test_myst_eval_rst_doctree.py` passes locally.
- This PR's Read the Docs preview build,
[4531787](https://app.readthedocs.com/projects/anyscale-ray/builds/4531787/),
passed.
- **Memory.** A local build with RtD's command (`sphinx-build -a -E -W
-j 2`), sampling total RSS across the Sphinx processes every 2 seconds:

  | Measurement | Master | With this PR |
  |---|---|---|
  | Peak memory, preparing documents | 6.61 GB | 1.90 GB |
  | Peak memory, writing output | 9.44 GB | 2.53 GB |
  | Total doctree size | 930 MB | 130 MB |
  | Doctrees over 5 MB | 25 | 0 |
  | Build time | 1,522 s | 918 s |

- **Output.** Diffing the full HTML output of the two builds:
- The 25 pages whose doctrees carried the environment render
byte-for-byte identically.
  - 30 of 9,088 output files differ, and none because of this change:
- 19 trace to upstream commits between the two builds' bases: `ray.data`
and `ray.train` source edits, `ray-core/sandboxes.md`, and the aggregate
files they feed (`api-nav.html`, `llms-full.txt`, `genindex`,
`objects.inv`).
- 11 differ between any two builds: random gallery icons, UUID equation
anchors, type-hint field order, and sitemap write order.

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

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
@dstrodtman dstrodtman added the go add ONLY when ready to merge, run all tests label Oct 6, 2026
@dstrodtman
dstrodtman enabled auto-merge (squash) October 6, 2026 18:05
… pages

The Serve and Train API landing pages were monolithic content pages with
every autosummary table inline, so the APIs tab sidebar listed 109 Serve
and 61 Train symbols flat, with no grouping. Ambiguous names such as
RayTrainReportCallback appeared four times with no framework context.

Split both into hub landing pages with one sub-page per public API group,
following the public module each API is imported from (for example
ray.serve.config, ray.serve.schema, ray.train.torch, ray.train.lightning).
Autosummary entries, templates, and `doc/` stub paths are unchanged, so
every per-symbol URL stays the same, and all existing labels move with
their content.

Align all six library API landing pages on one shape: a description, a
label, an H1, a one-sentence intro, and a toctree of groups.

Also repoint the /serve/llm/api.html redirect at the new LLM API page and
add the new thin API group pages to llms_txt_exclude, matching the
existing treatment of thin API hub pages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman
dstrodtman force-pushed the doc-1651-api-landing-pages branch from 8124504 to c35d392 Compare October 6, 2026 19:03
@github-actions
github-actions Bot disabled auto-merge October 6, 2026 19:03
dstrodtman added a commit that referenced this pull request Oct 6, 2026
…on (#66751)

## Why are these changes needed?

Four API reference pages live outside the APIs tab, so the shared API
sidebar and the `API_PATH_PREFIXES` page set don't include them. This PR
moves them into `core/api/`:

| Old path | New path |
|---|---|
| `ray-observability/reference/api.rst` | `core/api/state.rst` |
| `cluster/running-applications/job-submission/jobs-package-ref.md` |
`core/api/job-submission.md` |
| `core/compiled-graph/compiled-graph-api.rst` |
`core/api/compiled-graph.rst` |
| `cluster/running-applications/autoscaling/reference.md` |
`core/api/autoscaler.md` |

This is a pure path change: all four files are 100% renames with no
content edits. Everything else in the diff follows from the move:

- **Navigation.** The Core API toctree (`core/api/index.md`) now lists
all four pages. The old parent toctrees point at the new paths, so the
pages stay reachable from their original sections.
- **Redirects.** `doc/redirects/current.yaml` gains one `page` rule per
moved page, plus wildcard rules for the generated per-symbol stubs,
which move from each page's old `doc/` directory to `core/api/doc/`. All
rules use the default `force: false`. Existing rules that point at the
old paths are left alone, so older doc versions keep resolving them.
- **Dead stub-directory patterns.** Only these four pages generated
stubs into `ray-observability/reference/doc/`,
`cluster/running-applications/job-submission/doc/`, and
`core/compiled-graph/doc/`. Their entries in `conf.py`
(`llms_txt_exclude`, `remove_from_toctrees`), the `doc/Makefile` `clean`
target, and `doc/.gitignore` are removed. Existing `core/api/doc/*`
patterns cover the new location. One side effect: the compiled graph
stubs were missing from `remove_from_toctrees`, so they're now pruned
like every other API stub.
- **`doc_api` routing.** The `ray-observability/reference/` directory
was in the `doc_api` rule only because the Core API toctree pulled in
its `api.rst`. Now that the page lives in `core/api/`, the exception
goes away in both `.buildkite/test.rules.txt` and
`_ALLOWED_ONLY_IN_RULE` in `ci/pipeline/test_doc_api_rules_sync.py`. The
remaining pages in that directory, `cli.rst` (`click` directives only),
`index.md`, and `system-metrics.rst`, carry no `autosummary` or
`autoclass` blocks, which are the only blocks the API consistency check
parses. The `test.rules.test.txt` expectation moves to
`core/api/state.rst`.

**Effect on the Core API consistency check.** The check walks the
toctree from `core/api/index.md`, so it now also reads the job
submission and compiled graph pages. The autoscaler page uses
`autofunction`, which the check doesn't parse. I ran the check's
Sphinx-free doc parser (`ci/ray_ci/doc/autodoc.py`) over the new walk.
It finds 188 documented APIs, and the only names documented twice are
`ray.get`, `ray.put`, `ray.method`, and `ray.remote`, all already in
Core's `intentional_duplicate_apis`. `ActorMethod.bind`, documented in
both `core.rst` and the compiled graph page, is also already exempt.
None of the newly walked classes resolves to a private module path. I
couldn't run the code-side half of the check locally because it needs a
compiled Ray, so premerge's `doc: check API doc consistency` step is the
gate for that half.

**Stacking.** This branch is stacked on #66605 (move Ray Core docs to
`doc/source/core`), which touches the same surfaces: `api_sidebar.py`,
`apis/index.md`, the redirects file, and the `doc_api` rules. Merge
#66605 first. #66744 also edits `doc/redirects/current.yaml`, so expect
a small rebase there.

## Related issue number

None. This is groundwork for moving the API reference off Sphinx
autodoc: every page the API reference generator needs to reproduce
should live under an `API_PATH_PREFIXES` directory.

## Checks

- [x] I've signed off every commit (DCO).
- [x] Duplicate-work check: `gh pr list --repo ray-project/ray --state
open --search "<area keywords>"` found no open PR moving these pages.
The overlapping PRs are #66605, which this stacks on, and #66744, which
only shares the redirects file.
- [x] `bazel test //ci/pipeline:test_doc_api_rules_sync`: PASSED.
- [x] `rtd-redirects validate doc/redirects/current.yaml`: 0 errors, 0
warnings. Chain notes went from 171 to 181, from the two-hop paths
described above.
- [x] Tag dry run (Ray's `determine_tests_to_run.py` reference parser):
`core/api/state.rst` and `core/api/job-submission.md` emit `doc_api`,
and `ray-observability/reference/{cli.rst,index.md}` hit the prose skip
rule.
- [x] `make -C doc rtd-build` (RtD-faithful, `-W --keep-going`, Python
3.11 and the docs lock): exactly one warning, `_includes/_help.rst:
document isn't included in any toctree`. That orphan is in this branch's
base (#66605) and was already deleted on master by #66750. With it
removed locally, an incremental `-W` rebuild reports `build succeeded.`
with zero warnings. The four pages render at
`core/api/{state,job-submission,compiled-graph,autoscaler}.html`, and
their 116 generated stubs render under `core/api/doc/`.
- [x] `rtd-redirects simulate` against #66605 as the base, covering
master (built HTML), latest, `releases-2.55.0`, and `releases-2.40.0`,
with `--prefix` on all three old directories, sample stub URLs, and a
stub rename map: **0 regressions and 0 new loops on every version.** It
still exits nonzero, for two reasons I checked by hand:
- On master, 35 old stub URLs are flagged as "wrong landings" only
because the before side is a git tree, which has no generated stubs. All
35 land on the identical stub under `core/api/doc/` in one hop.
- On every version, the synthetic sample stub (`__simulate-sample__`, a
name that never existed) now lands on the Core API index instead of the
observability landing page. Real stubs on older releases are still
served directly, because the rules don't force.

AI assistance (Claude Code) was used to prepare this change. I reviewed
every changed line.

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

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

# Conflicts:
#	doc/source/conf.py
@dstrodtman
dstrodtman enabled auto-merge (squash) October 6, 2026 19:41
@github-actions
github-actions Bot disabled auto-merge October 6, 2026 19:41
@dstrodtman
dstrodtman merged commit 9b6495f into master Oct 6, 2026
7 checks passed
@dstrodtman
dstrodtman deleted the doc-1651-api-landing-pages branch October 6, 2026 20:45
dstrodtman added a commit that referenced this pull request Oct 7, 2026
)

## Why are these changes needed?

Stacked on #66744.

A Sphinx build of master logs 265 `document is referenced in multiple
toctrees` messages. They're info-level, so they don't fail the build,
but every one marks a page whose sidebar parent and breadcrumb Sphinx
has to choose arbitrarily. This PR removes 245 of them. The other 20 are
on Ray Core API pages and are left for separate follow-ups.

### Autosummary entries listed twice (240)

Most duplicates come from a hand-written API page that lists a class
with `:toctree: doc/` and then lists that class's methods in further
`:toctree:` blocks. The class stub, rendered from
`_templates/autosummary/class.rst`, already lists every documented
method in its own `:toctree:` autosummary, so each method stub ends up
with two parents. Similarly, `train/api/deprecated.rst` re-lists APIs
that the Train API pages also list, and `data/api/saving_data.rst`
re-lists `Dataset` methods that the Dataset page owns.

The fix drops `:toctree:` from the duplicated entries only. The tables
still render and link to the same stub pages, since autosummary links
entries by object reference. The stubs are still generated, because
autosummary recurses into generated stubs and the class stub's own
`:toctree:` block covers them. Where a block mixed duplicated and unique
entries, it's split into consecutive blocks in the original order, so
only the duplicated runs lose `:toctree:`. That split adds a small gap
between table rows on a few pages, for example `Learner` /
`Learner.build` / `Learner._make_module` in the RLlib Learner reference.

Files: RLlib `package_ref` (12 pages), Tune `api` (9 pages), Data
`saving_data` and `preprocessor`, Train `deprecated`.

### Hand-written navigation duplicates (3 pages)

- `cluster/vms/user-guides/community/index.md` had a hidden toctree
repeating `yarn`, `slurm`, and `lsf` from the visible toctree below it.
Removed the hidden one.
- `ray-references/faq.md`, an orphan page, listed `tune/faq` in a
toctree that competed with `tune/index`. It's now a plain `{doc}` link.
- `ray-observability/ray-distributed-debugger.md` sat in both
`ray-observability/index.md` and `user-guides/debug-apps/index.md`. Kept
it in the top-level observability toctree, which matches the file's
location, and removed it from the debug-apps toctree. The debug-apps
page still links it from its bullet list. **Reviewer call:** if the
debugger should live under Debugging Applications in the sidebar
instead, flip which toctree keeps it.

### Left for follow-ups (20)

These were deferred while #66605 (Ray Core directory move) and #66751
(API reference page moves) were in flight. Both have merged, and the
duplicates remain on the moved pages:

- 13 come from #66751 keeping each moved page in its original section's
toctree as well as in `core/api/index.md`: `core/api/job-submission.md`
and its eight `JobSubmissionClient` method stubs,
`job-submission/cli.md`, `core/api/autoscaler.md`,
`core/api/compiled-graph.rst`, and the `ActorMethod.bind` stub. Whether
those pages keep a second home in their original sections is a
navigation decision for that change, not a mechanical fix.
- 2 are `core/api/state.rst` and `ray-observability/reference/cli.rst`,
listed from both the observability reference index and the Core API
index.
- 5 are Core API stubs listed twice within `core/api/`: `ray.get`,
`ray.put`, and `ray.method` (`core` and `direct-transport`),
`ActorClass.options` (the `ActorClass` stub and `core`), and
`ray.remote` (twice in `core`).

## Related issue number

None.

## Checks

- Duplicate-work check: `gh pr list --repo ray-project/ray --state open
--search "toctree"` and a review of my open docs PRs found no other PR
addressing these messages. None of my other open PRs touch the files
changed here.
- `pre-commit run --files <changed files>` passed.
- The duplicate list comes from the RtD build log for #66744 (build
4527202). Each removed `:toctree:` entry was matched by fully qualified
name against a document that log reports as having a second parent, and
only entries on that list were changed.
- RtD preview build 4532297 succeeded and logged 18 `multiple toctrees`
messages, against 263 for #66744 before this change. It reported no
Sphinx warnings and no missing autosummary stubs. That build predates
the base branch's merge of #66605 and #66751, which brought the leftover
count to 20.
- After merging the current base, this branch's tree is identical to the
base plus the original dedupe commit, checked by applying that commit's
patch to the base tree and comparing tree hashes.

This PR was prepared with AI assistance (Claude Code).

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

---------

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

Labels

docs An issue or change related to documentation go add ONLY when ready to merge, run all tests serve Ray Serve Related Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants