2021-06-08 20:37:55 -04:00
|
|
|
from sphinx import roles
|
|
|
|
|
|
|
|
|
|
|
|
class PEPRole(roles.PEP):
|
|
|
|
"""Override the :pep: role"""
|
2022-01-09 13:07:03 -05:00
|
|
|
# TODO override the entire thing (internal should be True)
|
2021-06-08 20:37:55 -04:00
|
|
|
|
|
|
|
def build_uri(self) -> str:
|
|
|
|
"""Get PEP URI from role text."""
|
2021-06-30 15:19:44 -04:00
|
|
|
pep_str, _, fragment = self.target.partition("#")
|
2022-01-09 13:07:03 -05:00
|
|
|
pep_base = self.inliner.document.settings.pep_url.format(int(pep_str))
|
2021-06-08 20:37:55 -04:00
|
|
|
if fragment:
|
|
|
|
return f"{pep_base}#{fragment}"
|
|
|
|
return pep_base
|