-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Clang][Docs] Simpler syntax for Github links.
Github links in release notes are often invalid rST, clutter the release notes and are annoying to write. This introduces a sphynx plugin that rewrites `#GH<NUMBER>` to a link to the corresponding issue. While this could be introduced globally on all of LLVM, the PR only modifies Clang for now.
- Loading branch information
Showing
3 changed files
with
52 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from sphinx.application import Sphinx | ||
import re | ||
|
||
__version__ = "1.0" | ||
|
||
|
||
def subst_gh_links(app: Sphinx, docname, source): | ||
regex = re.compile("#GH([0-9]+)") | ||
out_pattern = r"`#\1 <https://github.com/llvm/llvm-project/issues/\1>`_" | ||
result = source[0] | ||
result = regex.sub(out_pattern, result) | ||
source[0] = result | ||
|
||
|
||
def setup(app: Sphinx): | ||
app.connect("source-read", subst_gh_links) | ||
return dict(version=__version__, parallel_read_safe=True, parallel_write_safe=True) |