Skip to main content

A Sphinx extension for linking to your project's issue tracker

Project description

pypi badge github actions status Code style: Black

A Sphinx extension for linking to your project’s issue tracker. Includes roles for linking to issues, pull requests, user profiles, with built-in support for GitHub (though this works with other services).

Example

For an example usage, check out marshmallow’s changelog, which makes use of the roles in this library.

Installation and Configuration

pip install sphinx-issues

Add sphinx_issues to extensions in your conf.py.

The extension has default values for GitHub projects. Simply set the add the issues_default_group_project config variable and you are good to go:

# docs/conf.py

# ...
extensions = [
    # ...
    "sphinx_issues"
]

# Path to GitHub repo {group}/{project}  (note that `group` is the GitHub user or organization)
issues_github_path = "sloria/marshmallow"

# which is the equivalent to:
issues_uri = "https://github.com/{group}/{project}/issues/{issue}"
issues_prefix = "#"
issues_pr_uri = "https://github.com/{group}/{project}/pull/{pr}"
issues_pr_prefix = "#"
issues_commit_uri = "https://github.com/{group}/{project}/commit/{commit}"
issues_commit_prefix = "@"
issues_user_uri = "https://github.com/{user}"
issues_user_prefix = "@"

The extension is very configurable and can be used with any kind of issue tracker. Here is how you could configure it for use with a custom hosed GitLab instance:

# docs/conf.py

# ...
extensions = [
    # ...
    "sphinx_issues"
]

#  Default repo {group}/{project} of gitlab project
issues_default_group_project = "myteam/super_great_project"
issues_uri = "https://gitlab.company.com/{group}/{project}/-/issues/{issue}"
issues_prefix = "#"
issues_pr_uri = "https://gitlab.company.com/{group}/{project}/-/merge_requests/{pr}"
issues_pr_prefix = "!"
issues_commit_uri = "https://gitlab.company.com/{group}/{project}/-/commit/{commit}"
issues_commit_prefix = "@"
issues_user_uri = "https://gitlab.company.com/{user}"
issues_user_prefix = "@"

Usage inside the documentation

Use the :issue: and :pr: roles in your docs like so:

See issue :issue:`42`

See issues :issue:`12,13`

See :issue:`sloria/konch#45`.

See PR :pr:`58`

Use the :user: role in your docs to link to user profiles (GitHub by default, but can be configured via the issues_user_uri config variable).

Use the :commit: role to link to commits.

Fixed in :commit:`6bb9124d5e9dbb2f7b52864c3d8af7feb1b69403`.

Use the :cve: role to link to CVEs on https://cve.mitre.org.

:cve:`CVE-2018-17175` - Addresses possible vulnerability when...
Thanks to :user:`bitprophet` for the idea!

You can also use explicit names if you want to use a different name than the github user name:

This change is due to :user:`Andreas Mueller <amueller>`.

The syntax :role:`My custom title <target>` works for all roles of this extension.

It can be also used in combination with a list:

Fix bad bug :issue:`123, (Duplicate) <199>`

Use the :cwe: role to link to CWEs on https://cwe.mitre.org.

:cwe:`CWE-787` - The software writes data past the end, or...

Credits

Credit goes to Jeff Forcier for his work on the releases extension, which is a full-featured solution for generating changelogs. I just needed a quick way to reference GitHub issues in my docs, so I yoinked the bits that I needed.

License

MIT licensed. See the bundled LICENSE file for more details.

Changelog

3.0.1 (2022-01-11)

  • Fix regression from 3.0.0: exception: ‘in <string>’ requires string as left operand, not type.

3.0.0 (2022-01-10)

  • The :commit: role now outputs with an @ prefix.

  • Add configuration options for changing prefixes.

  • Allow {group} to be specified within issues_uri, issues_pr_uri, issues_commit_uri, and

2.0.0 (2022-01-01)

  • Drop support for Python 2.7 and 3.5.

  • Test against Python 3.8 to 3.10.

  • Add :cwe: role for linking to CVEs on https://cwe.mitre.org. Thanks @hugovk for the PR.

  • Add support for custom urls and separators Issue #93

  • Allow custom titles for all roles Issue #116

  • Added setting issues_default_group_project as future replacement of issues_github_path, to reflect the now to universal nature of the extension

1.2.0 (2018-12-26)

  • Add :commit: role for linking to commits.

  • Add support for linking to external repos.

  • Test against Python 3.7.

1.1.0 (2018-09-18)

1.0.0 (2018-07-14)

  • Add :pr: role. Thanks @jnotham for the suggestion.

  • Drop support for Python 3.4.

0.4.0 (2017-11-25)

  • Raise ValueError if neither issues_uri nor issues_github_path is set. Thanks @jnothman for the PR.

  • Drop support for Python 2.6 and 3.3.

0.3.1 (2017-01-16)

  • setup returns metadata, preventing warnings about parallel reads and writes. Thanks @jfinkels for reporting.

0.3.0 (2016-10-20)

  • Support anchor text for :user: role. Thanks @jnothman for the suggestion and thanks @amueller for the PR.

0.2.0 (2014-12-22)

  • Add :user: role for linking to GitHub user profiles.

0.1.0 (2014-12-21)

  • Initial release.

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-issues-3.0.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sphinx_issues-3.0.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file sphinx-issues-3.0.1.tar.gz.

File metadata

  • Download URL: sphinx-issues-3.0.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.0

File hashes

Hashes for sphinx-issues-3.0.1.tar.gz
Algorithm Hash digest
SHA256 b7c1dc1f4808563c454d11c1112796f8c176cdecfee95f0fd2302ef98e21e3d6
MD5 e2351ac5790c84b8fe9f13da294f69f1
BLAKE2b-256 0035a50591c1242d3f3927bcfd0e967c2858fef8fdb50f25b742015b6c841e03

See more details on using hashes here.

File details

Details for the file sphinx_issues-3.0.1-py3-none-any.whl.

File metadata

  • Download URL: sphinx_issues-3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.0

File hashes

Hashes for sphinx_issues-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8b25dc0301159375468f563b3699af7a63720fd84caf81c1442036fcd418b20c
MD5 f662bb2f4aa8b1b1e752732688dc8a87
BLAKE2b-256 ff9575ad650ed20237f3756d7fcd6ce2e7c7c65e833641a980e125f4d4687cc5

See more details on using hashes here.

Supported by

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