本文整理汇总了Python中sphinx.writers.html.SmartyPantsHTMLTranslator.visit_title方法的典型用法代码示例。如果您正苦于以下问题:Python SmartyPantsHTMLTranslator.visit_title方法的具体用法?Python SmartyPantsHTMLTranslator.visit_title怎么用?Python SmartyPantsHTMLTranslator.visit_title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sphinx.writers.html.SmartyPantsHTMLTranslator
的用法示例。
在下文中一共展示了SmartyPantsHTMLTranslator.visit_title方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: visit_title
# 需要导入模块: from sphinx.writers.html import SmartyPantsHTMLTranslator [as 别名]
# 或者: from sphinx.writers.html.SmartyPantsHTMLTranslator import visit_title [as 别名]
def visit_title(self, node):
if isinstance(node.parent, nodes.section):
# Steal the id from the parent. This is used in chromesite to handle the
# auto-generated navbar and permalinks.
if node.parent.hasattr('ids'):
node['ids'] = node.parent['ids'][:]
HTMLTranslator.visit_title(self, node)
示例2: visit_title
# 需要导入模块: from sphinx.writers.html import SmartyPantsHTMLTranslator [as 别名]
# 或者: from sphinx.writers.html.SmartyPantsHTMLTranslator import visit_title [as 别名]
def visit_title(self, node):
# Why this?
#
# Sphinx insists on inserting a <h1>Page Title</h1> into the page, but this
# is not how the devsite wants it. The devsite inserts the page title on
# its own, the the extra h1 is duplication.
#
# Killing the doctree title node in a custom transform doesn't work, because
# Sphinx explicitly looks for it when writing a document. So instead we rig
# the HTML produced.
#
# When a title node is visited, and this is the h1-to-be, we ignore it and
# also set a flag that tells visit_Text not to print the actual text of the
# header.
# The h1 node is in the section whose parent is the document itself. Other
# sections have this top-section as their parent.
if (node.parent and node.parent.parent and
isinstance(node.parent.parent, nodes.document)):
# Internal flag. Also, nothing is pushed to the context. Our depart_title
# doesn't pop anything when this flag is set.
self.within_ignored_h1 = True
else:
HTMLTranslator.visit_title(self, node)