Skip to content

rtd_enhanced_search.js hits v3 API without version, RTD returns stable results on non-stable builds #327

Description

@karlhillx

In src/sunpy_sphinx_theme/theme/sunpy/static/js/rtd_enhanced_search.js, getReadTheDocsResults builds the URL as /_/api/v3/search/?q=project:<slug>+<term> with no version parameter. RTD falls back to the project's default version (stable), so search results on /en/latest/ link to /en/stable/ pages.

This affects any project using the sunpy theme (including astropy, which inherits from it via the astropy-unified theme — see astropy/astropy#19866, closed in favor of this fix).

Repro: build docs on RTD on a non-stable branch, click a search result, URL shows /en/stable/.

Fix: capture versions.current.slug from the readthedocs-addons-data-ready event, append &version=<slug> to the query. Patch is small, ~6 lines in rtd_enhanced_search.js.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions