当前位置: 首页>>代码示例>>Python>>正文


Python HTMLTranslator.visit_document方法代码示例

本文整理汇总了Python中sphinx.writers.html.HTMLTranslator.visit_document方法的典型用法代码示例。如果您正苦于以下问题:Python HTMLTranslator.visit_document方法的具体用法?Python HTMLTranslator.visit_document怎么用?Python HTMLTranslator.visit_document使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sphinx.writers.html.HTMLTranslator的用法示例。


在下文中一共展示了HTMLTranslator.visit_document方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: visit_document

# 需要导入模块: from sphinx.writers.html import HTMLTranslator [as 别名]
# 或者: from sphinx.writers.html.HTMLTranslator import visit_document [as 别名]
  def visit_document(self, node):
    SphinxHTMLTranslator.visit_document(self, node)

    # used to detect that bullet_lists are for the global and page tocs
    self.is_partial = node.get('source') == '<partial node>'
    self.page_toc_position = self.builder.config.html_theme_options.get(
      'page_toc_position', 'subnav')
    self.toc_nav = self.page_toc_position == 'nav'
    self.toc_subnav = self.page_toc_position == 'subnav'
    self.toc_sidebar = self.page_toc_position.startswith('sidebar-')

    self.page_toc_handled_first = False
    if self.toc_subnav:
      self.page_toc_maxdepth = 1
    else:
      self.page_toc_maxdepth = int(
        self.builder.config.html_theme_options.get('page_toc_maxdepth', '-1'))

    self.in_subnav = False
    if not self.is_partial and self.toc_subnav:
      docname = os.path.relpath(
        node['source'],
        self.builder.env.srcdir
      )

      suffixes = self.builder.config.source_suffix
      # retain backwards compatibility with sphinx < 1.3
      if isinstance(suffixes, basestring):
        suffixes = [suffixes]

      for suffix in suffixes:
        if docname.endswith(suffix):
          docname = docname[:-len(suffix)]
          break

      self.page_toc = self.builder.env.get_toc_for(docname, self.builder)

      toc_empty = bool(
        not len(self.page_toc.children) or
        len(self.page_toc.children[0].children) <= 1)
      if not toc_empty:
        toc_empty = True
        for child in self.page_toc.children[0].children[1]:
          if isinstance(child, nodes.list_item):
            toc_empty = False
            break

      if not toc_empty:
        # for page toc in the subnav, skip the first list
        self.page_toc = self.page_toc.children[0].children[1]
        self.page_toc['classes'].append('nav')
      else:
        self.page_toc = None
开发者ID:ervandew,项目名称:sphinx-bootstrap-theme,代码行数:55,代码来源:__init__.py


注:本文中的sphinx.writers.html.HTMLTranslator.visit_document方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。