Skip to content

Commit 1e013ff

Browse files
Nícolas F. R. A. PradoJonathan Corbet
authored andcommitted
docs: Document cross-referencing using relative path
Update the Cross-referencing section to explain how to create a cross-reference to a document using relative paths and with no additional syntax, by relying on automarkup.py. Signed-off-by: Nícolas F. R. A. Prado <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Corbet <[email protected]>
1 parent ea1d838 commit 1e013ff

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

Documentation/doc-guide/sphinx.rst

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -340,16 +340,26 @@ Rendered as:
340340
Cross-referencing
341341
-----------------
342342

343-
Cross-referencing from one documentation page to another can be done by passing
344-
the path to the file starting from the Documentation folder.
345-
For example, to cross-reference to this page (the .rst extension is optional)::
346-
347-
See Documentation/doc-guide/sphinx.rst.
348-
349-
If you want to use a relative path, you need to use Sphinx's ``doc`` directive.
350-
For example, referencing this page from the same directory would be done as::
351-
352-
See :doc:`sphinx`.
343+
Cross-referencing from one documentation page to another can be done simply by
344+
writing the path to the document file, no special syntax required. The path can
345+
be either absolute or relative. For absolute paths, start it with
346+
"Documentation/". For example, to cross-reference to this page, all the
347+
following are valid options, depending on the current document's directory (note
348+
that the ``.rst`` extension is required)::
349+
350+
See Documentation/doc-guide/sphinx.rst. This always works.
351+
Take a look at sphinx.rst, which is at this same directory.
352+
Read ../sphinx.rst, which is one directory above.
353+
354+
If you want the link to have a different rendered text other than the document's
355+
title, you need to use Sphinx's ``doc`` role. For example::
356+
357+
See :doc:`my custom link text for document sphinx <sphinx>`.
358+
359+
For most use cases, the former is preferred, as it is cleaner and more suited
360+
for people reading the source files. If you come across a ``:doc:`` usage that
361+
isn't adding any value, please feel free to convert it to just the document
362+
path.
353363

354364
For information on cross-referencing to kernel-doc functions or types, see
355365
Documentation/doc-guide/kernel-doc.rst.

0 commit comments

Comments
 (0)