MCPcopy Create free account
hub / github.com/ipython/traitlets / ghissue_role

Function ghissue_role

docs/sphinxext/github.py:57–100  ·  view source on GitHub ↗

Link to a GitHub issue. Returns 2 part tuple containing list of nodes to insert into the document and a list of system messages. Both are allowed to be empty. :param name: The role name used in the document. :param rawtext: The entire markup snippet, with role. :param text

(name, rawtext, text, lineno, inliner, options=None, content=None)

Source from the content-addressed store, hash-verified

55
56
57def ghissue_role(name, rawtext, text, lineno, inliner, options=None, content=None):
58 """Link to a GitHub issue.
59
60 Returns 2 part tuple containing list of nodes to insert into the
61 document and a list of system messages. Both are allowed to be
62 empty.
63
64 :param name: The role name used in the document.
65 :param rawtext: The entire markup snippet, with role.
66 :param text: The text marked with the role.
67 :param lineno: The line number where rawtext appears in the input.
68 :param inliner: The inliner instance that called us.
69 :param options: Directive options for customization.
70 :param content: The directive content for customization.
71 """
72 options = options or {}
73 content = content or []
74
75 try:
76 issue_num = int(text)
77 if issue_num <= 0:
78 raise ValueError
79 except ValueError:
80 msg = inliner.reporter.error(
81 "GitHub issue number must be a number greater than or equal to 1; "
82 '"%s" is invalid.' % text,
83 line=lineno,
84 )
85 prb = inliner.problematic(rawtext, rawtext, msg)
86 return [prb], [msg]
87 app = inliner.document.settings.env.app
88 # info('issue %r' % text)
89 if "pull" in name.lower():
90 category = "pull"
91 elif "issue" in name.lower():
92 category = "issues"
93 else:
94 msg = inliner.reporter.error(
95 'GitHub roles include "ghpull" and "ghissue", "%s" is invalid.' % name, line=lineno
96 )
97 prb = inliner.problematic(rawtext, rawtext, msg)
98 return [prb], [msg]
99 node = make_link_node(rawtext, app, category, str(issue_num), options)
100 return [node], []
101
102
103def ghuser_role(name, rawtext, text, lineno, inliner, options=None, content=None):

Callers

nothing calls this directly

Calls 2

make_link_nodeFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…