Skip to main content

Sphinx objects.inv Inspection/Manipulation Tool

Project description

Current Development Version:

https://img.shields.io/travis/com/bskinn/sphobjinv?label=travis-ci&logo=travis https://codecov.io/gh/bskinn/sphobjinv/branch/master/graph/badge.svg

Most Recent Stable Release:

https://img.shields.io/pypi/v/sphobjinv.svg?logo=pypi https://img.shields.io/pypi/pyversions/sphobjinv.svg?logo=python

Info:

https://img.shields.io/readthedocs/sphobjinv/v2.0.svg https://img.shields.io/github/license/mashape/apistatus.svg https://img.shields.io/badge/code%20style-black-000000.svg

Using Sphinx?

Having trouble writing cross-references?

sphobjinv (short for ‘sphinx objects.inv’) can help!

The syntax required for a functional Sphinx cross-reference is highly non-obvious in many cases. Sometimes Sphinx can guess correctly what you mean, but it’s pretty hit-or-miss. The best approach is to provide Sphinx with a completely specified cross-reference, and that’s where sphobjinv comes in.

After a pip install sphobjinv, find the documentation set you want to cross-reference into, and pass it to sphobjinv suggest.

For internal cross-references, locate objects.inv within build/html:

$ sphobjinv suggest doc/build/html/objects.inv as_rst -st 50

  Name                                                     Score
--------------------------------------------------------  -------
:py:method:`sphobjinv.data.SuperDataObj.as_rst`             60
:py:function:`sphobjinv.cmdline.getparser`                  50
:py:method:`sphobjinv.data.SuperDataObj.as_str`             50
:py:method:`sphobjinv.inventory.Inventory.objects_rst`      50

The -s argument in the above shell command indicates to print the fuzzywuzzy match score along with each search result, and -t 50 changes the reporting threshold for the match score.

For external references, just find the documentation wherever it lives on the web, and pass sphobjinv suggest a URL from within the documentation set with the --url/-u flag. For example, say I need to know how to cross-reference the Axis class from matplotlib (see here):

$ sphobjinv suggest https://matplotlib.org/api/ticker_api.html axis -su

No inventory at provided URL.
Attempting "https://matplotlib.org/api/ticker_api.html/objects.inv" ...
Attempting "https://matplotlib.org/api/objects.inv" ...
Attempting "https://matplotlib.org/objects.inv" ...
Remote inventory found.


  Name                           Score
------------------------------  -------
:py:module:`matplotlib.axis`      90
:std:doc:`api/axis_api`           90
:std:label:`axis-container`       90

NOTE that the results from sphobjinv suggest are printed using the longer block directives, whereas cross-references must be composed using the inline directives. Thus, the above redirect() function must be cross-referenced as :func:`flask.redirect`, not :function:`flask.redirect`.

Need to edit an inventory after it’s created, or compose one from scratch?

sphobjinv can help with that, too.

objects.inv files can be decompressed to plaintext at the commandline:

$ sphobjinv convert plain -o doc/build/html/objects.inv doc/scratch/
Conversion completed.
'...objects.inv' converted to '...objects.txt' (plain).

JSON output is supported (sphobjinv convert json ...), and inventories can be re-compressed to the partially-zlib-compressed form that intersphinx reads (sphobjinv convert zlib ...).

Alternatively, sphobjinv exposes an API to enable automation of inventory creation/modification:

>>> import sphobjinv as soi
>>> inv = soi.Inventory('doc/build/html/objects.inv')
>>> print(inv)
<Inventory (fname_zlib): sphobjinv v2.0, 181 objects>
>>> inv.project
'sphobjinv'
>>> inv.version
'2.0'
>>> inv.objects[0]
DataObjStr(name='sphobjinv.cmdline', domain='py', role='module', priority='0', uri='cli/implementation.html#module-$', dispname='-')

The API also enables straightforward re-export of an inventory, for subsequent use with intersphinx cross-references. See the docs for more details.


Full documentation is hosted at Read The Docs.

Available on PyPI (pip install sphobjinv).

Source on GitHub. Bug reports and feature requests are welcomed at the Issues page there.

Copyright (c) Brian Skinn 2016-2020

License: The MIT License. See LICENSE.txt for full license terms.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphobjinv-2.0.1.tar.gz (28.6 kB view details)

Uploaded Source

Built Distribution

sphobjinv-2.0.1-py3-none-any.whl (31.8 kB view details)

Uploaded Python 3

File details

Details for the file sphobjinv-2.0.1.tar.gz.

File metadata

  • Download URL: sphobjinv-2.0.1.tar.gz
  • Upload date:
  • Size: 28.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.6

File hashes

Hashes for sphobjinv-2.0.1.tar.gz
Algorithm Hash digest
SHA256 fde7fc6391bb7b8dd274e0af0bd254ef0043c9552294c8dcf08a24464a7dd488
MD5 40f0df974c466505a07422d5055030bc
BLAKE2b-256 cdf18526ef75134bca278e6081e976648749d61dc99e6ed42286544b198b1fca

See more details on using hashes here.

File details

Details for the file sphobjinv-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: sphobjinv-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 31.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.6

File hashes

Hashes for sphobjinv-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 57fcf0672882ce542ce4c6773416c804eeb31c99e5bb83599a12032bd053cad9
MD5 9960b583bc857af0e1af13aa544254ea
BLAKE2b-256 93c72348cb750c3d992fdce5a19046a7a25ca11ce64dd2ff9f9b8dc961ae4aee

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page