pdoc icon indicating copy to clipboard operation
pdoc copied to clipboard

Improve handling of camelCase and snake_case when searching documentation

Open MaddyGuthridge opened this issue 3 years ago • 2 comments

Problem Description

When I am searching for the documentation for a function, say fooBarFunction(), I will often type foo bar function into the search box in order to save time. When I do this, the function will often be significantly lower in the results list, even if what I have typed is an exact match (excluding the way words are split).

Proposal

Searching for a function using multiple words should prioritise functions with that exact name, even if the function uses a different capitalisation convention to the search query.

Additional context

The correct result is 7th in the list image

If I have time, I'll be happy to work on a PR for this.

MaddyGuthridge avatar Jul 11 '22 10:07 MaddyGuthridge

I'll say I'm a big snake_case fan, but I'm happy to merge a PR for this if it's straightforward to implement. :)

mhils avatar Jul 11 '22 17:07 mhils

Hi, we had the exact same issue with pydoctor (for search indexing and also for better line wrapping).

We ended-up indexing the splited the name as well.

Here's the code that splits camelCase or snake_case name identifiers: https://github.com/twisted/pydoctor/blob/0f2c5caee2f3b41ccc2943181086af5e00c0309d/pydoctor/epydoc2stan.py#L841

Tests can be found here: https://github.com/twisted/pydoctor/blob/0f2c5caee2f3b41ccc2943181086af5e00c0309d/pydoctor/test/test_epydoc2stan.py#L1508-L1544

Fell free to use this ;-)

tristanlatr avatar Jul 30 '22 18:07 tristanlatr