twisted / pydoctor

This is pydoctor, an API documentation generator that works by static analysis.
https://pydoctor.readthedocs.io
Other
181 stars 49 forks source link

Search bar doesn't always yield the expected results #648

Closed tristanlatr closed 1 year ago

tristanlatr commented 1 year ago

When searching for "ensure parsed docstring", I was expecting to see the pydoctor.epydoc2stan.ensure_parsed_docstring() function show up, but it doesn't:

by default 2022-09-08 at 1 29 50 PM

Maybe we can workaround the issue by adding wildcard at the end of the search query if the result did not yield any results, but it would be an uncommon behaviour. I'm unsure of the root cause if the issue, the lunr index building / searching seem quite complicated and might be the issue here. Because I've tried to make sure the object are also indexed by their split names as well, such that thins kind of query works. But it doesn't always.

ntamas commented 1 year ago

We have been running into this issue over there with python-igraph as well - see this issue and this comment in particular. The problem is that Lunr uses some kind of a similarity threshold, and for long keywords you need to enter quite a few characters from the keyword to get above the similarity threshold between the query and the keyword.

I am all in favour of adding the behaviour that you proposed above, or a simpler variant of it: when the search query contains no spaces and no asterisks, add an asterisk to the end and pass that to Lunr. In all other cases we assume that the user knows the Lunr syntax and wants the search string to be passed down to the Lunr engine exactly. You may even make this behaviour opt-in in a configuration file in order not to break behaviour for existing sites and we will happily opt in into this.