Skip to content

HTML search results: identical summaries displayed for different link targets #11943

@jayaddison

Description

@jayaddison

Describe the bug

My understanding (that could be mistaken) about the html_show_search_summary feature (enabled by default) is that each search result displayed to the user should have a relevant snippet of the content displayed alongside, to aid the user's determination of which result(s) are most relevant.

When the feature is enabled, we make an HTTP request to each result and display a portion of that using JavaScript.

How to Reproduce

Build the Sphinx documentation locally and then run a basic webserver to host it:

sphinx.git $ sphinx-build -b html doc _build 
sphinx.git $ cd _build
sphinx.git $ python -m http.server -b 127.0.0.1

Open http://127.0.0.1:8000 in a web browser, and perform a search for the query term test.

Observe that multiple results with separate HTML anchor targets appear in the search results. However: they display the same search snippet (not useful - this is the bug).

image

Environment Information

Platform:              linux; (Linux-6.6.13-amd64-x86_64-with-glibc2.37)
Python version:        3.11.7 (main, Dec  8 2023, 14:22:46) [GCC 13.2.0])
Python implementation: CPython
Sphinx version:        7.2.6
Docutils version:      0.20.1
Jinja2 version:        3.1.3
Pygments version:      2.17.2

Sphinx extensions

No response

Additional context

Discovered during investigation of #11942.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions