本文整理汇总了Python中sphinx.util.nodes.nested_parse_with_titles函数的典型用法代码示例。如果您正苦于以下问题:Python nested_parse_with_titles函数的具体用法?Python nested_parse_with_titles怎么用?Python nested_parse_with_titles使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了nested_parse_with_titles函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run(self):
env = self.state.document.settings.env
app = env.app
namespace = " ".join(self.content).strip()
app.info("documenting plugins from %r" % namespace)
overline_style = self.options.get("overline-style", "")
underline_style = self.options.get("underline-style", "=")
def report_load_failure(mgr, ep, err):
app.warn("Failed to load %s: %s" % (ep.module_name, err))
mgr = extension.ExtensionManager(namespace, on_load_failure_callback=report_load_failure)
result = ViewList()
if "detailed" in self.options:
data = _detailed_list(mgr, over=overline_style, under=underline_style)
else:
data = _simple_list(mgr)
for text, source in data:
for line in text.splitlines():
result.append(line, source)
# 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
示例2: run
def run(self):
env = self.state.document.settings.env
app = env.app
split_namespaces = 'split-namespaces' in self.options
config_file = self.options.get('config-file')
if config_file:
app.info('loading config file %s' % config_file)
conf = cfg.ConfigOpts()
conf.register_opts(generator._generator_opts)
conf(
args=['--config-file', config_file],
project='oslo.config.sphinxext',
)
namespaces = conf.namespace[:]
else:
namespaces = [
c.strip()
for c in self.content
if c.strip()
]
result = ViewList()
source_name = '<' + __name__ + '>'
for line in _format_option_help(app, namespaces, split_namespaces):
result.append(line, source_name)
node = nodes.section()
node.document = self.state.document
nested_parse_with_titles(self.state, result, node)
return node.children
示例3: run
def run(self):
module_path, class_name, attribute_name = self.arguments
mod = importlib.import_module(module_path)
klass = getattr(mod, class_name)
options = getattr(klass(), attribute_name)
if not isinstance(options, OptionsDictionary):
raise TypeError("Object '%s' is not an OptionsDictionary." % attribute_name)
lines = ViewList()
n = 0
for line in options.__rst__():
lines.append(line, "options table", n)
n += 1
# Note applicable to System, Solver and Driver 'options', but not to 'recording_options'
if attribute_name != 'recording_options':
lines.append("", "options table", n+1) # Blank line required after table.
# Create a node.
node = nodes.section()
node.document = self.state.document
# Parse the rst.
nested_parse_with_titles(self.state, lines, node)
# And return the result.
return node.children
示例4: run
def run(self):
if "READTHEDOCS" in os.environ:
project = os.environ["READTHEDOCS_PROJECT"]
version = os.environ["READTHEDOCS_VERSION"]
is_rtd = os.environ["READTHEDOCS"] == "True"
link = "https://readthedocs.org/projects/" \
+ "{}/downloads/pdf/{}/".format(project, version)
else:
is_rtd = False
rst = []
if is_rtd:
rst = "This documentation is also available as a " \
+ "`PDF <{}>`_.".format(link)
rst = [rst]
vl = ViewList(rst, "fakefile.rst")
# Create a node.
node = nodes.section()
node.document = self.state.document
# Parse the rst.
nested_parse_with_titles(self.state, vl, node)
return node.children
示例5: run
def run(self):
env = self.state.document.settings.env
app = env.app
iface_type = ' '.join(self.content).strip()
app.info('documenting service interface %r' % iface_type)
source_name = '<' + __name__ + '>'
api_map = interfaces.construct_map(trakt.Trakt.client)
iface_map = {iface_type: api_map.get(iface_type)}
result = ViewList()
for api_path, api_ref, api_methods in _format_apis(iface_map):
result.append(api_path, source_name)
result.append('', source_name)
result.append(api_ref, source_name)
result.append('', source_name)
for method in api_methods:
result.append(method, source_name)
result.append('', source_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
示例6: run
def run(self):
size = self.options.get('size', 4)
shuffle = 'shuffle' in self.options
seed = self.options.get('seed', 42)
titles = self.options.get('titles', False)
width = self.options.get('width', None)
env = self.state.document.settings.env
app = env.app
gallery_dir = app.builder.config.altair_gallery_dir
gallery_ref = app.builder.config.altair_gallery_ref
examples = populate_examples(shuffle=shuffle,
shuffle_seed=seed,
num_examples=size,
gallery_dir=gallery_dir,
gallery_ref=gallery_ref,
code_below=True)
include = MINIGALLERY_TEMPLATE.render(image_dir='/_images',
gallery_dir=gallery_dir,
examples=examples,
titles=titles,
width=width)
# parse and return documentation
result = ViewList()
for line in include.split('\n'):
result.append(line, "<altair-minigallery>")
node = nodes.paragraph()
node.document = self.state.document
nested_parse_with_titles(self.state, result, node)
return node.children
示例7: run
def run(self):
docutils.parsers.rst.roles.set_classes({"class": "timeline"})
nested_node = docutils.nodes.paragraph()
nested_parse_with_titles(self.state, self.content, nested_node)
# find milestones section
milestones_sections = list(
nested_node.traverse(
lambda(node):
utils.node_is_section_with_title(node, 'milestones')))
# find deadlines section
deadlines_sections = list(
nested_node.traverse(
lambda(node):
utils.node_is_section_with_title(node, 'deadlines')))
# create a timeline node
timeline = TimelineNode()
results = [timeline]
for milestones_section in milestones_sections:
timeline.add_milestones_from_section(milestones_section)
for deadline_section in deadlines_sections:
timeline.add_deadlines_from_section(deadline_section)
return results
示例8: run
def run(self):
namespace = ' '.join(self.content).strip()
LOG.info('documenting plugins from %r' % namespace)
overline_style = self.options.get('overline-style', '')
underline_style = self.options.get('underline-style', '=')
def report_load_failure(mgr, ep, err):
LOG.warning(u'Failed to load %s: %s' % (ep.module_name, err))
mgr = extension.ExtensionManager(
namespace,
on_load_failure_callback=report_load_failure,
)
result = ViewList()
titlecase = 'titlecase' in self.options
if 'detailed' in self.options:
data = _detailed_list(
mgr, over=overline_style, under=underline_style,
titlecase=titlecase)
else:
data = _simple_list(mgr)
for text, source in data:
for line in text.splitlines():
result.append(line, source)
# 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
示例9: run
def run(self):
path_to_model = self.arguments[0]
np = os.path.normpath(os.path.join(os.getcwd(), path_to_model))
# check that the file exists
if not os.path.isfile(np):
raise IOError('File does not exist({0})'.format(np))
html_name = os.path.join(os.getcwd(), (os.path.basename(path_to_model).split('.')[0] + "_n2.html"))
cmd = subprocess.Popen(['openmdao', 'view_model', np, '--no_browser', '--embed', '-o' + html_name])
cmd_out, cmd_err = cmd.communicate()
rst = ViewList()
# Add the content one line at a time.
# Second argument is the filename to report in any warnings
# or errors, third argument is the line number.
env = self.state.document.settings.env
docname = env.doc2path(env.docname)
rst.append(".. raw:: html", docname, self.lineno)
rst.append(" :file: %s" % html_name, docname, self.lineno)
# Create a node.
node = nodes.section()
# Parse the rst.
nested_parse_with_titles(self.state, rst, node)
# And return the result.
return node.children
示例10: run
def run(self):
env = self.state.document.settings.env
app = env.app
classname = self.arguments[0].split('(')[0].strip()
try:
obj = import_obj(classname, default_module='altair')
except ImportError:
raise
warnings.warn('Could not make table for {0}. Unable to import'
''.format(object))
# create the table from the object
include_vl_link = ('include-vegalite-link' in self.options)
table = altair_rst_table(obj, include_description=include_vl_link)
# parse and return documentation
result = ViewList()
for line in table:
result.append(line, "<altair-class>")
node = nodes.paragraph()
node.document = self.state.document
nested_parse_with_titles(self.state, result, node)
return node.children
示例11: _parse
def _parse(self, rst_text, annotation):
result = ViewList()
for line in rst_text.split("\n"):
result.append(line, annotation)
node = nodes.paragraph()
node.document = self.state.document
nested_parse_with_titles(self.state, result, node)
return node.children
示例12: run
def run(self):
node = nodes.section()
node.document = self.state.document
result = ViewList()
for line in self.make_rst():
result.append(line, '<autoroutr>')
nested_parse_with_titles(self.state, result, node)
return node.children
示例13: run
def run(self):
config = self.state.document.settings.env.config
if config._raw_config['tags'].eval_condition(self.arguments[0]):
node = nodes.Element()
nested_parse_with_titles(self.state, self.content, node)
return node.children
return []
示例14: run
def run(self):
# This directive is obsolete, AgreeItems can be placed alone.
classes = [u'form-group']
if 'class' in self.options:
classes.extend(self.options['class'])
node = aplus_nodes.html(u'div', { u'class': u" ".join(classes) })
nested_parse_with_titles(self.state, self.content, node)
return [node]
示例15: _rest2node
def _rest2node(self, rest, container=None):
vl = ViewList(prepare_docstring(rest))
if container is None:
node = nodes.container()
else:
node = container()
nested_parse_with_titles(self.state, vl, node)
return node