Slide 20
Slide 20 text
from docutils import nodes, utils
from docutils.parsers.rst.roles import set_classes
def bbissue_role(name, rawtext, text, lineno, inliner, options={},
content=[]):
"Link to a BitBucket issue."
try:
issue_num = int(text)
if issue_num <= 0:
raise ValueError
except ValueError:
msg = inliner.reporter.error(
'"%s" is an invalid bug id.' % text,
line=lineno)
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
app = inliner.document.settings.env.app
node = make_link_node(rawtext, app, 'issue',
text, options)
return [node], []
def make_link_node(rawtext, app, type, slug, options):
"Create a link to a BitBucket resource."
try:
base = app.config.bitbucket_project_url
if not base:
Saturday, March 16, 13