Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
content = []
nwarnings = 0
para = nodes.paragraph()
sorted_items = sorted(error_cache.items())
para += nodes.Text("There are {} warnings".format(len(sorted_items)))
content.append(para)
for key, value in sorted_items:
docname, lineno = key.split(":")
lineno = int(lineno)
cgatreportwarning, warningclass = value
para = nodes.paragraph()
filename = env.doc2path(docname, base=None)
nwarnings += 1
location_str = '%s:%d ' % (filename, lineno)
try:
description_str = warningclass
except KeyError:
description_str = "unknown"
# Create a reference
newnode = nodes.reference('', '')
innernode = nodes.emphasis(_(location_str), _(location_str))
newnode['refdocname'] = docname
def run(self):
pnode = nodes.compound(classes=['impl-detail'])
content = self.content
add_text = nodes.strong('CPython implementation detail:',
'CPython implementation detail:')
if self.arguments:
n, m = self.state.inline_text(self.arguments[0], self.lineno)
pnode.append(nodes.paragraph('', '', *(n + m)))
self.state.nested_parse(content, self.content_offset, pnode)
if pnode.children and isinstance(pnode[0], nodes.paragraph):
pnode[0].insert(0, add_text)
pnode[0].insert(1, nodes.Text(' '))
else:
pnode.insert(0, nodes.paragraph('', '', add_text))
return [pnode]
def run(self):
from docutils import nodes
node = nodes.paragraph()
node += addnodes.desc_name(self.arguments[0], self.arguments[0])
shape = self.options.get('shape')
if shape :
#node += nodes.Text(shape, shape)
add_shape(node, shape)
type = self.options.get('type')
attrs= self.options.get('attrs')
if type or attrs:
node += nodes.Text(' :: ', ' :: ')
if type: node += nodes.emphasis('', type)
if attr: node += nodes.literal('', '['+attr+']')
if self.content:
node += nodes.Text(': ', ': ')
argnodes, msgs = self.state.inline_text(' '.join(self.content), self.lineno)
node += argnodes
node += msgs
def make_footnote(doc, label, uri):
# type: (nodes.Node, unicode, unicode) -> nodes.footnote
"""Create a footnote node with children"""
footnote = nodes.footnote(uri)
para = nodes.paragraph()
para.append(nodes.Text(uri))
footnote.append(para)
footnote.insert(0, nodes.label('', label))
doc.note_autofootnote(footnote)
return footnote
def get_value_list(vals):
rv = nodes.paragraph()
if vals:
rv.append(nodes.literal(vals[0], vals[0]))
for i in range(1, len(vals)):
rv.append(text(" | "))
rv.append(nodes.literal(vals[i], vals[i]))
return rv
for node in doctree.traverse(TrackerLinks):
node.replace_self([])
return
env = app.builder.env
for node in doctree.traverse(TrackerLinks):
content = []
para = this = None
#XXX: the crossref stuff is a bit bogus, needs fixed
links = sorted(env.trackerlink_all_links,
key=operator.attrgetter('issue'))
for link in links:
if link.issue!=this:
if para: content.append(para)
this = link.issue
count = 1
para = docutils.nodes.paragraph()
#TODO: make this strikethrough or not styling.
para += docutils.nodes.reference(link.issue, link.issue,
refuri=link.ref)
titletext = ' %s: ' % link.title
if link.status=='2':
titletext += '(closed) '
para += docutils.nodes.Text(titletext, titletext)
if count>1:
para += docutils.nodes.Text(', ', ', ')
reftext = "%s %s" % (link.docname, link.lineno)
newnode = docutils.nodes.reference(reftext, reftext)
newnode['refdocname'] = link.docname
newnode['refuri'] = app.builder.get_relative_uri(
fromdocname, link.docname)
#XXX: refid is an unknown name, so far, so the links are bogus too
#newnode['refuri'] += '#' + link.target['refid']
for group in groups:
usages = []
for action in group['actions']:
option = self._get_option_group(fmt, action)[0]
if option.get('optional') and len(group['actions']) == 1:
group['required'] = False
usage = '\\ :option:`{}`\\ '.format(option['synopsis'])
usages.append(usage)
if not group['required']:
synopsis.append('[{}]'.format(' | '.join(usages)))
elif len(group['actions']) > 1:
synopsis.append('({})'.format(' | '.join(usages)))
else:
synopsis.append('{}'.format(usages[0]))
synopsis = self._format_synopsis(synopsis)
paragraph = nodes.paragraph()
self.state.nested_parse(StringList(synopsis), 0, paragraph)
return nodes.container('', paragraph)
def append_row(*column_texts):
row = nodes.row('')
for text in column_texts:
node = nodes.paragraph('')
vl = ViewList()
vl.append(text, '')
state.nested_parse(vl, 0, node)
row.append(nodes.entry('', node))
body.append(row)
def run(self):
tab_width = self.options.get('tab-width', self.state.document.settings.tab_width)
source = self.state_machine.input_lines.source(self.lineno - self.state_machine.input_offset - 1)
old_stdout, sys.stdout = sys.stdout, StringIO()
try:
exec '\n'.join(self.content)
text = sys.stdout.getvalue()
lines = string2lines(text, tab_width, convert_whitespace=True)
self.state_machine.insert_input(lines, source)
return []
except Exception as e:
errmsg = 'Unable to execute python code at {}:{}'.format(os.path.basename(source), self.lineno)
return [nodes.error(None, nodes.paragraph(text=errmsg), nodes.paragraph(text=str(e)))]
finally:
sys.stdout = old_stdout
def make_item_ref(app, env, fromdocname, item_info):
"""
Creates a reference node for an item, embedded in a
paragraph. Reference text adds also a caption if it exists.
"""
id = item_info['target']['refid']
if item_info['caption'] != '':
caption = ', ' + item_info['caption']
else:
caption = ''
para = nodes.paragraph()
newnode = nodes.reference('', '')
innernode = nodes.emphasis(id + caption, id + caption)
newnode['refdocname'] = item_info['docname']
try:
newnode['refuri'] = app.builder.get_relative_uri(fromdocname,
item_info['docname'])
newnode['refuri'] += '#' + id
except NoUri:
# ignore if no URI can be determined, e.g. for LaTeX output :(
pass
newnode.append(innernode)
para += newnode
return para