Link to source code and validate references in documentation
Project description
Sphinx Gitref
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
- Hashes code and alerts when something has changed
- Link to source code on github
- Incorporate into tests or git hooks
Supports Python 3.7+
Quickstart
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.
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`.
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::
sphinxg-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
Built Distribution
File details
Details for the file sphinx_gitref-0.4.0.tar.gz
.
File metadata
- Download URL: sphinx_gitref-0.4.0.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6b73a39dc4499f364e19b9b62832965c86961291f599074df2de79fac3fddb7 |
|
MD5 | 300e98a3921fafd9eed43f78d465641c |
|
BLAKE2b-256 | a558d9e21b565daa542e39d8f3902c384c5367e46d8997295b19bf15bce3b113 |
Provenance
File details
Details for the file sphinx_gitref-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: sphinx_gitref-0.4.0-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f7057acb7bc012910889a9be428014263a5c95dacd1aa55e63f1c0e52fa4c76 |
|
MD5 | e546e1bd7178594eeba32dfc8eab7e17 |
|
BLAKE2b-256 | 2ed070b31cdcca5355d1c8581cd33e5ea12a5849a5e0eae25cb8aff5c8eb7d53 |