Skip to main content

Keep your sphinx docs in sync with your code.

Project description

Sphinx Gitref

PyPI Documentation Tests Coverage

Keep your sphinx docs in sync with your code.

Adds a :gitref:`..` role to Sphinx to link to your code on GitHub, GitLab or Bitbucket, and to make sure the references in your docs match the code.

Key features:

  • Check code referenced in documentation still exists
  • Check code hashes and alert when something has changed
  • Link to source code on github
  • Incorporate into tests or git hooks

Supports Python 3.7+

Quickstart

Installation

Install:

pip install sphinx-gitref

In your Sphinx conf.py, add sphinx_gitref to the extensions list:

extensions = [
    ...
    'sphinx_gitref',
]

See Configuration for options to customise gitref's defaults.

In reStructuredText

You can then use the :gitref:`..` role to link to a file on GitHub, GitLab, Bitbucket, or your own remote git service:

This file is :gitref:`README.rst`
For more information, see the :gitref:`project README <README.rst>`

or link to a variable, function or class in a python file::

The method which turns a reference into a line number
is :gitref:`sphinx_python/parse.py::python_to_lineno` -
this will raise a warning if the reference is not found.

Reference class attributes as you would in Python, such
as :gitref:`sphinx_python/git.py::Repo.path`.

Code hash checks

If the file, line number or code reference is not in your code, or if they code's hash does not match the hash in the database, your docs will fail to build.

You can check your references are up-to-date with::

sphinx-gitref check

When adding new references, or when referenced code has changed, you can update the hash database with::

sphinx-gitref update

See the documentation for more detailed usage instructions and options.

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

sphinx_gitref-0.4.1.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

sphinx_gitref-0.4.1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file sphinx_gitref-0.4.1.tar.gz.

File metadata

  • Download URL: sphinx_gitref-0.4.1.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.4

File hashes

Hashes for sphinx_gitref-0.4.1.tar.gz
Algorithm Hash digest
SHA256 7ec15a83265eda1a8ed7174a7fc5efd76ee18132bb9fbd0b60e1fd4fd416b268
MD5 dc7480f83f56fcb05726570ed7fd5199
BLAKE2b-256 92f48dbb1e46b2ecd8d49f8e2369fdc17a186961251aeff202bd737e47ddb716

See more details on using hashes here.

File details

Details for the file sphinx_gitref-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_gitref-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b64f61dbade370f16703639528e08006b0cf946805960ca5ad14386b3c616489
MD5 a5228dcfae29105b1816c75615b07afa
BLAKE2b-256 934a11aa6b31f47cfdbf4e11b91ae2981cee8717b68c81f240d7f75e8948aee4

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