peps icon indicating copy to clipboard operation
peps copied to clipboard

Infra: Add search to the PEP index

Open nineteendo opened this issue 1 year ago • 5 comments

I currently search like this: https://github.com/search?q=repo%3Apython%2Fpeps+lang%3AreStructuredText&type=code It would be easier if the was a search box on https://peps.python.org.

nineteendo avatar Oct 27 '24 06:10 nineteendo

Agreed that it would be useful, it's something I often miss.

hugovk avatar Oct 27 '24 09:10 hugovk

Nice idea @nineteendo.

willingc avatar Oct 31 '24 01:10 willingc

I spent some time looking into this today, and here's what I've found so far:

sphinx search was intentionally disabled in https://github.com/python/peps/pull/1934#discussion_r626879295 , recommending folks use public search engines with site-scoping. While that's not a bad solution, it's not advertised anywhere user-facing, and implementing a search box on the site that would use a public (maybe even popular) search engine may be counter to some folks' desires to keep their searches private, and I'd hate to drag people into a weird search.

I tried reenabling sphinx search, and it's not too bad of a change, but since the general approach sphinx "wants" is to have a theme that extends an existing one (like basic) to inject the right JS snippets, so in order to make this work we'd need to either vendor the JS or figure our a smart JS loader from the pre-packed code - I couldn't figure that out yet.

Largely, it comes from here: https://github.com/python/peps/blob/1fb889bc72f1b935d8c3c9600abea904dd80d3ba/pep_sphinx_extensions/pep_processor/html/pep_html_builder.py#L9-L23

I'd be happy to continue to poke at this if there's continued interest in having a PEP web search, and don't want to invest the effort if it's not going to pass a review ;)

miketheman avatar Jan 30 '25 22:01 miketheman

Indeed, disabling search was intentional, both to improve performance and as Sphinx's search isn't that great, so readers are better served by using their favourite search engine (there are many discussions about this on Sphinx's side, notably https://github.com/orgs/sphinx-doc/discussions/12419, but the précis is that improving search is costly and will take a not insignificant amount of effort to do right).

A

AA-Turner avatar Jan 30 '25 22:01 AA-Turner

Thanks @AA-Turner - kinda makes sense.

I took another approach for this - using pagefind - and it seems to be a workable idea - check it out! https://github.com/python/peps/pull/4247

miketheman avatar Jan 31 '25 14:01 miketheman