本文整理汇总了Python中docutils.nodes.subtitle方法的典型用法代码示例。如果您正苦于以下问题:Python nodes.subtitle方法的具体用法?Python nodes.subtitle怎么用?Python nodes.subtitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docutils.nodes
的用法示例。
在下文中一共展示了nodes.subtitle方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import subtitle [as 别名]
def run(self):
if not (self.state_machine.match_titles
or isinstance(self.state_machine.node, nodes.sidebar)):
raise self.error('The "%s" directive may not be used within '
'topics or body elements.' % self.name)
self.assert_has_content()
title_text = self.arguments[0]
textnodes, messages = self.state.inline_text(title_text, self.lineno)
titles = [nodes.title(title_text, '', *textnodes)]
# Sidebar uses this code.
if 'subtitle' in self.options:
textnodes, more_messages = self.state.inline_text(
self.options['subtitle'], self.lineno)
titles.append(nodes.subtitle(self.options['subtitle'], '',
*textnodes))
messages.extend(more_messages)
text = '\n'.join(self.content)
node = self.node_class(text, *(titles + messages))
node['classes'] += self.options.get('class', [])
self.add_name(node)
if text:
self.state.nested_parse(self.content, self.content_offset, node)
return [node]
示例2: _build_backend_detail
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import subtitle [as 别名]
def _build_backend_detail(self, matrix, content):
detailstitle = nodes.subtitle(text="Backend Details")
content.append(detailstitle)
content.append(nodes.paragraph())
for key in six.iterkeys(matrix.backends):
content.append(
nodes.subtitle(text=matrix.backends[key].title))
content.append(
self._build_backend_detail_table(
matrix.backends[key],
matrix))
content.append(nodes.paragraph())
return content
示例3: apply
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import subtitle [as 别名]
def apply(self):
if getattr(self.document.settings, 'doctitle_xform', 1):
# promote_(sub)title defined in TitlePromoter base class.
if self.promote_title(self.document):
# If a title has been promoted, also try to promote a
# subtitle.
self.promote_subtitle(self.document)
# Set document['title'].
self.set_metadata()
示例4: depart_subtitle
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import subtitle [as 别名]
def depart_subtitle(self, node):
self.body.append('</p>\n')
if self.in_document_title:
self.subtitle = self.body[self.in_document_title:-1]
self.in_document_title = 0
self.body_pre_docinfo.extend(self.body)
self.html_subtitle.extend(self.body)
del self.body[:]
示例5: visit_title
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import subtitle [as 别名]
def visit_title(self, node):
"""Only 6 section levels are supported by HTML."""
check_id = 0 # TODO: is this a bool (False) or a counter?
close_tag = '</p>\n'
if isinstance(node.parent, nodes.topic):
self.body.append(
self.starttag(node, 'p', '', CLASS='topic-title first'))
elif isinstance(node.parent, nodes.sidebar):
self.body.append(
self.starttag(node, 'p', '', CLASS='sidebar-title'))
elif isinstance(node.parent, nodes.Admonition):
self.body.append(
self.starttag(node, 'p', '', CLASS='admonition-title'))
elif isinstance(node.parent, nodes.table):
self.body.append(
self.starttag(node, 'caption', ''))
close_tag = '</caption>\n'
elif isinstance(node.parent, nodes.document):
self.body.append(self.starttag(node, 'h1', '', CLASS='title'))
close_tag = '</h1>\n'
self.in_document_title = len(self.body)
else:
assert isinstance(node.parent, nodes.section)
h_level = self.section_level + self.initial_header_level - 1
atts = {}
if (len(node.parent) >= 2 and
isinstance(node.parent[1], nodes.subtitle)):
atts['CLASS'] = 'with-subtitle'
self.body.append(
self.starttag(node, 'h%s' % h_level, '', **atts))
atts = {}
if node.hasattr('refid'):
atts['class'] = 'toc-backref'
atts['href'] = '#' + node['refid']
if atts:
self.body.append(self.starttag({}, 'a', '', **atts))
close_tag = '</a></h%s>\n' % (h_level)
else:
close_tag = '</h%s>\n' % (h_level)
self.context.append(close_tag)
示例6: visit_subtitle
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import subtitle [as 别名]
def visit_subtitle(self, node):
if isinstance(node.parent, nodes.sidebar):
classes = 'sidebar-subtitle'
elif isinstance(node.parent, nodes.document):
classes = 'subtitle'
self.in_document_title = len(self.body)
elif isinstance(node.parent, nodes.section):
classes = 'section-subtitle'
self.body.append(self.starttag(node, 'p', '', CLASS=classes))