Skip to content

Commit c56925a

Browse files
dalmiaraghavrv
authored andcommitted
[MRG + 1] DOC adding :user: role to whats_new (scikit-learn#7818)
* DOC adding :user: role to whats_new * DOC correcting the improper username * DOC adding exceptions for ImportError in sphinx_issues.py * DOC added import for split_explicit_title * DOC reverting to the old format for core devs * DOC reverting changes for more users * DOC removing extra lines and blank lines * DOC Adding missing link target for user * DOC fixing more links * DOC adding missing links for new contributions * DOC adding space before brackets in the user links * DOC reverting a wrong change * DOC adding final changes
1 parent 41e1b8f commit c56925a

File tree

2 files changed

+204
-339
lines changed

2 files changed

+204
-339
lines changed

doc/sphinxext/sphinx_issues.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
try:
2626
from docutils import nodes, utils
27+
from sphinx.util.nodes import split_explicit_title
2728
except ImportError:
2829
# Load lazily so that test-sphinxext does not require docutils dependency
2930
pass
@@ -45,13 +46,20 @@ def user_role(name, rawtext, text, lineno,
4546
"""
4647
options = options or {}
4748
content = content or []
48-
username = utils.unescape(text).strip()
49+
has_explicit_title, title, target = split_explicit_title(text)
50+
51+
target = utils.unescape(target).strip()
52+
title = utils.unescape(title).strip()
4953
config = inliner.document.settings.env.app.config
5054
if config.issues_user_uri:
51-
ref = config.issues_user_uri.format(user=username)
55+
ref = config.issues_user_uri.format(user=target)
56+
else:
57+
ref = 'https://github.com/{0}'.format(target)
58+
if has_explicit_title:
59+
text = title
5260
else:
53-
ref = 'https://github.com/{0}'.format(username)
54-
text = '@{0}'.format(username)
61+
text = '@{0}'.format(target)
62+
5563
link = nodes.reference(text=text, refuri=ref, **options)
5664
return [link], []
5765

0 commit comments

Comments
 (0)