Skip to content

[doc][DOC-898] probe: remove MockedClassDocumenter monkey-patch in conf.py - #63197

Merged
elliot-barn merged 1 commit into
ray-project:masterfrom
dstrodtman:djs-260507-probe-mocked-class-documenter
May 8, 2026
Merged

elliot-barn merged 1 commit into
ray-project:masterfrom
dstrodtman:djs-260507-probe-mocked-class-documenter

Conversation

@dstrodtman

Copy link
Copy Markdown
Contributor

Why

The Anyscale docs team is auditing doc/source/conf.py against current Ray state as part of strategy work tracked in anyscale/docs#2064. One finding: conf.py globally swaps sphinx.ext.autodoc.ClassDocumenter with a MockedClassDocumenter subclass that suppresses the Bases: object line for classes that inherit directly from object.

The patch was added in #39982 (Oct 2023). It's a cosmetic workaround. Two reasons it may now be obsolete:

  1. Modern pydata-sphinx-theme (Ray pins 0.14.1; current is 0.16.x) renders base class lines differently than it did when the patch was authored.
  2. Global monkey patches at conf.py module scope are a fragility liability — if a future Sphinx ClassDocumenter signature change lands, the patch breaks the build at import. The cosmetic value should be weighed against that ongoing maintenance cost.

What this PR does

  1. Removes the MockedClassDocumenter class and its global assignment to sphinx.ext.autodoc.ClassDocumenter.
  2. Removes the now-unused from sphinx.ext import autodoc import.

How to validate

This is a probe, not a request-for-merge. The validation surfaces are:

  1. RtD PR preview build — runs against this branch. With fail_on_warning: true set in .readthedocs.yaml, any new Sphinx warning means the patch was still load-bearing in a non-cosmetic way.
  2. doc: check API doc consistency — premerge step that runs make -C doc/ html internally. Same fail-on-warning gate.
  3. Visual diff of any API ref page for a class that inherits directly from object. If Bases: object reappears in those pages, the patch was effectively suppressing visible noise — keep it. If the line is rendered the same way (or absent) by the modern theme without the patch, drop it.

Possible outcomes

  • Build clean, no visible regression → the patch is dead weight. Drop.
  • Build clean, Bases: object reappears on many pages → the patch is doing what it claims. Keep, and add a comment explaining what would replace it (a CSS rule on the modern theme's rendered output, or a different autodoc filter).
  • Build fails → the patch was load-bearing in a way nobody documented. Revert and document.

Status

Draft. Posting for visibility and validation, not for merge. Looking for a Ray maintainer to confirm whether the cosmetic suppression is still desired and whether there's a less-fragile mechanism to achieve it. Justin Yu @justinvyu, Aydin Abiar @aslonnie, or Elliot Barnwell @ebarn-anyscale would all be reasonable reviewers given recent activity in this area.

🤖 Generated with Claude Code

The MockedClassDocumenter class globally replaces sphinx.ext.autodoc.
ClassDocumenter to suppress the "Bases: object" line when a class
inherits from object. Added in ray-project#39982 (Oct 2023) for purely cosmetic
reasons.

This is a docs-team probe PR to validate the hypothesis that the
patch is no longer needed. Modern pydata-sphinx-theme handles base
class rendering differently than it did at the original landing time.
Surfaced by an audit of conf.py settings against current Ray state
in the docs-team strategy work (anyscale/docs#2064).

Also drops the now-unused `from sphinx.ext import autodoc` import.

Validation surface: the RtD preview build on this PR plus the
api_policy_check premerge step (which runs make -C doc/ html) will
exercise the doc build under fail_on_warning. If the build is clean,
the only visible change should be that classes inheriting directly
from object now show "Bases: object" in their API ref pages.

If that visible change is unwanted, the patch is still load-bearing
and we should keep it. If the visible change is acceptable (or the
modern theme renders it differently than expected), the patch is
safe to drop.

Marking as draft. Not requesting merge until a Ray maintainer weighs
in. Reviewers: Justin Yu, Aydin Abiar, Elliot Barnwell would all be
reasonable points of contact.

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

@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 removes a monkey-patch in doc/source/conf.py that was used to suppress the 'Bases: object' line in Sphinx documentation. The reviewer suggests that if this functionality is still needed for visual consistency, the official autodoc-process-bases event should be used instead of monkey-patching, as it is a supported and more maintainable approach.

I am having trouble creating individual review comments. Click here to see my feedback.

doc/source/conf.py (848-857)

medium

Removing this monkey-patch is a good improvement for maintainability. If the probe shows that suppressing the Bases: object line is still required for visual consistency, consider using the official autodoc-process-bases event (available since Sphinx 4.1) instead of re-introducing a monkey-patch. This event provides a list of base classes that can be modified in place, which is the supported and non-fragile way to achieve this.

Example implementation:

def filter_bases(app, name, obj, options, bases):
    if len(bases) == 1 and bases[0] is object:
        bases.clear()

# In setup(app):
app.connect("autodoc-process-bases", filter_bases)

@dstrodtman
dstrodtman marked this pull request as ready for review May 7, 2026 16:47
@dstrodtman
dstrodtman requested a review from a team as a code owner May 7, 2026 16:47
@dstrodtman
dstrodtman marked this pull request as draft May 7, 2026 16:50
@dstrodtman
dstrodtman marked this pull request as ready for review May 7, 2026 16:54
@dstrodtman dstrodtman changed the title [doc] probe: remove MockedClassDocumenter monkey-patch in conf.py [doc][DOC-898] probe: remove MockedClassDocumenter monkey-patch in conf.py May 7, 2026
@dstrodtman

Copy link
Copy Markdown
Contributor Author

Validation against the RtD preview build

Tracked in DOC-898. Build under fail_on_warning: true succeeded, so the patch wasn't load-bearing for build-time autodoc behavior. Followed up with an HTML scan of representative API ref pages to confirm there's no visible regression.

HTML scan against the preview

Counted occurrences of "Bases" across eight representative API ref pages on this PR's preview vs. current latest (pydata-sphinx-theme 0.14.1, Sphinx 7.3.7 in both):

Page Preview (#63197, patch removed) Current latest (patch active)
data/api/dataset.html (renders Dataset, inherits object) 0 0
data/api/data_iterator.html 0 0
data/api/dataset_context.html 0 —
serve/api/index.html 0 0
train/api/api.html 0 0
tune/api/api.html 0 0
ray-core/api/index.html 0 0
rllib/package_ref/index.html 0 0
serve/api/doc/ray.serve.config.AutoscalingConfig.html (Pydantic, non-object base) 0 0

WebFetch of ray.serve.Deployment and ray.serve.Application (both @PublicAPI-decorated, both inherit directly from object) also came back "Bases: not present" on the preview.

Visual inspection

Spot-checked by @dstrodtman against representative pages — preview matches current latest. No visible regression.

Why this signal is conclusive

The patch's filter targets the literal autodoc-emitted line Bases: :py:class:\object`before HTML rendering. If autodoc no longer emits that line (likely because Sphinx 7.x silently dropped the "Bases: object" announcement for default-base classes — consistent with what's observed on both the preview andlatest`), the patch never fires. Either way, the visible output is identical.

Recommendation

Marking ready for review. Same logic as #63196: green build + no visible regression = safe to merge. Reviewer is welcome to spot-check additional pages, but I don't see a plausible failure mode the build and the HTML scan didn't already cover.

@ray-gardener ray-gardener Bot added the core Issues that should be addressed in Ray Core label May 7, 2026
@dstrodtman dstrodtman added the go add ONLY when ready to merge, run all tests label May 8, 2026
@edoakes

edoakes commented May 8, 2026

Copy link
Copy Markdown
Collaborator

LGTM assuming we don't render the bases: object w/o the patch

@elliot-barn
elliot-barn merged commit 66de00b into ray-project:master May 8, 2026
4 checks passed
Lucas61000 pushed a commit to Lucas61000/ray that referenced this pull request May 15, 2026
…nf.py (ray-project#63197)

## Why

The Anyscale docs team is auditing `doc/source/conf.py` against current
Ray state as part of strategy work tracked in
[anyscale/docs#2064](anyscale/docs#2064). One
finding: `conf.py` globally swaps `sphinx.ext.autodoc.ClassDocumenter`
with a `MockedClassDocumenter` subclass that suppresses the `Bases:
object` line for classes that inherit directly from `object`.

The patch was added in
[ray-project#39982](ray-project#39982) (Oct 2023). It's
a cosmetic workaround. Two reasons it may now be obsolete:

1. **Modern pydata-sphinx-theme** (Ray pins 0.14.1; current is 0.16.x)
renders base class lines differently than it did when the patch was
authored.
2. **Global monkey patches at conf.py module scope** are a fragility
liability — if a future Sphinx ClassDocumenter signature change lands,
the patch breaks the build at import. The cosmetic value should be
weighed against that ongoing maintenance cost.

## What this PR does

1. Removes the `MockedClassDocumenter` class and its global assignment
to `sphinx.ext.autodoc.ClassDocumenter`.
2. Removes the now-unused `from sphinx.ext import autodoc` import.

## How to validate

This is a probe, not a request-for-merge. The validation surfaces are:

1. **RtD PR preview build** — runs against this branch. With
`fail_on_warning: true` set in `.readthedocs.yaml`, any new Sphinx
warning means the patch was still load-bearing in a non-cosmetic way.
2. **`doc: check API doc consistency`** — premerge step that runs `make
-C doc/ html` internally. Same fail-on-warning gate.
3. **Visual diff of any API ref page** for a class that inherits
directly from `object`. If `Bases: object` reappears in those pages, the
patch was effectively suppressing visible noise — keep it. If the line
is rendered the same way (or absent) by the modern theme without the
patch, drop it.

## Possible outcomes

- **Build clean, no visible regression** → the patch is dead weight.
Drop.
- **Build clean, `Bases: object` reappears on many pages** → the patch
is doing what it claims. Keep, and add a comment explaining what would
replace it (a CSS rule on the modern theme's rendered output, or a
different autodoc filter).
- **Build fails** → the patch was load-bearing in a way nobody
documented. Revert and document.

## Status

**Draft.** Posting for visibility and validation, not for merge. Looking
for a Ray maintainer to confirm whether the cosmetic suppression is
still desired and whether there's a less-fragile mechanism to achieve
it. Justin Yu @justinvyu, Aydin Abiar @aslonnie, or Elliot Barnwell
@ebarn-anyscale would all be reasonable reviewers given recent activity
in this area.

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

Signed-off-by: Douglas Strodtman <[email protected]>
elliot-barn pushed a commit that referenced this pull request May 18, 2026
## Why

Add `sphinxext-opengraph` — per-page Open Graph metadata. `ogp_site_url`
is pinned to `html_baseurl` so the `og:url` tag stays aligned with
Sphinx's `<link rel="canonical">`. Improves rich-link previews when docs
pages get shared and tightens SEO signal. Low-effort additive change
called out as a Bucket 1 quick win in the Anyscale docs team's
agent-friendliness assessment.

## What

- `doc/requirements-doc.txt`: add `sphinxext-opengraph==0.13.0`.
- `doc/source/conf.py`: append `"sphinxext.opengraph"` to `extensions`;
set `ogp_site_url = html_baseurl`.
- `python/deplocks/docs/docbuild_depset_py3.10.lock`: package entry plus
via-comment addition on `sphinx` (the only runtime dep, already pinned,
so no further transitives). Matches the manual-lock-edit pattern used in
[#63130](#63130).

## Verification

After this lands and `latest` rebuilds:

- A representative doc page's `<head>` includes `<meta property="og:*">`
tags reflecting page title, description, and the site URL.
- No new warnings in the RtD build log (`fail_on_warning: true`).

## Extension diligence


[`sphinxext-opengraph`](https://github.com/sphinx-doc/sphinxext-opengraph)
— official `sphinx-doc` org project, BSD-2-Clause. Latest release 0.13.0
(March 2026). Pure-Python, depends only on Sphinx (already pinned to
7.3.7), no system-level requirements.

## What changed in the force-push

This PR originally also bundled
[`sphinx-notfound-page`](https://github.com/readthedocs/sphinx-notfound-page)
to give the Ray docs a 404 page with absolute URLs. Dropped on
2026-05-15 because the RtD PR preview build surfaced a sitewide
regression: 732 of 756 `<a class="reference internal">` sidebar hrefs
were emitted with a `.//en/<ver>/...` prefix that doubles when the
browser resolves them against the build's `/en/<ver>/` deploy path.
Production docs.ray.io (which doesn't have the extension) was unaffected
(0/747 hrefs).

The cause is sphinx-notfound-page's `html-page-context` hook: it
overrides `pathto`/`toctree` for **every** page in the build, prepending
a URL prefix derived from `READTHEDOCS_CANONICAL_URL`. The extension
docs imply this is "for the 404 page only," but the override fires on
every page-context event. On a PR preview where the canonical URL
differs from `html_baseurl`, this produces the doubled-prefix
anti-pattern across the entire sidebar.

The 404-page-with-absolute-URLs goal is tracked separately so it can be
re-attempted with a config or extension that doesn't break sitewide
navigation. Options to revisit: `notfound_urls_prefix = None`, a custom
404 template that bypasses the global `pathto` override, or
`html_extra_path` with a static 404.

## Context

Part of the [DOC-932](https://anyscale1.atlassian.net/browse/DOC-932)
campaign: Ray docs dependency upgrades. Pattern mirrors the merged
[DOC-898](https://anyscale1.atlassian.net/browse/DOC-898) probe
([#63197](#63197)) and the
obsolete-env-var removal in
[#63196](#63196). Strategy
context: `anyscale/docs:strategy/ray-docs/sphinx-rtd-viability.md` "Low
effort" section.

This is the bottom of a stacked series:

1. **#63343 — sphinxext-opengraph (this PR)**
2. [#63344](#63344) —
pydata-sphinx-theme bump
3. [#63359](#63359) — notebook
`language_info.name` fix
4. [#63360](#63360) — myst-nb
1.4.0 bump

[DOC-933](https://anyscale1.atlassian.net/browse/DOC-933)

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
TruongQuangPhat pushed a commit to cyhapun/ray-fix-issue that referenced this pull request May 27, 2026
## Why

Add `sphinxext-opengraph` — per-page Open Graph metadata. `ogp_site_url`
is pinned to `html_baseurl` so the `og:url` tag stays aligned with
Sphinx's `<link rel="canonical">`. Improves rich-link previews when docs
pages get shared and tightens SEO signal. Low-effort additive change
called out as a Bucket 1 quick win in the Anyscale docs team's
agent-friendliness assessment.

## What

- `doc/requirements-doc.txt`: add `sphinxext-opengraph==0.13.0`.
- `doc/source/conf.py`: append `"sphinxext.opengraph"` to `extensions`;
set `ogp_site_url = html_baseurl`.
- `python/deplocks/docs/docbuild_depset_py3.10.lock`: package entry plus
via-comment addition on `sphinx` (the only runtime dep, already pinned,
so no further transitives). Matches the manual-lock-edit pattern used in
[ray-project#63130](ray-project#63130).

## Verification

After this lands and `latest` rebuilds:

- A representative doc page's `<head>` includes `<meta property="og:*">`
tags reflecting page title, description, and the site URL.
- No new warnings in the RtD build log (`fail_on_warning: true`).

## Extension diligence

[`sphinxext-opengraph`](https://github.com/sphinx-doc/sphinxext-opengraph)
— official `sphinx-doc` org project, BSD-2-Clause. Latest release 0.13.0
(March 2026). Pure-Python, depends only on Sphinx (already pinned to
7.3.7), no system-level requirements.

## What changed in the force-push

This PR originally also bundled
[`sphinx-notfound-page`](https://github.com/readthedocs/sphinx-notfound-page)
to give the Ray docs a 404 page with absolute URLs. Dropped on
2026-05-15 because the RtD PR preview build surfaced a sitewide
regression: 732 of 756 `<a class="reference internal">` sidebar hrefs
were emitted with a `.//en/<ver>/...` prefix that doubles when the
browser resolves them against the build's `/en/<ver>/` deploy path.
Production docs.ray.io (which doesn't have the extension) was unaffected
(0/747 hrefs).

The cause is sphinx-notfound-page's `html-page-context` hook: it
overrides `pathto`/`toctree` for **every** page in the build, prepending
a URL prefix derived from `READTHEDOCS_CANONICAL_URL`. The extension
docs imply this is "for the 404 page only," but the override fires on
every page-context event. On a PR preview where the canonical URL
differs from `html_baseurl`, this produces the doubled-prefix
anti-pattern across the entire sidebar.

The 404-page-with-absolute-URLs goal is tracked separately so it can be
re-attempted with a config or extension that doesn't break sitewide
navigation. Options to revisit: `notfound_urls_prefix = None`, a custom
404 template that bypasses the global `pathto` override, or
`html_extra_path` with a static 404.

## Context

Part of the [DOC-932](https://anyscale1.atlassian.net/browse/DOC-932)
campaign: Ray docs dependency upgrades. Pattern mirrors the merged
[DOC-898](https://anyscale1.atlassian.net/browse/DOC-898) probe
([ray-project#63197](ray-project#63197)) and the
obsolete-env-var removal in
[ray-project#63196](ray-project#63196). Strategy
context: `anyscale/docs:strategy/ray-docs/sphinx-rtd-viability.md` "Low
effort" section.

This is the bottom of a stacked series:

1. **ray-project#63343 — sphinxext-opengraph (this PR)**
2. [ray-project#63344](ray-project#63344) —
pydata-sphinx-theme bump
3. [ray-project#63359](ray-project#63359) — notebook
`language_info.name` fix
4. [ray-project#63360](ray-project#63360) — myst-nb
1.4.0 bump

[DOC-933](https://anyscale1.atlassian.net/browse/DOC-933)

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: phattruong <[email protected]>
alexandrplashchinsky pushed a commit to alexandrplashchinsky/ray-alex that referenced this pull request May 29, 2026
…nf.py (ray-project#63197)

## Why

The Anyscale docs team is auditing `doc/source/conf.py` against current
Ray state as part of strategy work tracked in
[anyscale/docs#2064](anyscale/docs#2064). One
finding: `conf.py` globally swaps `sphinx.ext.autodoc.ClassDocumenter`
with a `MockedClassDocumenter` subclass that suppresses the `Bases:
object` line for classes that inherit directly from `object`.

The patch was added in
[ray-project#39982](ray-project#39982) (Oct 2023). It's
a cosmetic workaround. Two reasons it may now be obsolete:

1. **Modern pydata-sphinx-theme** (Ray pins 0.14.1; current is 0.16.x)
renders base class lines differently than it did when the patch was
authored.
2. **Global monkey patches at conf.py module scope** are a fragility
liability — if a future Sphinx ClassDocumenter signature change lands,
the patch breaks the build at import. The cosmetic value should be
weighed against that ongoing maintenance cost.

## What this PR does

1. Removes the `MockedClassDocumenter` class and its global assignment
to `sphinx.ext.autodoc.ClassDocumenter`.
2. Removes the now-unused `from sphinx.ext import autodoc` import.

## How to validate

This is a probe, not a request-for-merge. The validation surfaces are:

1. **RtD PR preview build** — runs against this branch. With
`fail_on_warning: true` set in `.readthedocs.yaml`, any new Sphinx
warning means the patch was still load-bearing in a non-cosmetic way.
2. **`doc: check API doc consistency`** — premerge step that runs `make
-C doc/ html` internally. Same fail-on-warning gate.
3. **Visual diff of any API ref page** for a class that inherits
directly from `object`. If `Bases: object` reappears in those pages, the
patch was effectively suppressing visible noise — keep it. If the line
is rendered the same way (or absent) by the modern theme without the
patch, drop it.

## Possible outcomes

- **Build clean, no visible regression** → the patch is dead weight.
Drop.
- **Build clean, `Bases: object` reappears on many pages** → the patch
is doing what it claims. Keep, and add a comment explaining what would
replace it (a CSS rule on the modern theme's rendered output, or a
different autodoc filter).
- **Build fails** → the patch was load-bearing in a way nobody
documented. Revert and document.

## Status

**Draft.** Posting for visibility and validation, not for merge. Looking
for a Ray maintainer to confirm whether the cosmetic suppression is
still desired and whether there's a less-fragile mechanism to achieve
it. Justin Yu @justinvyu, Aydin Abiar @aslonnie, or Elliot Barnwell
@ebarn-anyscale would all be reasonable reviewers given recent activity
in this area.

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

Signed-off-by: Douglas Strodtman <[email protected]>
Signed-off-by: Alexandr Plashchinsky <[email protected]>
alexandrplashchinsky pushed a commit to alexandrplashchinsky/ray-alex that referenced this pull request May 29, 2026
## Why

Add `sphinxext-opengraph` — per-page Open Graph metadata. `ogp_site_url`
is pinned to `html_baseurl` so the `og:url` tag stays aligned with
Sphinx's `<link rel="canonical">`. Improves rich-link previews when docs
pages get shared and tightens SEO signal. Low-effort additive change
called out as a Bucket 1 quick win in the Anyscale docs team's
agent-friendliness assessment.

## What

- `doc/requirements-doc.txt`: add `sphinxext-opengraph==0.13.0`.
- `doc/source/conf.py`: append `"sphinxext.opengraph"` to `extensions`;
set `ogp_site_url = html_baseurl`.
- `python/deplocks/docs/docbuild_depset_py3.10.lock`: package entry plus
via-comment addition on `sphinx` (the only runtime dep, already pinned,
so no further transitives). Matches the manual-lock-edit pattern used in
[ray-project#63130](ray-project#63130).

## Verification

After this lands and `latest` rebuilds:

- A representative doc page's `<head>` includes `<meta property="og:*">`
tags reflecting page title, description, and the site URL.
- No new warnings in the RtD build log (`fail_on_warning: true`).

## Extension diligence

[`sphinxext-opengraph`](https://github.com/sphinx-doc/sphinxext-opengraph)
— official `sphinx-doc` org project, BSD-2-Clause. Latest release 0.13.0
(March 2026). Pure-Python, depends only on Sphinx (already pinned to
7.3.7), no system-level requirements.

## What changed in the force-push

This PR originally also bundled
[`sphinx-notfound-page`](https://github.com/readthedocs/sphinx-notfound-page)
to give the Ray docs a 404 page with absolute URLs. Dropped on
2026-05-15 because the RtD PR preview build surfaced a sitewide
regression: 732 of 756 `<a class="reference internal">` sidebar hrefs
were emitted with a `.//en/<ver>/...` prefix that doubles when the
browser resolves them against the build's `/en/<ver>/` deploy path.
Production docs.ray.io (which doesn't have the extension) was unaffected
(0/747 hrefs).

The cause is sphinx-notfound-page's `html-page-context` hook: it
overrides `pathto`/`toctree` for **every** page in the build, prepending
a URL prefix derived from `READTHEDOCS_CANONICAL_URL`. The extension
docs imply this is "for the 404 page only," but the override fires on
every page-context event. On a PR preview where the canonical URL
differs from `html_baseurl`, this produces the doubled-prefix
anti-pattern across the entire sidebar.

The 404-page-with-absolute-URLs goal is tracked separately so it can be
re-attempted with a config or extension that doesn't break sitewide
navigation. Options to revisit: `notfound_urls_prefix = None`, a custom
404 template that bypasses the global `pathto` override, or
`html_extra_path` with a static 404.

## Context

Part of the [DOC-932](https://anyscale1.atlassian.net/browse/DOC-932)
campaign: Ray docs dependency upgrades. Pattern mirrors the merged
[DOC-898](https://anyscale1.atlassian.net/browse/DOC-898) probe
([ray-project#63197](ray-project#63197)) and the
obsolete-env-var removal in
[ray-project#63196](ray-project#63196). Strategy
context: `anyscale/docs:strategy/ray-docs/sphinx-rtd-viability.md` "Low
effort" section.

This is the bottom of a stacked series:

1. **ray-project#63343 — sphinxext-opengraph (this PR)**
2. [ray-project#63344](ray-project#63344) —
pydata-sphinx-theme bump
3. [ray-project#63359](ray-project#63359) — notebook
`language_info.name` fix
4. [ray-project#63360](ray-project#63360) — myst-nb
1.4.0 bump

[DOC-933](https://anyscale1.atlassian.net/browse/DOC-933)

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: Alexandr Plashchinsky <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
## Why

Add `sphinxext-opengraph` — per-page Open Graph metadata. `ogp_site_url`
is pinned to `html_baseurl` so the `og:url` tag stays aligned with
Sphinx's `<link rel="canonical">`. Improves rich-link previews when docs
pages get shared and tightens SEO signal. Low-effort additive change
called out as a Bucket 1 quick win in the Anyscale docs team's
agent-friendliness assessment.

## What

- `doc/requirements-doc.txt`: add `sphinxext-opengraph==0.13.0`.
- `doc/source/conf.py`: append `"sphinxext.opengraph"` to `extensions`;
set `ogp_site_url = html_baseurl`.
- `python/deplocks/docs/docbuild_depset_py3.10.lock`: package entry plus
via-comment addition on `sphinx` (the only runtime dep, already pinned,
so no further transitives). Matches the manual-lock-edit pattern used in
[ray-project#63130](ray-project#63130).

## Verification

After this lands and `latest` rebuilds:

- A representative doc page's `<head>` includes `<meta property="og:*">`
tags reflecting page title, description, and the site URL.
- No new warnings in the RtD build log (`fail_on_warning: true`).

## Extension diligence

[`sphinxext-opengraph`](https://github.com/sphinx-doc/sphinxext-opengraph)
— official `sphinx-doc` org project, BSD-2-Clause. Latest release 0.13.0
(March 2026). Pure-Python, depends only on Sphinx (already pinned to
7.3.7), no system-level requirements.

## What changed in the force-push

This PR originally also bundled
[`sphinx-notfound-page`](https://github.com/readthedocs/sphinx-notfound-page)
to give the Ray docs a 404 page with absolute URLs. Dropped on
2026-05-15 because the RtD PR preview build surfaced a sitewide
regression: 732 of 756 `<a class="reference internal">` sidebar hrefs
were emitted with a `.//en/<ver>/...` prefix that doubles when the
browser resolves them against the build's `/en/<ver>/` deploy path.
Production docs.ray.io (which doesn't have the extension) was unaffected
(0/747 hrefs).

The cause is sphinx-notfound-page's `html-page-context` hook: it
overrides `pathto`/`toctree` for **every** page in the build, prepending
a URL prefix derived from `READTHEDOCS_CANONICAL_URL`. The extension
docs imply this is "for the 404 page only," but the override fires on
every page-context event. On a PR preview where the canonical URL
differs from `html_baseurl`, this produces the doubled-prefix
anti-pattern across the entire sidebar.

The 404-page-with-absolute-URLs goal is tracked separately so it can be
re-attempted with a config or extension that doesn't break sitewide
navigation. Options to revisit: `notfound_urls_prefix = None`, a custom
404 template that bypasses the global `pathto` override, or
`html_extra_path` with a static 404.

## Context

Part of the [DOC-932](https://anyscale1.atlassian.net/browse/DOC-932)
campaign: Ray docs dependency upgrades. Pattern mirrors the merged
[DOC-898](https://anyscale1.atlassian.net/browse/DOC-898) probe
([ray-project#63197](ray-project#63197)) and the
obsolete-env-var removal in
[ray-project#63196](ray-project#63196). Strategy
context: `anyscale/docs:strategy/ray-docs/sphinx-rtd-viability.md` "Low
effort" section.

This is the bottom of a stacked series:

1. **ray-project#63343 — sphinxext-opengraph (this PR)**
2. [ray-project#63344](ray-project#63344) —
pydata-sphinx-theme bump
3. [ray-project#63359](ray-project#63359) — notebook
`language_info.name` fix
4. [ray-project#63360](ray-project#63360) — myst-nb
1.4.0 bump

[DOC-933](https://anyscale1.atlassian.net/browse/DOC-933)

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: 400Ping <[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 go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants