Skip to content

Commit ea7063a

Browse files
nedbatmerwokhugovk
authored
Avoid over-linking #1293 (#1294)
* Avoid over-linking * Update documentation/markup.rst Co-authored-by: Éric <[email protected]> * two updates from comments * update per ezio-melotti's comment #1294 (comment) * fix a sphinx lint failure * Update documentation/markup.rst Co-authored-by: Hugo van Kemenade <[email protected]> --------- Co-authored-by: Éric <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 45f7b02 commit ea7063a

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

documentation/markup.rst

+4
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,10 @@ versatile:
753753
In HTML output, the link's ``title`` attribute (that is e.g. shown as a
754754
tool-tip on mouse-hover) will always be the full target name.
755755

756+
* Combining ``~`` and ``!`` (for example, ``:meth:`~!Queue.Queue.get```) is not
757+
supported. You can obtain the same result by using ``!`` and the last
758+
component of the target (for example, ``:meth:`!get```).
759+
756760
The following roles refer to objects in modules and are possibly hyperlinked if
757761
a matching identifier is found:
758762

documentation/style-guide.rst

+29-1
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,39 @@ explanation.
127127
provide context, make connections between topics, and discuss alternative
128128
opinions. There is no section dedicated to explanations but these can be
129129
found throughout Python's documentation, for example the
130-
:ref:`python:unicode-howto`
130+
:ref:`python:unicode-howto`.
131131

132132
Please consult the `Diátaxis <https://diataxis.fr/>`_ guide for more
133133
detail.
134134

135+
Links
136+
=====
137+
138+
Links are a powerful tool for helping people navigate documentation and find
139+
more information, but links can be over-used. Links should be used only if
140+
they help the reader.
141+
142+
Generally, a link should be provided for the first use of a term in a unit,
143+
such as a section or paragraph. This is not a hard and fast rule. Sometimes
144+
the second mention is more appropriate for a link. Some units are long enough
145+
to have a few repeated links. Use judgement to decide when a link will help
146+
the reader.
147+
148+
Do not use a link when the link would point to the current unit. It's natural
149+
to use the name of a function in the documentation for the function, but a link
150+
on that function name that simply reloads the section the user is already
151+
reading is useless and distracting.
152+
153+
Do not use links in section headers. They distract from the title of the
154+
section. The term will be mentioned in the paragraph text and can be linked
155+
from there.
156+
157+
Sphinx provides ways to automatically add links to references, and a way to
158+
suppress the link. Using roles like ``:func:`map``` will link to the
159+
documentation for ``map``. You can suppress the link while keeping the
160+
semantic presentation of the function name by adding an exclamation point
161+
prefix: ``:func:`!map```. See :ref:`roles` for more details.
162+
135163
Affirmative tone
136164
================
137165

0 commit comments

Comments
 (0)