Skip to content
Merged
Changes from 5 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
68 changes: 46 additions & 22 deletions documentation/style-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,35 @@ of these entities are not assigned any special markup, but the preferred
spellings are given in :ref:`specific words` to aid authors in maintaining the
consistency of presentation in the Python documentation.


Use simple language
===================

Avoid esoteric phrasing where possible. Our audience is world-wide and may not
be native English speakers.

Don't use Latin abbreviations like "e.g." or "i.e." where English words will do,
such as "for example" or "that is."


Charged terminology to avoid
============================

Avoid terminology that may be considered insensitive or exclusionary.

.. list-table::
:header-rows: 1

* - Avoid
- Instead
* - whitelist
- allowlist
* - blacklist
- blocklist, denylist
* - master/slave
- main, parent/child, server/client, primary/secondary


.. _specific words:

Specific words
Expand Down Expand Up @@ -116,32 +145,25 @@ Unix
1970s.


Use simple language
===================
Type names
==========

Avoid esoteric phrasing where possible. Our audience is world-wide and may not
be native English speakers.

Don't use Latin abbreviations like "e.g." or "i.e." where English words will do,
such as "for example" or "that is."


Charged terminology to avoid
============================
When writing the names of types in prose, write the name of the type
exactly as it appears in source, styled as a class reference or an unlinked
class. For example, refer to dict as ``:class:`dict`‌`` or ``:class:`!dict`‌``.

Avoid terminology that may be considered insensitive or exclusionary.
Links should be used according to the :ref:`guidance on links <style-guide-links>`.

.. list-table::
:header-rows: 1
Some type names are commonly understood ideas or nouns outside of Python.
For example, "tuples" are a general programming concept, as distinct from the
``tuple`` type. When referring to general ideas, do not style the relevant word
as a type.

* - Avoid
- Instead
* - whitelist
- allowlist
* - blacklist
- blocklist, denylist
* - master/slave
- main, parent/child, server/client, primary/secondary
Many types have descriptive names which do not exactly match their type
name. For example, "context variables" describes ``contextvars.ContextVar``,
and "partial function" may be used to describe an application of
``functools.partial``. Use these names only when they serve to clarify the text
better than the type name itself would, and put them in lowercase.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In line with my comment on the issue, could we add:

Python classes can also be discussed not as linked classes, but as concepts or with descriptive names. For example, a long discussion of dictionaries won't use dict everywhere. Sometimes "dict" or "dictionary" will feel more natural. The author will need to exercise judgement when to use class links and when to use descriptive names.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this proposed text, but feel that it has a degree of overlap with the last paragraph.

I'm going to try to integrate the two but intend to append this if I can't figure out a good combination.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The style guide as a whole could use a PEP-8 style note:

know when to be inconsistent – sometimes style guide recommendations just aren’t applicable. When in doubt, use your best judgment. Look at other examples and decide what looks best. And don’t hesitate to ask!


Specifically for class names in long discussion, perhaps this could mirror the guidance on links. The first occurrence should use :class:; subsequent ones can use plain words if it's clear that it's still talking about the same thing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made an edit to weave these suggestions into the text, which required a little tuning of the first paragraph in addition to a larger change to the last.

The part which is most different from Ned's suggestion is this:

Once it is clear that the text refers to a specific type, use the naming which suits the context: in the case of dict, any of "dict", "dictionary", or "``:class:`dict```" may be best.

I mean for that to carry the message about "the author will need to exercise judgement" as well as the idea that, like links, you should first clarify the exact type and then exercise more freedom in how you write.

I'm very concerned with brevity for these docs, so I was trying to pack the ideas in very tightly, in the smallest reasonable number of words.



.. index:: diataxis
Expand Down Expand Up @@ -190,6 +212,8 @@ Please consult the `Diátaxis <https://diataxis.fr/>`__ guide for more
detail.


.. _style-guide-links:

Links
=====

Expand Down
Loading