Skip to content

Parser: honor the project's root selector when finding the main content node #13259

Description

@ericholscher

AddonsConfig.options_root_selector lets a project tell us where its main content is — "CSS selector for the main content of the page. Leave it blank for auto-detect." We only send it to the addons client.

The server-side parser ignores it. GenericParser._get_main_node() in readthedocs/search/parsers.py always auto-detects: [role=main], then <main>, then the first <h1>'s parent, then <body>.

So a project that set the selector because auto-detect picks the wrong node still gets indexed for search, and hashed for the file tree diff, from the node it told us not to use.

Honoring it is a few lines, self.project is already available there. Two things to know before doing it: it changes search results for those projects, not just their file tree diff, and it re-hashes every page of each affected project once — their next PR preview reports every file as modified until the base version is built again.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ImprovementMinor improvement to code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions