mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-91888: add a :gh:
role to the documentation (#91889)
* Add a new :gh:`...` role for GitHub issues. * Fix a GitHub id to use the :gh: role. * Add Misc/NEWS entry. * Refactoring and rephrasing. Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
This commit is contained in:
parent
4403320727
commit
f7641a2ffe
3 changed files with 26 additions and 1 deletions
|
@ -44,6 +44,7 @@ import suspicious
|
||||||
|
|
||||||
|
|
||||||
ISSUE_URI = 'https://bugs.python.org/issue?@action=redirect&bpo=%s'
|
ISSUE_URI = 'https://bugs.python.org/issue?@action=redirect&bpo=%s'
|
||||||
|
GH_ISSUE_URI = 'https://github.com/python/cpython/issues/%s'
|
||||||
SOURCE_URI = 'https://github.com/python/cpython/tree/main/%s'
|
SOURCE_URI = 'https://github.com/python/cpython/tree/main/%s'
|
||||||
|
|
||||||
# monkey-patch reST parser to disable alphabetic and roman enumerated lists
|
# monkey-patch reST parser to disable alphabetic and roman enumerated lists
|
||||||
|
@ -58,11 +59,33 @@ Body.enum.converters['loweralpha'] = \
|
||||||
|
|
||||||
def issue_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
|
def issue_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
|
||||||
issue = utils.unescape(text)
|
issue = utils.unescape(text)
|
||||||
|
# sanity check: there are no bpo issues within these two values
|
||||||
|
if 47261 < int(issue) < 400000:
|
||||||
|
msg = inliner.reporter.error(f'The BPO ID {text!r} seems too high -- '
|
||||||
|
'use :gh:`...` for GitHub IDs', line=lineno)
|
||||||
|
prb = inliner.problematic(rawtext, rawtext, msg)
|
||||||
|
return [prb], [msg]
|
||||||
text = 'bpo-' + issue
|
text = 'bpo-' + issue
|
||||||
refnode = nodes.reference(text, text, refuri=ISSUE_URI % issue)
|
refnode = nodes.reference(text, text, refuri=ISSUE_URI % issue)
|
||||||
return [refnode], []
|
return [refnode], []
|
||||||
|
|
||||||
|
|
||||||
|
# Support for marking up and linking to GitHub issues
|
||||||
|
|
||||||
|
def gh_issue_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
|
||||||
|
issue = utils.unescape(text)
|
||||||
|
# sanity check: all GitHub issues have ID >= 32426
|
||||||
|
# even though some of them are also valid BPO IDs
|
||||||
|
if int(issue) < 32426:
|
||||||
|
msg = inliner.reporter.error(f'The GitHub ID {text!r} seems too low -- '
|
||||||
|
'use :issue:`...` for BPO IDs', line=lineno)
|
||||||
|
prb = inliner.problematic(rawtext, rawtext, msg)
|
||||||
|
return [prb], [msg]
|
||||||
|
text = 'gh-' + issue
|
||||||
|
refnode = nodes.reference(text, text, refuri=GH_ISSUE_URI % issue)
|
||||||
|
return [refnode], []
|
||||||
|
|
||||||
|
|
||||||
# Support for linking to Python source files easily
|
# Support for linking to Python source files easily
|
||||||
|
|
||||||
def source_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
|
def source_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
|
||||||
|
@ -615,6 +638,7 @@ def process_audit_events(app, doctree, fromdocname):
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
app.add_role('issue', issue_role)
|
app.add_role('issue', issue_role)
|
||||||
|
app.add_role('gh', gh_issue_role)
|
||||||
app.add_role('source', source_role)
|
app.add_role('source', source_role)
|
||||||
app.add_directive('impl-detail', ImplementationDetail)
|
app.add_directive('impl-detail', ImplementationDetail)
|
||||||
app.add_directive('availability', Availability)
|
app.add_directive('availability', Availability)
|
||||||
|
|
|
@ -463,7 +463,7 @@ inspect
|
||||||
line number, column and end column). The affected functions are:
|
line number, column and end column). The affected functions are:
|
||||||
:func:`inspect.getframeinfo`, :func:`inspect.getouterframes`, :func:`inspect.getinnerframes`,
|
:func:`inspect.getframeinfo`, :func:`inspect.getouterframes`, :func:`inspect.getinnerframes`,
|
||||||
:func:`inspect.stack` and :func:`inspect.trace`. (Contributed by Pablo Galindo in
|
:func:`inspect.stack` and :func:`inspect.trace`. (Contributed by Pablo Galindo in
|
||||||
:issue:`88116`)
|
:gh:`88116`)
|
||||||
|
|
||||||
locale
|
locale
|
||||||
------
|
------
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Add a new `gh` role to the documentation to link to GitHub issues.
|
Loading…
Add table
Add a link
Reference in a new issue