【问题标题】:toctree nested drop down目录树嵌套下拉
【发布时间】:2016-04-28 21:34:00
【问题描述】:

我的 index.rst 中有一个目录树,看起来像这样:

.. toctree::
   :maxdepth: 2

   cat
   dog
   moose

我希望嵌套我的 toctree 的内容,类似于 here 使用 'api 文档':

所以最终做出这样的事情:

.. toctree::
   :maxdepth: 2
   :dropdown Animals
     cat
     dog
     moose

但我似乎在文档中找不到任何这样做的东西。

【问题讨论】:

    标签: python python-sphinx toctree


    【解决方案1】:

    侧边栏中目录树的这种行为是阅读文档主题 (https://github.com/snide/sphinx_rtd_theme) 的一项功能

    pip install sphinx-rtd-theme安装它

    主题具有选项collapse_navigation,用于控制在导航到文档的另一部分时是否自动折叠树。

    # -- Options for HTML output ----------------------------------------------
    
    # The theme to use for HTML and HTML Help pages.  See the documentation for
    # a list of builtin themes.
    html_theme = 'sphinx_rtd_theme'
    
    # Theme options are theme-specific and customize the look and feel of a theme
    # further.  For a list of options available for each theme, see the
    # documentation.
    html_theme_options = {
        "collapse_navigation" : False
    }
    

    indexr.rst:

    #################
      Title
    #################
    
    Animals
    =======
    
    .. toctree::
       :maxdepth: 2
    
        animals/index
    
    Flowers
    =======
    
    .. toctree::
       :maxdepth: 2
    
       flowers/index
    

    动物/index.rst:

    ####################
      Animals
    ####################
    
    .. toctree::
       :maxdepth: 2
    
       cat
       dog
       moose
    

    【讨论】:

    • 感谢您的回答,但我认为您错误地识别了我的问题,我想知道如何编写目录树规则以实际进行类似于示例中的下拉菜单。 :dropdown Animals 命令不正确。我想设置下拉到真实文档页面的任意组部分
    • 此主题不支持备用目录树行为,因为我看不到文档中列出的任何配置选项。可以分叉主题本身并维护自定义代码来解决这个问题。 sphinx-rtd-theme.readthedocs.io/en/latest/configuring.html
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-20
    • 2020-07-29
    • 1970-01-01
    • 1970-01-01
    • 2019-01-23
    • 2021-02-12
    • 1970-01-01
    相关资源
    最近更新 更多