How can I link/reference another reST file in the documentation?

前端 未结 4 982
我寻月下人不归
我寻月下人不归 2021-02-03 16:57

I have simply no idea on how can I link to another document in the reST file.

I want to link a file named install.rst to my quickstart guide in a paragraph.

相关标签:
4条回答
  • 2021-02-03 17:23

    Simplifying @eme-eme's answer, you can just do:

    :doc:`path/to/document`
    

    You don't need to enclose the path in <> and provide a text to be displayed. In this case, a top-level header from the referenced document will be displayed as a link.

    You don't need inter-sphinx extension for that.

    0 讨论(0)
  • 2021-02-03 17:32

    To create links between different reStructuredText (.rst) files you can use the inline markup provided by sphinx. See the documentation under the heading Cross-referencing documents

    on top of the file you define its label

    .. _my-reference-label:
    

    then you can link to it from other documents using

    :ref:`my-reference-label`.
    

    I do not believe you need to use the intersphinx extension, since it is for links between different projects. With this method you can link between different .rst files using their relative paths as described in the documentaion link above.

    0 讨论(0)
  • 2021-02-03 17:38

    To referecnce other files I had to include the following in the conf.py. I took the code from the docs of Pillow(PIL fork) here.

    extensions = ['sphinx.ext.intersphinx']
    

    I think the inter-sphinx extension came to my help. It linked across the other doc pages.

    0 讨论(0)
  • 2021-02-03 17:42

    I write the link to another document using this:

    :doc:`my document <../my_doc>` 
    

    ../my_doc is the path to my my_doc.rst file.

    I also have inter-sphinx extension in my conf.py file.

    extensions = ['sphinx.ext.intersphinx']
    
    0 讨论(0)
提交回复
热议问题