本文整理汇总了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函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:feld,项目名称:SickRage,代码行数:30,代码来源:sphinxext.py
示例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
开发者ID:HoratiusTang,项目名称:oslo.config,代码行数:33,代码来源:sphinxext.py
示例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
开发者ID:OpenMDAO,项目名称:OpenMDAO,代码行数:30,代码来源:embed_options.py
示例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
开发者ID:ZELLMECHANIK-DRESDEN,项目名称:ShapeOut,代码行数:25,代码来源:rtd_pdf.py
示例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
开发者ID:SiCKRAGETV,项目名称:SiCKRAGE,代码行数:30,代码来源:sphinxext.py
示例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
开发者ID:ellisonbg,项目名称:altair,代码行数:35,代码来源:altairgallery.py
示例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
开发者ID:mdrohmann,项目名称:sphinxplugin-project-timeline,代码行数:29,代码来源:directives.py
示例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
开发者ID:SerhatG,项目名称:nzbToMedia,代码行数:34,代码来源:sphinxext.py
示例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
开发者ID:OpenMDAO,项目名称:OpenMDAO,代码行数:32,代码来源:embed_n2.py
示例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
开发者ID:chauhanu,项目名称:altair,代码行数:26,代码来源:altair_autodoc.py
示例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
开发者ID:SiahaanBernard,项目名称:cloud-custodian,代码行数:8,代码来源:c7n_schema.py
示例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
开发者ID:andreypopp,项目名称:routr-doc,代码行数:8,代码来源:routrdoc.py
示例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 []
开发者ID:i80and,项目名称:docs-tools,代码行数:8,代码来源:fixed_only.py
示例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]
开发者ID:Aalto-LeTech,项目名称:a-plus-rst-tools,代码行数:8,代码来源:questionnaire.py
示例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
开发者ID:AnneGilles,项目名称:yafowil.documentation,代码行数:8,代码来源:sphinxext.py
示例16: run
def run(self):
node = nodes.section()
node.document = self.state.document
result = ViewList()
for line in self.make_rst():
result.append(line, '<{0}>'.format(self.__class__.__name__))
nested_parse_with_titles(self.state, result, node)
return node.children
开发者ID:garyvdm,项目名称:pywayland,代码行数:8,代码来源:sphinx_wl_protocol.py
示例17: run
def run(self):
env = self.state.document.settings.env
app = env.app
def info(msg):
app.info('[reno] %s' % (msg,))
title = ' '.join(self.content)
branch = self.options.get('branch')
reporoot_opt = self.options.get('reporoot', '.')
reporoot = os.path.abspath(reporoot_opt)
relnotessubdir = self.options.get('relnotessubdir',
defaults.RELEASE_NOTES_SUBDIR)
conf = config.Config(reporoot, relnotessubdir)
opt_overrides = {}
if 'notesdir' in self.options:
opt_overrides['notesdir'] = self.options.get('notesdir')
version_opt = self.options.get('version')
# FIXME(dhellmann): Force these flags True for now and figure
# out how Sphinx passes a "false" flag later.
# 'collapse-pre-releases' in self.options
opt_overrides['collapse_pre_releases'] = True
opt_overrides['stop_at_branch_base'] = True
if 'earliest-version' in self.options:
opt_overrides['earliest_version'] = self.options.get(
'earliest-version')
if branch:
opt_overrides['branch'] = branch
conf.override(**opt_overrides)
notesdir = os.path.join(relnotessubdir, conf.notesdir)
info('scanning %s for %s release notes' %
(os.path.join(conf.reporoot, notesdir),
branch or 'current branch'))
ldr = loader.Loader(conf)
if version_opt is not None:
versions = [
v.strip()
for v in version_opt.split(',')
]
else:
versions = ldr.versions
info('got versions %s' % (versions,))
text = formatter.format_report(
ldr,
versions,
title=title,
)
source_name = '<' + __name__ + '>'
result = statemachine.ViewList()
for line in text.splitlines():
result.append(line, source_name)
node = nodes.section()
node.document = self.state.document
nested_parse_with_titles(self.state, result, node)
return node.children
开发者ID:openstack,项目名称:reno,代码行数:58,代码来源:sphinxext.py
示例18: run
def run(self):
self.env = self.state.document.settings.env
self.language = self.options.get('language', self.env.config.language)
self.env.temp_data['language'] = self.language
# catch exceptions and report them together with the name of
# the guilty file
try:
output = self.get_rst()
except Exception as e:
traceback.print_exc()
document = self.state.document
return [document.reporter.warning(str(e), line=self.lineno)]
#~ output = output.decode('utf-8')
if 'debug' in self.options:
print(self.env.docname)
print('-' * 50)
print(output)
print('-' * 50)
content = statemachine.StringList(
output.splitlines(), self.state.document.current_source)
# content = RSTStateMachine(output.splitlines())
if self.raw_insert:
self.state_machine.insert_input(content, output)
return []
# print("20180821 {} {}".format(
# self.name, self.state.document.current_source))
if self.titles_allowed:
node = nodes.section()
# necessary so that the child nodes get the right source/line set
# self.state.parent.setup_child(node)
# node.document = self.state.document
nested_parse_with_titles(self.state, content, node)
else:
node = nodes.paragraph()
# self.state.parent.setup_child(node)
# node.document = self.state.document
self.state.nested_parse(content, self.content_offset, node)
# following lines originally copied from
# docutils.parsers.rst.directives.tables.RSTTable
#~ title, messages = self.make_title()
# ~ node = nodes.Element() # anonymous container for parsing
#~ self.state.nested_parse(content, self.content_offset, node)
#~ if len(node) != 1 or not isinstance(node[0], nodes.table):
#~ error = self.state_machine.reporter.error(
#~ 'Error parsing content block for the "%s" directive: exactly '
#~ 'one table expected.' % self.name, nodes.literal_block(
#~ self.block_text, self.block_text), line=self.lineno)
#~ return [error]
#~ return [x for x in node]
return list(node)
开发者ID:lino-framework,项目名称:atelier,代码行数:58,代码来源:insert_input.py
示例19: run
def run(self):
self.result = ViewList()
path = self.arguments[0]
filename = os.path.basename(path)
node = nodes.section()
node.document = self.state.document
self.add_lines(JavaScriptDocument(path).to_rst(self.options))
nested_parse_with_titles(self.state, self.result, node)
return node.children
开发者ID:GeekFreaker,项目名称:vumi-jssandbox-toolkit,代码行数:9,代码来源:autojs.py
示例20: run
def run(self):
command = sh_split(' '.join(self.arguments[0:]))
stdout = Popen(command, stdout=PIPE, stdin=open(os.devnull)
).communicate()[0]
node = nodes.section()
node.document = self.state.document
nested_parse_with_titles(self.state, ViewList(stdout.splitlines()),
node)
return node.children
开发者ID:dpmatthews,项目名称:rose,代码行数:9,代码来源:script_include.py
注:本文中的sphinx.util.nodes.nested_parse_with_titles函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论