Conversation
|
🚀 Preview deployment available at: https://dcca3028.rdoc-6cd.pages.dev (commit: b3dcacc) |
When searching for a class name like "String", the search should return exact matches first before returning classes that contain the search term in their name (like "Prism::StringNode"). This adds a new pass 0 to the search algorithm that only matches when the searchIndex exactly equals the query. The previous passes are shifted accordingly: - Pass 0: exact match (new) - Pass 1: searchIndex starts with query (was pass 0) - Pass 2: longSearchIndex starts with query (was pass 1) - Pass 3: searchIndex contains query (was pass 2) - Pass 4: regexp match (was pass 3) Fixes #1194
|
Another great improvement would be to order results by most common classes first. Consider https://docs.ruby-lang.org/en/master?q=empty%3F - The top 5 results are Array, Dir, ENV, File, and FileTest. Arguably, the most useful ordering would be String, Array, Hash, Set, and Symbol. But I imagine that rdoc doesn't have a way to weight certain classes over others. And then there would probably be some contested discussions around how things should be weighted., so this may never happen, but I wanted to throw the idea out there, just in case :-) |
Yeah the generated site is completely static and there's no way we can collect that info. We may get some insight if docs.ruby-lang.org collects some statistics. But we'd still have no ways to insert those weights without significantly changing RDoc as you said. |
|
@st0012 I have list of boosts that I use for Ruby API, I would be interested to see if this is something RDoc could use in its search. |
|
@colby-swandale Thanks that's definitely helpful! I don't think this should be baked in RDoc directly given that it's technically a static site generator for all Ruby projects. |
I know adding 2 new phases for exact matches feels like a workaround, but without a more thorough review on the entire searching algorithm this is the best solution I have.
I also added basic tests for
search.jsusingmini_racergem (dev dependency) to simulate JS evaluation. I chose this approach because it should be simpler than maintaining a whole set of JS dependencies and setups.Fixes #1194