Adding a cross-reference to a subheading or anchor in another page

后端 未结 4 2042
-上瘾入骨i
-上瘾入骨i 2020-12-04 10:37

How to insert a cross-reference in a reST/Sphinx page to either a sub-header or anchor in another page in the same documentation set?

4条回答
  •  甜味超标
    2020-12-04 11:12

    New, better answer for 2016!

    The autosection extension lets you do this easily.

    =============
    Some Document
    =============
    
    
    Internal Headline
    =================
    

    then, later...

    ===============
    Some Other Doc
    ===============
    
    
    A link-  :ref:`Internal Headline`
    

    This extension is built-in, so all you need is to edit conf.py

    extensions = [
        .
        . other
        . extensions
        . already
        . listed
        .
        'sphinx.ext.autosectionlabel',
    ]
    

    The only thing you have to be careful of is that now you can't duplicate internal headlines across the doc collection. (Worth it.)

提交回复
热议问题