本文整理汇总了Python中sphinx.writers.html.HTMLTranslator.visit_title方法的典型用法代码示例。如果您正苦于以下问题:Python HTMLTranslator.visit_title方法的具体用法?Python HTMLTranslator.visit_title怎么用?Python HTMLTranslator.visit_title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sphinx.writers.html.HTMLTranslator
的用法示例。
在下文中一共展示了HTMLTranslator.visit_title方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: visit_title
# 需要导入模块: from sphinx.writers.html import HTMLTranslator [as 别名]
# 或者: from sphinx.writers.html.HTMLTranslator import visit_title [as 别名]
def visit_title(self, node):
if isinstance(node.parent, nodes.section):
level = self.section_level + self.initial_header_level - 1
tag = 'h%s' % level
self.body.append(self.starttag(node, tag, ''))
self.context.append('</%s>\n' % tag)
else:
HTMLTranslator.visit_title(self, node)
示例2: visit_title
# 需要导入模块: from sphinx.writers.html import HTMLTranslator [as 别名]
# 或者: from sphinx.writers.html.HTMLTranslator import visit_title [as 别名]
def visit_title(self, node):
if isinstance(node.parent, slide) or node.parent.attributes.get("include-as-slide", False):
slide_level = node.parent.attributes.get("level", self.section_level)
level = max(slide_level + self.initial_header_level - 1, 1)
tag = "h%s" % level
self.body.append(self.starttag(node, tag, ""))
self.context.append("</%s>\n" % tag)
else:
HTMLTranslator.visit_title(self, node)
示例3: visit_title
# 需要导入模块: from sphinx.writers.html import HTMLTranslator [as 别名]
# 或者: from sphinx.writers.html.HTMLTranslator import visit_title [as 别名]
def visit_title(self, node):
if isinstance(node.parent, nodes.section) and not self.builder.has_title(self.document):
h_level = self.section_level + self.initial_header_level - 1
if h_level == 1:
# Confluence take first title for page title from rst
# It use for making internal links
self.builder.set_title(self.document, node.children[0])
# ignore first header; document must have title header
raise nodes.SkipNode
HTMLTranslator.visit_title(self, node)
示例4: visit_title
# 需要导入模块: from sphinx.writers.html import HTMLTranslator [as 别名]
# 或者: from sphinx.writers.html.HTMLTranslator import visit_title [as 别名]
def visit_title(self, node):
if (isinstance(node.parent, slide) or
node.parent.attributes.get('include-as-slide', False)):
slide_level = node.parent.attributes.get(
'level',
self.section_level)
level = max(
slide_level + self.initial_header_level - 1,
1,
)
tag = 'h%s' % level
self.body.append(self.starttag(node, tag, ''))
self.context.append('</%s>\n' % tag)
else:
HTMLTranslator.visit_title(self, node)
示例5: visit_title
# 需要导入模块: from sphinx.writers.html import HTMLTranslator [as 别名]
# 或者: from sphinx.writers.html.HTMLTranslator import visit_title [as 别名]
def visit_title(self, node):
self.push_body()
if isinstance(node.parent, slide) or node.parent.attributes.get("include-as-slide", False):
slide_level = node.parent.attributes.get("level", self.section_level)
level = max(slide_level + self.initial_header_level - 1, 1)
self.current_slide.level = level
# tag = 'h%s' % level
# self.body.append(self.starttag(node, tag, ''))
# self.context.append('</%s>\n' % tag)
if self.current_slide and isinstance(node.parent, (nodes.section, slide)):
self.current_slide.title = node.astext().strip()
else:
HTMLTranslator.visit_title(self, node)
示例6: visit_title
# 需要导入模块: from sphinx.writers.html import HTMLTranslator [as 别名]
# 或者: from sphinx.writers.html.HTMLTranslator import visit_title [as 别名]
def visit_title(self, node):
if not isinstance(node.parent, nodes.section):
HTMLTranslator.visit_title(self, node)
return
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))
ids = node.parent.get('ids', [])
for id_ in ids:
self.body.append('<span id="%s" class="bookmark"></span>' % id_)
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)
示例7: visit_title
# 需要导入模块: from sphinx.writers.html import HTMLTranslator [as 别名]
# 或者: from sphinx.writers.html.HTMLTranslator import visit_title [as 别名]
def visit_title(self, node):
if self.section_level == 1:
raise nodes.SkipNode
HTMLTranslator.visit_title(self, node)