Skip to content

Avoid over-linking #1293 #1294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions documentation/markup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,10 @@ versatile:
In HTML output, the link's ``title`` attribute (that is e.g. shown as a
tool-tip on mouse-hover) will always be the full target name.

* Combining ``~`` and ``!`` (for example, ``:meth:`~!Queue.Queue.get```) is not
supported. You can obtain the same result by using ``!`` and the last
component of the target (for example, ``:meth:`!get```).

The following roles refer to objects in modules and are possibly hyperlinked if
a matching identifier is found:

Expand Down
30 changes: 29 additions & 1 deletion documentation/style-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,39 @@ explanation.
provide context, make connections between topics, and discuss alternative
opinions. There is no section dedicated to explanations but these can be
found throughout Python's documentation, for example the
:ref:`python:unicode-howto`
:ref:`python:unicode-howto`.

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

Links
=====

Links are a powerful tool for helping people navigate documentation and find
more information, but links can be over-used. Links should be used only if
they help the reader.

Generally, a link should be provided for the first use of a term in a unit,
such as a section or paragraph. This is not a hard and fast rule. Sometimes
the second mention is more appropriate for a link. Some units are long enough
to have a few repeated links. Use judgement to decide when a link will help
the reader.

Do not use a link when the link would point to the current unit. It's natural
to use the name of a function in the documentation for the function, but a link
on that function name that simply reloads the section the user is already
reading is useless and distracting.

Do not use links in section headers. They distract from the title of the
section. The term will be mentioned in the paragraph text and can be linked
from there.

Sphinx provides ways to automatically add links to references, and a way to
suppress the link. Using roles like ``:func:`map``` will link to the
documentation for ``map``. You can suppress the link while keeping the
semantic presentation of the function name by adding an exclamation point
prefix: ``:func:`!map```. See :ref:`roles` for more details.

Affirmative tone
================

Expand Down
Loading