sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.46k stars 2.1k forks source link

Extend search across affiliated documentation sites #8152

Open mattip opened 4 years ago

mattip commented 4 years ago

PyTorch uses sphinx to build pytorch docs, torch audio docs, torch text docs, torch vision docs and a few more. It would be nice if search were aggregated across all the different separate sphinx doc sites.

I think the IndexBuilder could be fed the objects.inv intersphinx index from the other sites. The javascript would need to change a bit to accommodate a possibly different link base for the page.

One alternative would be to use search from something like Algolia, as proposed in this issue for numpy.

Any thoughts or hints? Could this be done as an extension so it could be adapted independently of Sphinx?

mattip commented 4 years ago

I see the generated searchindex.js file calls the setIndex function in searchtools.js. Could that be tweaked to become extendIndex, and we could set the page headers to load the searchindex.js of all the relevant affiliated sites.

mattip commented 4 years ago

I think I will try:

It works in a prototype with [this diff] (https://gist.github.com/mattip/75f97b4cbf639d892af47be49c468fe9) where I manually edit the relevant affiliated searchindex.js to (1) change the function name (2) add the rootUrl, and (3) add it to search.html. The only thing I haven't worked out yet is how to delay/redo the query to accomodate for network delays in loading the affiliate data, like delayQuery.

mattip commented 4 years ago

I am turning these ideas into a sphinx extension in mattip/sphinx-affiliates.