Skip to content

Commit

Permalink
Add a :user: role in Sphinx
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
webknjaz committed Sep 24, 2020
1 parent 1ea521c commit 455b3d3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/2395.doc.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added a ``:user:`` role to Sphinx config -- by :user:`webknjaz`
16 changes: 15 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,18 @@
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 --

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.
templates_path = ['_templates']
Expand All @@ -27,6 +36,11 @@
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# -- Options for extlinks extension ---------------------------------------
extlinks = {
'user': (f'{github_sponsors_url}/%s', '@'), # noqa: WPS323
}

# -- Options for HTML output --

# The theme to use for HTML and HTML Help pages. Major themes that come with
Expand Down

0 comments on commit 455b3d3

Please sign in to comment.