python-sphinx - 仅侧边栏中的 Sphinx 目录树
问题描述
我是 Sphinx 的新手,一段时间以来一直在寻找这个问题的解决方案。
我的索引页面由 index.rst 组成,其中包含一个目录树。该页面在正文和侧边栏中显示 TOC。我只想在侧边栏上显示目录,而不是在每个页面正文中输入一些文本。特别是主要的“Welcome to My Place”,目前index.html和index.rst应该只是一段blurb而不是TOC。
我试过这个:
Welcome to My Place
==================
.. toctree::
:hidden:
:maxdepth: 2
:caption: Contents:
但这会从页面和侧边栏中删除目录。我怎样才能让它工作?
编辑:这是它的显示方式,我希望 TOC 只出现在侧边栏中。 截屏
解决方案
您可以通过包含一个单独的文件来执行此操作,并将conf.py 中toctree
的变量指向该文件。master_doc
conf.py
# ...
master_doc = "contents"
# ...rest of the document
contents.rst
.. toctree::
example
index.rst
# Landing Page
Welcome!
推荐阅读
- symfony - 包学说/反射被放弃
- html - 文本高度与图像比较
- html - 隐藏文件输入上的标签要垂直对齐
- python - for 循环:为列表中的每个元素运行一个函数,确定 7 天的范围
- javascript - 如何仅在时钟到达特定时间时运行 Chrome 扩展程序
- javascript - Angular中多个HTTP请求的最佳方式
- c - 搜索到链表
- javascript - 未捕获的类型错误:如何修复 jQuery 冲突?
- sql - 在一行中显示一对多关系
- powershell - 复制文件夹时出错!使用“0”参数调用“ExecuteQuery”的异常:“远程服务器返回错误:(400) 错误请求。”