searchindex.js contains rst_epilog matches for all pages in docs
#4,248 opened on 2017年11月17日
説明
Problem: rst_epilog values are returned for all pages when searched for.
My understanding is that the searchindex.js file is built from the doctrees cache. https://github.com/sphinx-doc/sphinx/blob/master/sphinx/search/__init__.py#L239
Each doctree file contains all of the rst_epilog values. As a result, these are included for every page when indexed, e.g. this is included in all doctrees files: .. |TEST1| replace:: TestWord
Reproduce:
- Add something like this to the
conf.pyand build
rst_epilog = '''
.. |TEST1| replace:: TestWord
.. |TEST2| replace:: TestWord2
'''
- Search the rebuilt docs for "testword"
- All pages in the doc set will be returned, and none will not actually contain "testword"
- if you take a look at
searchindex.jsyou will see therst_epilogvalues indexed for all pages, e.g.{testword2:[0,1,2],testword:[0,1,2]}
Env: Tested using Sphinx 1.5.5 and 1.6.5 & python 2.7.10
-
Using "stopwords" to filter out does not seem to be suitable here, because there are still valid returns for where these are values are legitimately substituted on pages. https://github.com/sphinx-doc/sphinx/blob/master/sphinx/search/en.py#L19
-
It would seem that if the
IndexBuilderor maybeWordCollectorignore sentences with.. replace::this search issue could be avoided, though that is just an idea and I am not sure if really appropriate: https://github.com/sphinx-doc/sphinx/blob/master/sphinx/search/__init__.py#L191 -
btw, this also works the same with
rst_prolog
Regards, Brian