本文整理匯總了Python中docutils.statemachine.ViewList方法的典型用法代碼示例。如果您正苦於以下問題:Python statemachine.ViewList方法的具體用法?Python statemachine.ViewList怎麽用?Python statemachine.ViewList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類docutils.statemachine
的用法示例。
在下文中一共展示了statemachine.ViewList方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: wrap_mangling_directive
# 需要導入模塊: from docutils import statemachine [as 別名]
# 或者: from docutils.statemachine import ViewList [as 別名]
def wrap_mangling_directive(base_directive, objtype):
class directive(base_directive):
def run(self):
env = self.state.document.settings.env
name = None
if self.arguments:
m = re.match(r'^(.*\s+)?(.*?)(\(.*)?', self.arguments[0])
name = m.group(2).strip()
if not name:
name = self.arguments[0]
lines = list(self.content)
mangle_docstrings(env.app, objtype, name, None, None, lines)
# local import to avoid testing dependency
from docutils.statemachine import ViewList
self.content = ViewList(lines, self.content.parent)
return base_directive.run(self)
return directive
示例2: wrap_mangling_directive
# 需要導入模塊: from docutils import statemachine [as 別名]
# 或者: from docutils.statemachine import ViewList [as 別名]
def wrap_mangling_directive(base_directive, objtype):
class directive(base_directive):
def run(self):
env = self.state.document.settings.env
name = None
if self.arguments:
m = re.match(r'^(.*\s+)?(.*?)(\(.*)?', self.arguments[0])
name = m.group(2).strip()
if not name:
name = self.arguments[0]
lines = list(self.content)
mangle_docstrings(env.app, objtype, name, None, None, lines)
self.content = ViewList(lines, self.content.parent)
return base_directive.run(self)
return directive
示例3: run
# 需要導入模塊: from docutils import statemachine [as 別名]
# 或者: from docutils.statemachine import ViewList [as 別名]
def run(self):
module = self.options.get("module")
attr = self.options.get("attr")
parser = get_parser(module, attr)
self._available_options = []
for group in parser.groups:
for arg in group.arguments:
self._available_options += arg.args
node = nodes.section()
node.document = self.state.document
result = ViewList()
for line in self.generate_parser_rst(parser):
result.append(line, "argparse")
nested_parse_with_titles(self.state, result, node)
return node.children
示例4: _generate_app_node
# 需要導入模塊: from docutils import statemachine [as 別名]
# 或者: from docutils.statemachine import ViewList [as 別名]
def _generate_app_node(self, app, application_name):
ignored_opts = self._get_ignored_opts()
parser = app.parser
self._drop_ignored_options(parser, ignored_opts)
parser.prog = application_name
source_name = '<{}>'.format(app.__class__.__name__)
result = statemachine.ViewList()
for line in _format_parser(parser):
result.append(line, source_name)
section = nodes.section()
self.state.nested_parse(result, 0, section)
# return [section.children]
return section.children
示例5: run
# 需要導入模塊: from docutils import statemachine [as 別名]
# 或者: from docutils.statemachine import ViewList [as 別名]
def run(self):
self.filenames = set()
if self.arguments[0] == 'lexers':
out = self.document_lexers()
elif self.arguments[0] == 'formatters':
out = self.document_formatters()
elif self.arguments[0] == 'filters':
out = self.document_filters()
else:
raise Exception('invalid argument for "pygmentsdoc" directive')
node = nodes.compound()
vl = ViewList(out.split('\n'), source='')
nested_parse_with_titles(self.state, vl, node)
for fn in self.filenames:
self.state.document.settings.record_dependencies.add(fn)
return node.children
示例6: wrap_mangling_directive
# 需要導入模塊: from docutils import statemachine [as 別名]
# 或者: from docutils.statemachine import ViewList [as 別名]
def wrap_mangling_directive(base_directive, objtype):
class directive(base_directive):
def run(self):
env = self.state.document.settings.env
name = None
if self.arguments:
m = re.match(r'^(.*\s+)?(.*?)(\(.*)?', self.arguments[0])
name = m.group(2).strip()
if not name:
name = self.arguments[0]
lines = list(self.content)
mangle_docstrings(env.app, objtype, name, None, None, lines)
self.content = ViewList(lines, self.content.parent)
return base_directive.run(self)
return directive
示例7: _create_row
# 需要導入模塊: from docutils import statemachine [as 別名]
# 或者: from docutils.statemachine import ViewList [as 別名]
def _create_row(self, *column_texts):
row = nodes.row('')
source, line = self.state_machine.get_source_and_line()
for text_line in column_texts:
node = nodes.paragraph('')
vl = ViewList()
for text in text_line.split('\n'):
vl.append(text, '%s:%d' % (source, line))
with switch_source_input(self.state, vl):
self.state.nested_parse(vl, 0, node)
try:
if isinstance(node[0], nodes.paragraph) and len(node.children) == 1:
node = node[0]
except IndexError:
pass
row.append(nodes.entry('', node))
return row
示例8: run
# 需要導入模塊: from docutils import statemachine [as 別名]
# 或者: from docutils.statemachine import ViewList [as 別名]
def run(self):
all_workbooks = get_workbooks()
# Build the view of the data to be parsed for rendering.
result = ViewList()
for workbook_name in sorted(all_workbooks.keys()):
workbook = all_workbooks[workbook_name]
for line in _workbook_to_rst(workbook_name, workbook):
result.append(line, '<' + __name__ + '>')
# Parse what we have into a new section.
node = nodes.section()
node.document = self.state.document
nested_parse_with_titles(self.state, result, node)
return node.children