bskinn / sphobjinv

Toolkit for manipulation and inspection of Sphinx objects.inv files
https://sphobjinv.readthedocs.io
MIT License
81 stars 9 forks source link

Add printout of intersphinx_mapping entry for found-url #149

Closed bskinn closed 2 years ago

bskinn commented 3 years ago

~Trivial for standard docs layout

~Impossible to write a general algorithm to properly construct it for nonstandard docs layouts.

ALTHOUGH -- if a user has pasted a link to the actual docset as the input argument for suggest, then we can pretty strongly infer that that is a valid page in the docset. We can then search the uris in the inventory for one that matches the tail of the link passed in by the user. If the head of that link is the same as the location of the found objects.inv, then the ({objects_url}, None) syntax will work. If not, then the ({docs_base_url}, {objects_url}) syntax will be needed.

OTOH, we can't be sure that all input URLs will be pasted from a page in the docs, so a failure to match on this rubric doesn't mean that the root of the objects.inv URL isn't the correct docset root for the mapping...just that we can't be sure.

If the tail of the objects.inv URL is not /objects.inv, then we can be 100% sure that the mapping will not be (..., None), but instead (some_url, objectsinv_url). The only way to determine some_url is if the user also provides a URL to an object in the docset, and then we can extract the base from that using the Inventory objects, presuming one matches. This might mean that it would be best to expose that base-finding function as public...

Implement as helper function in the API, exploited by the CLI? (Yes. Standalone in a new module. DO NOT cross-implement as a method on Inventory, would lead to an import cycle.) Should just need objects_url and docs_link_url? (Yes, plus the retrieved Inventory.)


TODO: