def visit_list_item(self, node):
children = []
for child in node.children:
if not isinstance(child, nodes.Invisible):
children.append(child)
if (children and isinstance(children[0], nodes.paragraph)
and (isinstance(children[-1], nodes.bullet_list)
or isinstance(children[-1], nodes.enumerated_list))):
children.pop()
if len(children) <= 1:
return
else:
raise nodes.NodeFound
# def visit_bullet_list(self, node):
# pass
# def visit_enumerated_list(self, node):
# pass
# def visit_paragraph(self, node):
# raise nodes.SkipNode
python类bullet_list()的实例源码
def is_compactable(self, node):
# print "is_compactable %s ?" % node.__class__,
# explicite class arguments have precedence
if 'compact' in node['classes']:
return True
if 'open' in node['classes']:
return False
# check config setting:
if (isinstance(node, (nodes.field_list, nodes.definition_list))
and not self.settings.compact_field_lists):
# print "`compact-field-lists` is False"
return False
if (isinstance(node, (nodes.enumerated_list, nodes.bullet_list))
and not self.settings.compact_lists):
# print "`compact-lists` is False"
return False
# more special cases:
if (self.topic_classes == ['contents']): # TODO: self.in_contents
return True
# check the list items:
return self.check_simple_list(node)
def visit_list_item(self, node):
# print "visiting list item", node.__class__
children = [child for child in node.children
if not isinstance(child, nodes.Invisible)]
# print "has %s visible children" % len(children)
if (children and isinstance(children[0], nodes.paragraph)
and (isinstance(children[-1], nodes.bullet_list) or
isinstance(children[-1], nodes.enumerated_list) or
isinstance(children[-1], nodes.field_list))):
children.pop()
# print "%s children remain" % len(children)
if len(children) <= 1:
return
else:
# print "found", child.__class__, "in", node.__class__
raise nodes.NodeFound
def bullet(self, match, context, next_state):
"""Bullet list item."""
bulletlist = nodes.bullet_list()
(bulletlist.source,
bulletlist.line) = self.state_machine.get_source_and_line()
self.parent += bulletlist
bulletlist['bullet'] = match.string[0]
i, blank_finish = self.list_item(match.end())
bulletlist += i
offset = self.state_machine.line_offset + 1 # next line
new_line_offset, blank_finish = self.nested_list_parse(
self.state_machine.input_lines[offset:],
input_offset=self.state_machine.abs_line_offset() + 1,
node=bulletlist, initial_state='BulletList',
blank_finish=blank_finish)
self.goto_line(new_line_offset)
if not blank_finish:
self.parent += self.unindent_warning('Bullet list')
return [], next_state, []
def visit_list_item(self, node):
children = []
for child in node.children:
if not isinstance(child, nodes.Invisible):
children.append(child)
if (children and isinstance(children[0], nodes.paragraph)
and (isinstance(children[-1], nodes.bullet_list)
or isinstance(children[-1], nodes.enumerated_list))):
children.pop()
if len(children) <= 1:
return
else:
raise nodes.NodeFound
# def visit_bullet_list(self, node):
# pass
# def visit_enumerated_list(self, node):
# pass
# def visit_paragraph(self, node):
# raise nodes.SkipNode
def is_compactable(self, node):
# print "is_compactable %s ?" % node.__class__,
# explicite class arguments have precedence
if 'compact' in node['classes']:
return True
if 'open' in node['classes']:
return False
# check config setting:
if (isinstance(node, (nodes.field_list, nodes.definition_list))
and not self.settings.compact_field_lists):
# print "`compact-field-lists` is False"
return False
if (isinstance(node, (nodes.enumerated_list, nodes.bullet_list))
and not self.settings.compact_lists):
# print "`compact-lists` is False"
return False
# more special cases:
if (self.topic_classes == ['contents']): # TODO: self.in_contents
return True
# check the list items:
return self.check_simple_list(node)
def visit_list_item(self, node):
# print "visiting list item", node.__class__
children = [child for child in node.children
if not isinstance(child, nodes.Invisible)]
# print "has %s visible children" % len(children)
if (children and isinstance(children[0], nodes.paragraph)
and (isinstance(children[-1], nodes.bullet_list) or
isinstance(children[-1], nodes.enumerated_list) or
isinstance(children[-1], nodes.field_list))):
children.pop()
# print "%s children remain" % len(children)
if len(children) <= 1:
return
else:
# print "found", child.__class__, "in", node.__class__
raise nodes.NodeFound
def bullet(self, match, context, next_state):
"""Bullet list item."""
bulletlist = nodes.bullet_list()
(bulletlist.source,
bulletlist.line) = self.state_machine.get_source_and_line()
self.parent += bulletlist
bulletlist['bullet'] = match.string[0]
i, blank_finish = self.list_item(match.end())
bulletlist += i
offset = self.state_machine.line_offset + 1 # next line
new_line_offset, blank_finish = self.nested_list_parse(
self.state_machine.input_lines[offset:],
input_offset=self.state_machine.abs_line_offset() + 1,
node=bulletlist, initial_state='BulletList',
blank_finish=blank_finish)
self.goto_line(new_line_offset)
if not blank_finish:
self.parent += self.unindent_warning('Bullet list')
return [], next_state, []
def bullet(self, match, context, next_state):
"""Bullet list item."""
bulletlist = nodes.bullet_list()
self.parent += bulletlist
bulletlist['bullet'] = match.string[0]
i, blank_finish = self.list_item(match.end())
bulletlist += i
offset = self.state_machine.line_offset + 1 # next line
new_line_offset, blank_finish = self.nested_list_parse(
self.state_machine.input_lines[offset:],
input_offset=self.state_machine.abs_line_offset() + 1,
node=bulletlist, initial_state='BulletList',
blank_finish=blank_finish)
self.goto_line(new_line_offset)
if not blank_finish:
self.parent += self.unindent_warning('Bullet list')
return [], next_state, []
def run(self):
ncolumns = self.options.get('columns', 2)
node = nodes.paragraph()
node.document = self.state.document
self.state.nested_parse(self.content, self.content_offset, node)
if len(node.children) != 1 or not isinstance(node.children[0],
nodes.bullet_list):
return [self.state.document.reporter.warning(
'.. hlist content is not a list', line=self.lineno)]
fulllist = node.children[0]
# create a hlist node where the items are distributed
npercol, nmore = divmod(len(fulllist), ncolumns)
index = 0
newnode = addnodes.hlist()
for column in range(ncolumns):
endindex = index + (column < nmore and (npercol+1) or npercol)
col = addnodes.hlistcol()
col += nodes.bullet_list()
col[0] += fulllist.children[index:endindex]
index = endindex
newnode += col
return [newnode]
def _toctree_prune(self, node, depth, maxdepth, collapse=False):
"""Utility: Cut a TOC at a specified depth."""
for subnode in node.children[:]:
if isinstance(subnode, (addnodes.compact_paragraph,
nodes.list_item)):
# for <p> and <li>, just recurse
self._toctree_prune(subnode, depth, maxdepth, collapse)
elif isinstance(subnode, nodes.bullet_list):
# for <ul>, determine if the depth is too large or if the
# entry is to be collapsed
if maxdepth > 0 and depth > maxdepth:
subnode.parent.replace(subnode, [])
else:
# cull sub-entries whose parents aren't 'current'
if (collapse and depth > 1 and
'iscurrent' not in subnode.parent):
subnode.parent.remove(subnode)
else:
# recurse on visible children
self._toctree_prune(subnode, depth+1, maxdepth, collapse)
def _build_notes(self, content):
"""Constructs a list of notes content for the support matrix.
This is generated as a bullet list.
"""
notestitle = nodes.subtitle(text="Notes")
notes = nodes.bullet_list()
content.append(notestitle)
content.append(notes)
NOTES = []
for note in NOTES:
item = nodes.list_item()
item.append(nodes.strong(text=note))
notes.append(item)
def visit_list_item(self, node):
children = []
for child in node.children:
if not isinstance(child, nodes.Invisible):
children.append(child)
if (children and isinstance(children[0], nodes.paragraph)
and (isinstance(children[-1], nodes.bullet_list)
or isinstance(children[-1], nodes.enumerated_list))):
children.pop()
if len(children) <= 1:
return
else:
raise nodes.NodeFound
# def visit_bullet_list(self, node):
# pass
# def visit_enumerated_list(self, node):
# pass
# def visit_paragraph(self, node):
# raise nodes.SkipNode
def is_compactable(self, node):
# print "is_compactable %s ?" % node.__class__,
# explicite class arguments have precedence
if 'compact' in node['classes']:
return True
if 'open' in node['classes']:
return False
# check config setting:
if (isinstance(node, (nodes.field_list, nodes.definition_list))
and not self.settings.compact_field_lists):
# print "`compact-field-lists` is False"
return False
if (isinstance(node, (nodes.enumerated_list, nodes.bullet_list))
and not self.settings.compact_lists):
# print "`compact-lists` is False"
return False
# more special cases:
if (self.topic_classes == ['contents']): # TODO: self.in_contents
return True
# check the list items:
return self.check_simple_list(node)
def visit_list_item(self, node):
# print "visiting list item", node.__class__
children = [child for child in node.children
if not isinstance(child, nodes.Invisible)]
# print "has %s visible children" % len(children)
if (children and isinstance(children[0], nodes.paragraph)
and (isinstance(children[-1], nodes.bullet_list) or
isinstance(children[-1], nodes.enumerated_list) or
isinstance(children[-1], nodes.field_list))):
children.pop()
# print "%s children remain" % len(children)
if len(children) <= 1:
return
else:
# print "found", child.__class__, "in", node.__class__
raise nodes.NodeFound
def bullet(self, match, context, next_state):
"""Bullet list item."""
bulletlist = nodes.bullet_list()
(bulletlist.source,
bulletlist.line) = self.state_machine.get_source_and_line()
self.parent += bulletlist
bulletlist['bullet'] = match.string[0]
i, blank_finish = self.list_item(match.end())
bulletlist += i
offset = self.state_machine.line_offset + 1 # next line
new_line_offset, blank_finish = self.nested_list_parse(
self.state_machine.input_lines[offset:],
input_offset=self.state_machine.abs_line_offset() + 1,
node=bulletlist, initial_state='BulletList',
blank_finish=blank_finish)
self.goto_line(new_line_offset)
if not blank_finish:
self.parent += self.unindent_warning('Bullet list')
return [], next_state, []
def write_dl(self, rows, col_max=30, col_spacing=2):
"""Writes a definition list into the buffer. This is how options
and commands are usually formatted.
:param rows: a list of two item tuples for the terms and values.
:param col_max: the maximum width of the first column.
:param col_spacing: the number of spaces between the first and
second column.
"""
rows = list(rows)
dl = nodes.bullet_list()
self._node.append(dl)
for (option, help_text) in rows:
item = nodes.list_item()
dl.append(item)
p = nodes.paragraph()
p.append(nodes.literal('', option))
p.append(nodes.Text(': '))
p.append(nodes.Text(help_text))
item.append(p)
def visit_list_item(self, node):
children = []
for child in node.children:
if not isinstance(child, nodes.Invisible):
children.append(child)
if (children and isinstance(children[0], nodes.paragraph)
and (isinstance(children[-1], nodes.bullet_list)
or isinstance(children[-1], nodes.enumerated_list))):
children.pop()
if len(children) <= 1:
return
else:
raise nodes.NodeFound
# def visit_bullet_list(self, node):
# pass
# def visit_enumerated_list(self, node):
# pass
# def visit_paragraph(self, node):
# raise nodes.SkipNode
def is_compactable(self, node):
# print "is_compactable %s ?" % node.__class__,
# explicite class arguments have precedence
if 'compact' in node['classes']:
return True
if 'open' in node['classes']:
return False
# check config setting:
if (isinstance(node, (nodes.field_list, nodes.definition_list))
and not self.settings.compact_field_lists):
# print "`compact-field-lists` is False"
return False
if (isinstance(node, (nodes.enumerated_list, nodes.bullet_list))
and not self.settings.compact_lists):
# print "`compact-lists` is False"
return False
# more special cases:
if (self.topic_classes == ['contents']): # TODO: self.in_contents
return True
# check the list items:
return self.check_simple_list(node)
def visit_list_item(self, node):
# print "visiting list item", node.__class__
children = [child for child in node.children
if not isinstance(child, nodes.Invisible)]
# print "has %s visible children" % len(children)
if (children and isinstance(children[0], nodes.paragraph)
and (isinstance(children[-1], nodes.bullet_list) or
isinstance(children[-1], nodes.enumerated_list) or
isinstance(children[-1], nodes.field_list))):
children.pop()
# print "%s children remain" % len(children)
if len(children) <= 1:
return
else:
# print "found", child.__class__, "in", node.__class__
raise nodes.NodeFound
def bullet(self, match, context, next_state):
"""Bullet list item."""
bulletlist = nodes.bullet_list()
(bulletlist.source,
bulletlist.line) = self.state_machine.get_source_and_line()
self.parent += bulletlist
bulletlist['bullet'] = match.string[0]
i, blank_finish = self.list_item(match.end())
bulletlist += i
offset = self.state_machine.line_offset + 1 # next line
new_line_offset, blank_finish = self.nested_list_parse(
self.state_machine.input_lines[offset:],
input_offset=self.state_machine.abs_line_offset() + 1,
node=bulletlist, initial_state='BulletList',
blank_finish=blank_finish)
self.goto_line(new_line_offset)
if not blank_finish:
self.parent += self.unindent_warning('Bullet list')
return [], next_state, []
support_matrix.py 文件源码
项目:Trusted-Platform-Module-nova
作者: BU-NU-CLOUD-SP16
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
def _build_notes(self, content):
"""Constructs a list of notes content for the support matrix.
This is generated as a bullet list.
"""
notestitle = nodes.subtitle(text="Notes")
notes = nodes.bullet_list()
content.append(notestitle)
content.append(notes)
NOTES = [
"Virtuozzo was formerly named Parallels in this document"
]
for note in NOTES:
item = nodes.list_item()
item.append(nodes.strong(text=note))
notes.append(item)
__init__.py 文件源码
项目:tf_aws_ecs_instance_draining_on_scale_in
作者: terraform-community-modules
项目源码
文件源码
阅读 22
收藏 0
点赞 0
评论 0
def visit_list_item(self, node):
children = []
for child in node.children:
if not isinstance(child, nodes.Invisible):
children.append(child)
if (children and isinstance(children[0], nodes.paragraph)
and (isinstance(children[-1], nodes.bullet_list)
or isinstance(children[-1], nodes.enumerated_list))):
children.pop()
if len(children) <= 1:
return
else:
raise nodes.NodeFound
# def visit_bullet_list(self, node):
# pass
# def visit_enumerated_list(self, node):
# pass
# def visit_paragraph(self, node):
# raise nodes.SkipNode
_html_base.py 文件源码
项目:tf_aws_ecs_instance_draining_on_scale_in
作者: terraform-community-modules
项目源码
文件源码
阅读 25
收藏 0
点赞 0
评论 0
def is_compactable(self, node):
# print "is_compactable %s ?" % node.__class__,
# explicite class arguments have precedence
if 'compact' in node['classes']:
return True
if 'open' in node['classes']:
return False
# check config setting:
if (isinstance(node, (nodes.field_list, nodes.definition_list))
and not self.settings.compact_field_lists):
# print "`compact-field-lists` is False"
return False
if (isinstance(node, (nodes.enumerated_list, nodes.bullet_list))
and not self.settings.compact_lists):
# print "`compact-lists` is False"
return False
# more special cases:
if (self.topic_classes == ['contents']): # TODO: self.in_contents
return True
# check the list items:
return self.check_simple_list(node)
_html_base.py 文件源码
项目:tf_aws_ecs_instance_draining_on_scale_in
作者: terraform-community-modules
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def visit_list_item(self, node):
# print "visiting list item", node.__class__
children = [child for child in node.children
if not isinstance(child, nodes.Invisible)]
# print "has %s visible children" % len(children)
if (children and isinstance(children[0], nodes.paragraph)
and (isinstance(children[-1], nodes.bullet_list) or
isinstance(children[-1], nodes.enumerated_list) or
isinstance(children[-1], nodes.field_list))):
children.pop()
# print "%s children remain" % len(children)
if len(children) <= 1:
return
else:
# print "found", child.__class__, "in", node.__class__
raise nodes.NodeFound
states.py 文件源码
项目:tf_aws_ecs_instance_draining_on_scale_in
作者: terraform-community-modules
项目源码
文件源码
阅读 25
收藏 0
点赞 0
评论 0
def bullet(self, match, context, next_state):
"""Bullet list item."""
bulletlist = nodes.bullet_list()
(bulletlist.source,
bulletlist.line) = self.state_machine.get_source_and_line()
self.parent += bulletlist
bulletlist['bullet'] = match.string[0]
i, blank_finish = self.list_item(match.end())
bulletlist += i
offset = self.state_machine.line_offset + 1 # next line
new_line_offset, blank_finish = self.nested_list_parse(
self.state_machine.input_lines[offset:],
input_offset=self.state_machine.abs_line_offset() + 1,
node=bulletlist, initial_state='BulletList',
blank_finish=blank_finish)
self.goto_line(new_line_offset)
if not blank_finish:
self.parent += self.unindent_warning('Bullet list')
return [], next_state, []
def visit_block_quote(self, node):
# If the block quote contains a single object and that object
# is a list, then generate a list not a block quote.
# This lets us indent lists.
done = 0
if len(node.children) == 1:
child = node.children[0]
if isinstance(child, nodes.bullet_list) or \
isinstance(child, nodes.enumerated_list):
done = 1
if not done:
self.body.append('\\begin{quote}\n')
if self.table:
self.table.has_problematic = True
def depart_block_quote(self, node):
done = 0
if len(node.children) == 1:
child = node.children[0]
if isinstance(child, nodes.bullet_list) or \
isinstance(child, nodes.enumerated_list):
done = 1
if not done:
self.body.append('\\end{quote}\n')
# option node handling copied from docutils' latex writer
def build_contents(self, node, level=0):
level += 1
sections = [sect for sect in node if isinstance(sect, nodes.section)]
entries = []
autonum = 0
depth = self.startnode.details.get('depth', sys.maxint)
for section in sections:
title = section[0]
auto = title.get('auto') # May be set by SectNum.
entrytext = self.copy_and_filter(title)
reference = nodes.reference('', '', refid=section['ids'][0],
*entrytext)
ref_id = self.document.set_id(reference)
entry = nodes.paragraph('', '', reference)
item = nodes.list_item('', entry)
if ( self.backlinks in ('entry', 'top')
and title.next_node(nodes.reference) is None):
if self.backlinks == 'entry':
title['refid'] = ref_id
elif self.backlinks == 'top':
title['refid'] = self.toc_id
if level < depth:
subsects = self.build_contents(section, level)
item += subsects
entries.append(item)
if entries:
contents = nodes.bullet_list('', *entries)
if auto:
contents['classes'].append('auto-toc')
return contents
else:
return []
def extract_authors(self, field, name, docinfo):
try:
if len(field[1]) == 1:
if isinstance(field[1][0], nodes.paragraph):
authors = self.authors_from_one_paragraph(field)
elif isinstance(field[1][0], nodes.bullet_list):
authors = self.authors_from_bullet_list(field)
else:
raise TransformError
else:
authors = self.authors_from_paragraphs(field)
authornodes = [nodes.author('', '', *author)
for author in authors if author]
if len(authornodes) >= 1:
docinfo.append(nodes.authors('', *authornodes))
else:
raise TransformError
except TransformError:
field[-1] += self.document.reporter.warning(
'Bibliographic field "%s" incompatible with extraction: '
'it must contain either a single paragraph (with authors '
'separated by one of "%s"), multiple paragraphs (one per '
'author), or a bullet list with one paragraph (one author) '
'per item.'
% (name, ''.join(self.language.author_separators)),
base_node=field)
raise