Skip to main content

Sphinx objects.inv Inspection/Manipulation Tool

Project description

Current Development Version:

https://travis-ci.org/bskinn/sphobjinv.svg?branch=dev https://codecov.io/gh/bskinn/sphobjinv/branch/dev/graph/badge.svg

Most Recent Stable Release:

https://img.shields.io/pypi/v/sphobjinv.svg https://img.shields.io/pypi/pyversions/sphobjinv.svg

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:attribute:`sphobjinv.data.SuperDataObj.as_rst`             60
:py:function:`sphobjinv.cmdline.getparser`                     50
:py:attribute:`sphobjinv.data.DataObjBytes.as_str`             50
:py:attribute:`sphobjinv.data.DataObjStr.as_str`               50
:py:attribute:`sphobjinv.data.SuperDataObj.as_str`             50
:py:attribute:`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 redirect() function from Flask (see here):

$ sphobjinv suggest http://flask.pocoo.org/docs/1.0/views/#method-hints redirect -su

No inventory at provided URL.
Attempting "http://flask.pocoo.org/docs/1.0/views/objects.inv" ...
Attempting "http://flask.pocoo.org/docs/1.0/objects.inv" ...
Remote inventory found.

  Name                            Score
-------------------------------  -------
:py:function:`flask.redirect`      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, 195 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-2019

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.1rc1.tar.gz (28.0 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: sphobjinv-2.0.1rc1.tar.gz
  • Upload date:
  • Size: 28.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.3

File hashes

Hashes for sphobjinv-2.0.1rc1.tar.gz
Algorithm Hash digest
SHA256 78402d7f16d4c55c4250c5d4c89688f2c448054bc7863f9714e24024a24889dd
MD5 3a4ef3306c86155872e8ff05c1f622fa
BLAKE2b-256 3ed9f9847a9c60743656c2c5cad8fe42cd02567c9ac9b952675a3a340c00516e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sphobjinv-2.0.1rc1-py3-none-any.whl
  • Upload date:
  • Size: 29.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.3

File hashes

Hashes for sphobjinv-2.0.1rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 28d2a20a4e50bf8d636002229eb6e2790d24ff6a6079d7bf7368cefd2bff0c4d
MD5 8f7f748099fec7c49c254fbe09ba7fb5
BLAKE2b-256 5264654df0ae3595a86636982ab2c6c82e46a712fa9a29f700e7e5733d6dfde4

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