How can I link the generated index page in ReadTheDocs navigation bar?

前端 未结 1 1598
暖寄归人
暖寄归人 2021-01-06 02:09

I\'m creating my documentation with Sphinx on ReadTheDocs, using their theme. The build process generates a genindex.html file, which can be referenced with:



        
相关标签:
1条回答
  • 2021-01-06 02:29

    As far as no one posts a better solution, I'll write down my workaround as a working solution.


    Sphinx creates the index as a denindex.html in the build root directory. It can't be referenced in a toctree directive, because this directive references ReST files. So how to solve it?

    So let's create a genindex.rst file and reference it from a toctree directive. This also creates a genindex.html in the build root directory. All links are created as expected. The genindex.html file needs to define a headline like "Index", which is used as a link title in the navigation bar.

    After writing all HTML files from ReST files, Sphinx generates its index and overwrites genindex.html.

    Source files:

    Source file index.rst:

    .. toctree::
       :caption: Introduction
    
       chapter1
       chapter2
    
    .. toctree::
       :caption: Main Documentation
    
       chapter3
       chapter4
    
    .. toctree::
       :caption: Appendix
    
       genindex
    

    Source files genindex.rst:

    .. This file is a placeholder and will be replaced
    
    Index
    #####
    

    Navigation Bar Screenshot:

    0 讨论(0)
提交回复
热议问题