本文整理汇总了Python中sphinx.writers.html.HTMLTranslator.depart_title方法的典型用法代码示例。如果您正苦于以下问题:Python HTMLTranslator.depart_title方法的具体用法?Python HTMLTranslator.depart_title怎么用?Python HTMLTranslator.depart_title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sphinx.writers.html.HTMLTranslator
的用法示例。
在下文中一共展示了HTMLTranslator.depart_title方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: depart_title
# 需要导入模块: from sphinx.writers.html import HTMLTranslator [as 别名]
# 或者: from sphinx.writers.html.HTMLTranslator import depart_title [as 别名]
def depart_title(self, node):
close_tag = self.context[-1]
if (self.permalink_text and self.builder.add_permalinks and node.parent.hasattr('ids') and node.parent['ids']):
aname = ''
for id in node.parent['ids']:
if self.builder.env.domaindata['std']['labels'].has_key(id):
ref_text = '. Label :ref:`%s`' % id
aname = id
break
if aname:
link_text = ':ref:'
else:
ref_text = ''
aname = node.parent['ids'][0]
link_text = self.permalink_text
# add permalink anchor
if close_tag.startswith('</h'):
what = u'<a class="headerlink" href="#%s" ' % aname + u'title="%s">%s</a>' % (
_('Permalink to this headline') + ref_text, link_text)
if 0:
print 'what:', repr(what)
print 'aname:', repr(aname)
self.body.append(what)
elif close_tag.startswith('</a></h'):
what = u'</a><a class="headerlink" href="#%s" ' % aname + u'title="%s">%s' % (
_('Permalink to this headline') + ref_text, link_text)
if 0:
print 'what:', repr(what)
print 'aname:', repr(aname)
self.body.append(what)
HTMLTranslator.depart_title(self, node)
示例2: depart_title
# 需要导入模块: from sphinx.writers.html import HTMLTranslator [as 别名]
# 或者: from sphinx.writers.html.HTMLTranslator import depart_title [as 别名]
def depart_title(self, node):
if node.parent.hasattr('ids') and node.parent['ids'] and \
self.section_level == 2:
print "TITLE",self.section_level,node.parent['ids'][0]
#self._title = node.parent['ids'][0]
self._title = striptags(''.join(self.body[1:]))
print "\t",str(node)[:50]
print "\tBODY", self.body[:4]
HTMLTranslator.depart_title(self, node)
示例3: depart_title
# 需要导入模块: from sphinx.writers.html import HTMLTranslator [as 别名]
# 或者: from sphinx.writers.html.HTMLTranslator import depart_title [as 别名]
def depart_title(self, node):
if self.current_slide and isinstance(node.parent, (nodes.section, slide)):
self.current_slide.title = "".join(self.body)
self.pop_body()
else:
HTMLTranslator.depart_title(self, node)
title = "".join(self.body)
self.pop_body()
self.body.append(title)
示例4: depart_title
# 需要导入模块: from sphinx.writers.html import HTMLTranslator [as 别名]
# 或者: from sphinx.writers.html.HTMLTranslator import depart_title [as 别名]
def depart_title(self, node):
if node.parent.hasattr("ids") and node.parent["ids"]:
aname = node.parent["ids"][0]
if self.builder.app.config.slide_link_to_html:
self.body.append(
u'<a class="headerlink" href="%s#%s" ' % (html.html_path(self.builder), aname)
+ u'title="%s">%s</a>' % (_("View HTML"), self.builder.app.config.slide_html_slide_link_symbol)
)
HTMLTranslator.depart_title(self, node)
示例5: depart_title
# 需要导入模块: from sphinx.writers.html import HTMLTranslator [as 别名]
# 或者: from sphinx.writers.html.HTMLTranslator import depart_title [as 别名]
def depart_title(self, node):
# print "--TITLE", node.text
if not self._title:
self._title = striptags(''.join(self.body[1:]))
print "\n\n**title", self.section_level, ''.join(self.body[1:])[:150]
low_level = self.section_level \
<= int(self.builder.config.mobi_chapter_level)
if node.parent.getattr('ids', False) and low_level:
print "TITLE", self.section_level, node.parent['ids'][0]
self._title = striptags(''.join(self.body[1:]))
print "\t", str(node)[:50]
print "\tBODY", self.body[:4]
else:
print "FALSE"
HTMLTranslator.depart_title(self, node)
示例6: depart_title
# 需要导入模块: from sphinx.writers.html import HTMLTranslator [as 别名]
# 或者: from sphinx.writers.html.HTMLTranslator import depart_title [as 别名]
def depart_title(self, node):
BaseTranslator.depart_title(self, node)
h_level = self.section_level + self.initial_header_level - 1
if h_level == 1: del self.body[1:]