如何移除Sphinx索引页面底部重复的toc?
解决Sphinx文档重复TOC问题
你遇到的重复TOC问题,根源在于代码里同时做了两件事:
- 用
.. include:: readme.rst将readme内容直接嵌入首页 - 在Introduction的toctree中添加了
readme条目
这导致readme相关内容被渲染了两次,进而出现重复的TOC。可以通过以下两种方式解决:
方案一:保留toctree的readme入口,移除直接嵌入的语句
修改后的index.rst代码如下:
Welcome to the documentation! ============================= .. _INTRODUCTION:: .. toctree:: :maxdepth: 1 :caption: Introduction readme .. toctree:: :maxdepth: 1 :caption: Contents: gazetimation Indices and tables ================== * :ref:`genindex`
方案二:保留首页嵌入readme内容,移除toctree中的readme条目
修改后的index.rst代码如下:
Welcome to the documentation! ============================= .. include:: readme.rst .. _INTRODUCTION:: .. toctree:: :maxdepth: 1 :caption: Introduction .. toctree:: :maxdepth: 1 :caption: Contents: gazetimation Indices and tables ================== * :ref:`genindex`
内容的提问来源于stack exchange,提问作者shuvo
相关产品推荐
相关产品推荐

