Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTM command #49

Open
circuitsacul opened this issue Sep 13, 2022 · 12 comments
Open

RTM command #49

circuitsacul opened this issue Sep 13, 2022 · 12 comments

Comments

@circuitsacul
Copy link
Member

circuitsacul commented Sep 13, 2022

It would be cool to have a slash command for searching sphinx documentation. All sphinx docs generate an object.inv file, which can be downloaded, parsed, and cached.

For example, the python docs: https://docs.python.org/3/
The objects.inv file is: https://docs.python.org/3/objects.inv

I found some great documentation on how to parse this https://sphobjinv.readthedocs.io/en/latest/syntax.html. Once parsed, it can be cached, and then we can probably use some sort of fuzzy search. The cached version of documentation can be set to expire after 24 hours.

For the slash command, I was thinking something like this:

/rtm query: <query> [docs-url: <docs-url="https://docs.python.org/3/">]

The docs-url can have autocomplete (and we can list more common projects), but will let you specify any valid sphinx url. If the url hasn't been used yet, it'll download/parse/cache it first.

@circuitsacul circuitsacul self-assigned this Sep 13, 2022
@Lunarmagpie
Copy link
Collaborator

This seems useful to me.
I'd like to integrate a fuzzy search algorithm for this (and for peps). I think thats the place to finally oxidize mcoding bot :trollface:

@circuitsacul
Copy link
Member Author

I think thats the place to finally oxidize mcoding bot :trollface:

I was thinking the same thing. rust-fuzzysearch time?

@Lunarmagpie
Copy link
Collaborator

LETS FUCKING GO
Fyi there are fuzzy search dependencies in c but I want to oxidize cause it's fun. Should be done in a way you don't need rustc to contribute though.
Also parsing rst isn't a bad place to use rust imo.

@circuitsacul
Copy link
Member Author

Also parsing rst isn't a bad place to use rust imo.

Where are we parsing rst?

@Lunarmagpie
Copy link
Collaborator

Lunarmagpie commented Sep 13, 2022

I thought we needed to to get doc information. (If we make a RTFM command in this issue)

@circuitsacul
Copy link
Member Author

circuitsacul commented Sep 13, 2022

Sphinx parses the docstrings and creates an objects.inv file. That's what I need to parse. I suppose it could be written in rust, but I'm going to figure it out in python first and then we can RIR if we want.

Fyi there are fuzzy search dependencies in c but I want to oxidize cause it's fun.

Sounds good to me, as long as mCodingBot can use the library without doing anything with rustc.

@circuitsacul
Copy link
Member Author

@circuitsacul circuitsacul removed their assignment Nov 17, 2022
@Enderchief
Copy link
Member

assign this to me
:ball:

@trag1c trag1c assigned trag1c and Enderchief and unassigned trag1c Dec 6, 2022
@Enderchief
Copy link
Member

unassign this to me
not ball

@bskinn
Copy link

bskinn commented Aug 25, 2023

Author of sphobjinv here. Glad you found the explainer on the objects.inv syntax useful!

Depending on exactly what you need to do, sphobjinv includes fuzzy-search capabilities that might be enough for you. In the current v2.3.1 it uses a vendored copy of [fuzzywuzzy].

Check out the Inventory.suggest() method -- it won't be nearly as fast as it would be in Rust (though I hopefully will have time to explore increasing performance before too long...), but it's already implemented.

@circuitsacul
Copy link
Member Author

circuitsacul commented Aug 25, 2023

@bskinn we already have a utility for fuzzy searching that uses RapidFuzz. I think it's good enough, but I don't know how it compares to what you're suggesting.

Edit: code is here: https://github.com/mcb-dev/mCodingBot/blob/main/mcodingbot/utils/search.py

@bskinn
Copy link

bskinn commented Aug 25, 2023

That's probably already better than what sphobjinv would offer, then. 👍 At this point I would only recommend sphobjinv as a quick path from nothing to something.

I have a grand plan to implement a plugin system for sphobjinv someday (bskinn/sphobjinv#207), which would allow wiring in custom scorers for suggest. That's likely a long way off, though... and would be overkill if the default fuzz scoring works fine for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants