Skip to content

Commit 7a2a18b

Browse files
authored
Add a Sphinx role to link to GitHub labels (#932)
* Add a Sphinx role to link to GitHub labels * Link to https://github.com/python/cpython/labels/{LABEL-NAME} * Add a working example for 'needs backport to X.Y'
1 parent 2a09dac commit 7a2a18b

File tree

3 files changed

+67
-30
lines changed

3 files changed

+67
-30
lines changed

_extensions/custom_roles.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""Sphinx extension to add custom roles.
2+
3+
Based on https://protips.readthedocs.io/link-roles.html
4+
"""
5+
import urllib.parse
6+
7+
from docutils import nodes
8+
9+
10+
def setup(app):
11+
app.add_role(
12+
"gh-label",
13+
autolink("https://github.com/python/cpython/labels/%s"),
14+
)
15+
# Parallel safety:
16+
# https://www.sphinx-doc.org/en/master/extdev/index.html#extension-metadata
17+
return {"parallel_read_safe": True, "parallel_write_safe": True}
18+
19+
20+
def autolink(pattern):
21+
def role(name, rawtext, text, lineno, inliner, options={}, content=[]):
22+
if " " in text:
23+
url_text = urllib.parse.quote(f"{text}")
24+
else:
25+
url_text = text
26+
url = pattern % (url_text,)
27+
node = nodes.reference(rawtext, text, refuri=url, **options)
28+
return [node], []
29+
30+
return role

conf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
import os
2+
import sys
13
import time
24

5+
# Location of custom extensions.
6+
sys.path.insert(0, os.path.abspath(".") + "/_extensions")
7+
38
extensions = [
9+
'custom_roles',
410
'sphinx.ext.intersphinx',
511
'sphinx.ext.todo',
612
'sphinx_copybutton',

triage/labels.rst

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,35 @@ you going. For a full list, see `here <https://github.com/python/cpython/issues/
1313
General purpose labels
1414
======================
1515

16-
type-behavior
16+
:gh-label:`type-behavior`
1717
Used for issues/PRs that address unintentional behavior, but do not
1818
pose significant security concerns. Generally, bugfixes will be attached
1919
to a specific issue where the unintended behavior was first reported.
2020

21-
type-documentation
21+
:gh-label:`type-documentation`
2222
Used for issues/PRs that exclusively involve changes to
2323
the documentation. Documentation includes ``*.rst`` files, docstrings,
2424
and code comments.
2525

26-
type-enhancement
26+
:gh-label:`type-enhancement`
2727
Used for issues/PRs that provide additional functionality
2828
or capabilities beyond the existing specifications.
2929

30-
type-performance
30+
:gh-label:`type-performance`
3131
Used for issues/PRs that provide performance optimizations.
3232

33-
type-security
33+
:gh-label:`type-security`
3434
Used for issues/PRs that involve critical security issues. Less severe
3535
security concerns can instead use the type-bugfix label.
3636

37-
type-tests
37+
:gh-label:`type-tests`
3838
Used for issues/PRs that exclusively involve changes to the tests.
3939

40-
OS-Mac / OS-Windows
40+
:gh-label:`OS-Mac` / :gh-label:`OS-Windows`
4141
Used for issues/PRs involving changes which only have an effect upon
4242
a specific operating system.
4343

44-
spam
44+
:gh-label:`spam`
4545
Used for issues/PRs that don't include enough eggs or bacon.
4646

4747
Labels specific to issues
@@ -50,11 +50,11 @@ Labels specific to issues
5050
Priority
5151
--------
5252

53-
release-blocker
53+
:gh-label:`release-blocker`
5454
The highest priority of an issue. If unaddressed, will cause the
5555
release manager to hold releasing a new version of Python.
5656

57-
deferred-blocker
57+
:gh-label:`deferred-blocker`
5858
A release blocker that was pushed one or more releases into the
5959
future. Possibly a temporary workaround was employed, or the version
6060
of Python the issue is affecting is still in alpha or beta stages
@@ -63,54 +63,55 @@ deferred-blocker
6363
Component
6464
---------
6565

66-
library
66+
:gh-label:`library`
6767
Used for issues involving Python modules in the ``Lib/`` dir.
6868

69-
docs
69+
:gh-label:`docs`
7070
Used for issues involving documentation in the ``Doc/`` dir.
7171

72-
interpreter-core
72+
:gh-label:`interpreter-core`
7373
Used for issues in interpreter core (``Objects/``, ``Python/``,
7474
``Grammar/``, and ``Parser/`` dirs).
7575

76-
extension-modules
76+
:gh-label:`extension-modules`
7777
Used for issues involving C modules in the ``Modules/`` dir.
7878

79-
tests
79+
:gh-label:`tests`
8080
Used for issues involving only Python's regression test suite, i.e.
8181
files in the ``Lib/test/`` dir.
8282

8383
Other
8484
-----
8585

86-
new
86+
:gh-label:`new`
8787
Denotes that the issue hasn't been looked at by triagers or core
8888
developers yet.
8989

90-
easy
90+
:gh-label:`easy`
9191
Denotes that the issue is a good candidate for a newcomer to address.
9292

9393

9494
Labels specific to PRs
9595
======================
9696

97-
DO-NOT-MERGE
97+
:gh-label:`DO-NOT-MERGE`
9898
Used on PRs to prevent miss-islington from being able
9999
to automatically merge the pull request. This label is appropriate when a PR
100100
has a non-trivial conflict with the branch it is being merged into.
101101

102-
expert-asyncio
102+
:gh-label:`expert-asyncio`
103103
Used for PRs which involve changes to the asyncio module
104104
or other asynchronous frameworks that utilize it.
105105

106-
invalid
106+
:gh-label:`invalid`
107107
Used manually for PRs that do not meet basic requirements and
108108
automatically added by bedevere when PR authors attempt to merge maintenance
109109
branches into the main branch. During events such as the October
110110
Hacktoberfest, this label will prevent the PR from counting toward the
111111
author's contributions.
112112

113113
needs backport to X.Y
114+
For example, :gh-label:`needs backport to 3.11`.
114115
Used for PRs which are appropriate to backport to
115116
branches prior to main. Generally, backports to the maintenance branches
116117
are primarily bugfixes and documentation clarifications. Backports to the
@@ -119,53 +120,53 @@ needs backport to X.Y
119120
miss-islington to attempt to automatically merge the PR into the branches
120121
specified.
121122

122-
skip issue
123+
:gh-label:`skip issue`
123124
Used for PRs which involve trivial changes, such as typo fixes,
124125
comment changes, and section rephrases. The majority of PRs require
125126
an issue to be attached to, but if there are no code changes and the
126127
section being modified retains the same meaning, this label might be
127128
appropriate.
128129

129-
skip news
130+
:gh-label:`skip news`
130131
Similar to the skip issue label, this label is used for PRs which
131132
involve trivial changes, backports, or already have a relevant news entry
132133
in another PR. Any potentially impactful changes should have a
133134
corresponding news entry, but for trivial changes it's commonly at the
134135
discretion of the PR author if they wish to opt-out of making one.
135136

136-
sprint
137+
:gh-label:`sprint`
137138
Used for PRs authored during an in-person sprint, such as
138139
at PyCon, EuroPython, or other official Python events. The label is
139140
used to prioritize the review of those PRs during the sprint.
140141

141-
stale
142+
:gh-label:`stale`
142143
Used for PRs that include changes which are no longer relevant, or when the
143144
author hasn't responded to feedback in a long period of time, or when the
144145
reviewer is unresponsive. This label helps core developers quickly identify
145146
PRs that are candidates for closure or require a ping to the author or
146147
reviewer.
147148

148-
awaiting review
149+
:gh-label:`awaiting review`
149150
Used for PRs that haven't been reviewed by anyone yet.
150151

151-
awaiting core review
152+
:gh-label:`awaiting core review`
152153
Used when the PR is authored by a core developer or when a non-core
153154
developer has reviewed the PR, even if they requested changes.
154155
Note that reviewers could have been added manually by a triager or core
155156
developer, or included automatically through use of the `CODEOWNERS
156157
<https://github.com/python/cpython/blob/main/.github/CODEOWNERS>`_
157158
file.
158159

159-
awaiting changes
160+
:gh-label:`awaiting changes`
160161
A reviewer required changes to proceed with the PR.
161162

162-
awaiting change review
163+
:gh-label:`awaiting change review`
163164
The PR author made requested changes, and they are waiting for review.
164165

165-
awaiting merge
166+
:gh-label:`awaiting merge`
166167
The PR has been approved by a core developer and is ready to merge.
167168

168-
test-with-buildbots
169+
:gh-label:`test-with-buildbots`
169170
Used on PRs to test the latest commit with the buildbot fleet. Generally for
170171
PRs with large code changes requiring more testing before merging. This
171172
may take multiple hours to complete. Triagers can also stop a stuck build

0 commit comments

Comments
 (0)