prototype a Sphinx search backend for the Python docs

docs.python.org has no search server: its search page downloads the
whole Sphinx index (searchindex.js, ~900KB gzipped) and ranks matches
in the browser. oc now does the same ranking itself, so 'oc py search'
answers from the site's own index instead of DuckDuckGo.

The index is cached on disk for a day and never printed; what renders
is a numbered result list that rides the normal open path, so 'do <n>'
follows a result. A query that names a symbol exactly (json.dumps)
links straight to its anchor. A site definition opts in with a
'sphinx' field naming the docs root, so any Sphinx site can use the
backend later.
This commit is contained in:
only-cli
2026-08-24 09:59:34 -04:00
parent 4ae8cffdd2
commit e834309363
8 changed files with 349 additions and 12 deletions
+1 -1
View File
@@ -3,6 +3,6 @@
"commands": {
"library": { "open": "https://docs.python.org/3/library/{module}.html", "args": ["module"] },
"doc": { "open": "https://docs.python.org/3/{path}.html", "args": ["path"] },
"search": { "open": "https://html.duckduckgo.com/html/?q=site%3Adocs.python.org+{query}", "args": ["query"] }
"search": { "sphinx": "https://docs.python.org/3/", "args": ["query"] }
}
}