Skip to content

RTM command #49

Open
Open

Description

@circuitsacul

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.

Activity

  1. self-assigned this
    on Sep 13, 2022
  2. zunda-arrow commented on Sep 13, 2022

    @zunda-arrow
    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:

  3. circuitsacul commented on Sep 13, 2022

    @circuitsacul
    MemberAuthor

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

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

  4. zunda-arrow commented on Sep 13, 2022

    @zunda-arrow
    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.

  5. circuitsacul commented on Sep 13, 2022

    @circuitsacul
    MemberAuthor

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

    Where are we parsing rst?

  6. zunda-arrow commented on Sep 13, 2022

    @zunda-arrow
    Collaborator

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

  7. circuitsacul commented on Sep 13, 2022

    @circuitsacul
    MemberAuthor

    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.

  8. circuitsacul commented on Sep 13, 2022

    @circuitsacul
    MemberAuthor
  9. removed their assignment
    on Nov 17, 2022
  10. Enderchief commented on Dec 6, 2022

    @Enderchief
    Member

    assign this to me
    :ball:

  11. assigned and unassigned on Dec 6, 2022
  12. Enderchief commented on Dec 6, 2022

    @Enderchief
    Member

    unassign this to me
    not ball

  13. bskinn commented on Aug 25, 2023

    @bskinn

    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.

  14. circuitsacul commented on Aug 25, 2023

    @circuitsacul
    MemberAuthor

    @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

  15. bskinn commented on Aug 25, 2023

    @bskinn

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions