On Tue, 09 Mar 2021 10:15:52 +0100 Drew Parsons <dpars...@debian.org> wrote:
> The local numpy docs at /usr/share/doc/python-numpy-doc/html/index.html
> provide a search window.  Search does work, but the result links are
> borken.
> 
> For instance, search for norm, finds 76 pages of results, the first
> being "numpy.linalg.norm (Python function, in numpy.linalg.norm)"
> The url link for this result is 
> file:///usr/share/doc/python-numpy-doc/html/reference/generated/numpy.linalg.normundefined?highlight=norm#numpy.linalg.norm
> 
> The "undefined" suffix at the end of the filepath of course means the
> link does not work. The actual file is
> file:///usr/share/doc/python-numpy-doc/html/reference/generated/numpy.linalg.norm.html
> 
> The tags on the search url do work if applied to the correct filepath, as in
> file:///usr/share/doc/python-numpy-doc/html/reference/generated/numpy.linalg.norm.html?highlight=norm
> 
> Something in the search engine is replacing '.html' with 'undefined'.

It is because the sphinx builder seems to do something wrong
when building the search.html file...

DIR=/usr/share/doc/python-numpy-doc/html

in $DIR/_static/searchtools.js line 268,
the script generates links using this:
```
linkUrl = item[0] + DOCUMENTATION_OPTIONS.LINK_SUFFIX;
```

The issue is that, somehow,
the `DOCUMENTATION_OPTIONS` is defined in $DIR/search.html,
and does not contain a `LINK_SUFFIX` parameter (-> undefined).

>From numpy doc website, they use this instead:
```
<script data-url_root="./" id="documentation_options" 
src="_static/documentation_options.js"></script>
```

Dirty workaround is to comment the definition of
`DOCUMENTATION_OPTIONS` in search.html and add this line,
or add `LINK_SUFFIX: '.html'` to its definition.

Sadly, I do not have any knowledge on Sphinx build to properly fix it.

Regards
-- 

Cédric Hannotier

Reply via email to