Can sphinx link to documents that are not located in directories below the root document?

前端 未结 6 1524
余生分开走
余生分开走 2020-12-02 10:22

I am using Sphinx to document a non-Python project. I want to distribute ./doc folders in each submodule, containing submodule_name.rst files to d

6条回答
  •  独厮守ぢ
    2020-12-02 10:54

    In conf.py, add the relative paths to system using sys.path and os.path

    For example:

    import os
    import sys
    
    sys.path.insert(0, os.path.abspath('..'))
    sys.path.insert(0, os.path.abspath('../../Directory1'))
    sys.path.insert(0, os.path.abspath('../../Directory2'))
    

    Then use your index.rst as usual, referencing the rst files in the same directory. So in my index.rst in my local Sphinx folder:

    Contents:
    
    .. toctree::
       :maxdepth: 4
    
       Package1 
       Package2 
       Package3 
    

    Then in package1.rst, you should be able to just reference the relative packages normally.

    Package1 package
    =====================
    
    Submodules
    ----------
    
    Submodule1 module
    ----------------------------------
    
    .. automodule:: file_within_directory_1
        :members:
        :undoc-members:
        :show-inheritance:
    
    Submodule1 module
    ----------------------------------
    
    .. automodule:: file_within_directory_2
        :members:
        :undoc-members:
        :show-inheritance:
    

提交回复
热议问题