diff --git a/_extensions/custom_roles.py b/_extensions/custom_roles.py new file mode 100644 index 000000000..ceba4909e --- /dev/null +++ b/_extensions/custom_roles.py @@ -0,0 +1,30 @@ +"""Sphinx extension to add custom roles. + +Based on https://protips.readthedocs.io/link-roles.html +""" +import urllib.parse + +from docutils import nodes + + +def setup(app): + app.add_role( + "gh-label", + autolink("https://github.com/python/cpython/labels/%s"), + ) + # Parallel safety: + # https://www.sphinx-doc.org/en/master/extdev/index.html#extension-metadata + return {"parallel_read_safe": True, "parallel_write_safe": True} + + +def autolink(pattern): + def role(name, rawtext, text, lineno, inliner, options={}, content=[]): + if " " in text: + url_text = urllib.parse.quote(f"{text}") + else: + url_text = text + url = pattern % (url_text,) + node = nodes.reference(rawtext, text, refuri=url, **options) + return [node], [] + + return role diff --git a/conf.py b/conf.py index ba3b164a0..327615bdb 100644 --- a/conf.py +++ b/conf.py @@ -1,6 +1,12 @@ +import os +import sys import time +# Location of custom extensions. +sys.path.insert(0, os.path.abspath(".") + "/_extensions") + extensions = [ + 'custom_roles', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx_copybutton', diff --git a/triage/labels.rst b/triage/labels.rst index 78a5ac9b5..60f255641 100644 --- a/triage/labels.rst +++ b/triage/labels.rst @@ -13,35 +13,35 @@ you going. For a full list, see `here `_ file. -awaiting changes +:gh-label:`awaiting changes` A reviewer required changes to proceed with the PR. -awaiting change review +:gh-label:`awaiting change review` The PR author made requested changes, and they are waiting for review. -awaiting merge +:gh-label:`awaiting merge` The PR has been approved by a core developer and is ready to merge. -test-with-buildbots +:gh-label:`test-with-buildbots` Used on PRs to test the latest commit with the buildbot fleet. Generally for PRs with large code changes requiring more testing before merging. This may take multiple hours to complete. Triagers can also stop a stuck build