Skip to content

Commit c36a03f

Browse files
authored
Merge pull request #26405 from timhoffm/doc-ref
DOC: Clarify the difference between document and section references
2 parents 8c58e42 + eae95fc commit c36a03f

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

doc/devel/document.rst

+18-3
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,24 @@ nor the ````literal```` role:
194194
Refer to other documents and sections
195195
-------------------------------------
196196

197-
Sphinx_ allows internal references_ between documents.
197+
Sphinx_ supports internal references_:
198198

199-
Documents can be linked with the ``:doc:`` directive:
199+
========== =============== ===========================================
200+
Role Links target Representation in rendered HTML
201+
========== =============== ===========================================
202+
|doc-dir|_ document link to a page
203+
|ref-dir|_ reference label link to an anchor associated with a heading
204+
========== =============== ===========================================
205+
206+
.. The following is a hack to have a link with literal formatting
207+
See https://stackoverflow.com/a/4836544
208+
209+
.. |doc-dir| replace:: ``:doc:``
210+
.. _doc-dir: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-doc
211+
.. |ref-dir| replace:: ``:ref:``
212+
.. _ref-dir: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-ref
213+
214+
Examples:
200215

201216
.. code-block:: rst
202217
@@ -214,7 +229,7 @@ will render as:
214229

215230
See the example :doc:`/gallery/lines_bars_and_markers/simple_plot`
216231

217-
Sections can also be given reference names. For instance from the
232+
Sections can also be given reference labels. For instance from the
218233
:doc:`/users/installing/index` link:
219234

220235
.. code-block:: rst

0 commit comments

Comments
 (0)