Commit 455b3d3c authored by Sviatoslav Sydorenko's avatar Sviatoslav Sydorenko

Add a :user: role in Sphinx

This change adds a role that links to the GitHub user Sponsors
page. If that page is not set up, it'll redirect to the GitHub user
profile page instead:

Links to https://github.com/sponsors/{{ username }} open as GitHub
Sponsors page if the target `username` has it enabled and redirect
to https://github.com/{{ username }} if it's disabled.
parent 1ea521c5
Added a ``:user:`` role to Sphinx config -- by :user:`webknjaz`
...@@ -10,9 +10,18 @@ import os ...@@ -10,9 +10,18 @@ import os
cwd=os.path.join(os.path.dirname(__file__), os.path.pardir), cwd=os.path.join(os.path.dirname(__file__), os.path.pardir),
) )
# -- Project information -----------------------------------------------------
github_url = 'https://github.com'
github_sponsors_url = f'{github_url}/sponsors'
# -- General configuration -- # -- General configuration --
extensions = ['jaraco.packaging.sphinx', 'rst.linker'] extensions = [
'sphinx.ext.extlinks', # allows to create custom roles easily
'jaraco.packaging.sphinx',
'rst.linker',
]
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates'] templates_path = ['_templates']
...@@ -27,6 +36,11 @@ exclude_trees = [] ...@@ -27,6 +36,11 @@ exclude_trees = []
# The name of the Pygments (syntax highlighting) style to use. # The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx' pygments_style = 'sphinx'
# -- Options for extlinks extension ---------------------------------------
extlinks = {
'user': (f'{github_sponsors_url}/%s', '@'), # noqa: WPS323
}
# -- Options for HTML output -- # -- Options for HTML output --
# The theme to use for HTML and HTML Help pages. Major themes that come with # The theme to use for HTML and HTML Help pages. Major themes that come with
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment