Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sphinx - docutils #1931

Merged
merged 15 commits into from
Jun 9, 2021
Prev Previous commit
Next Next commit
Add PEPRole rst role
AA-Turner committed Jun 8, 2021

Unverified

This user has not yet uploaded their public signing key.
commit 61a1bf7e1d23b6a14fbf12b27b01577978d1edf9
16 changes: 16 additions & 0 deletions pep_sphinx_extensions/pep_processor/parsing/pep_role.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from sphinx import roles

from pep_sphinx_extensions.config import pep_url


class PEPRole(roles.PEP):
"""Override the :pep: role"""

def build_uri(self) -> str:
"""Get PEP URI from role text."""
base_url = self.inliner.document.settings.pep_base_url
pep_num, _, fragment = self.target.partition("#")
pep_base = base_url + pep_url.format(int(pep_num))
if fragment:
return f"{pep_base}#{fragment}"
return pep_base