Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-110679: Improved markup in enum.rst #110747

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 5 commits into from
Oct 25, 2023
Merged
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
30 changes: 15 additions & 15 deletions Doc/library/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Data Types
to subclass *EnumType* -- see :ref:`Subclassing EnumType <enumtype-examples>`
for details.

*EnumType* is responsible for setting the correct :meth:`!__repr__`,
``EnumType`` is responsible for setting the correct :meth:`!__repr__`,
:meth:`!__str__`, :meth:`!__format__`, and :meth:`!__reduce__` methods on the
final *enum*, as well as creating the enum members, properly handling
duplicates, providing iteration over the enum class, etc.
Expand Down Expand Up @@ -406,7 +406,7 @@ Data Types

.. class:: IntEnum

*IntEnum* is the same as *Enum*, but its members are also integers and can be
*IntEnum* is the same as :class:`Enum`, but its members are also integers and can be
used anywhere that an integer can be used. If any integer operation is performed
with an *IntEnum* member, the resulting value loses its enumeration status.

Expand Down Expand Up @@ -437,7 +437,7 @@ Data Types

.. class:: StrEnum

*StrEnum* is the same as *Enum*, but its members are also strings and can be used
``StrEnum`` is the same as :class:`Enum`, but its members are also strings and can be used
in most of the same places that a string can be used. The result of any string
operation performed on or with a *StrEnum* member is not part of the enumeration.

Expand Down Expand Up @@ -576,7 +576,7 @@ Data Types

.. class:: IntFlag

*IntFlag* is the same as *Flag*, but its members are also integers and can be
``IntFlag`` is the same as :class:`Flag`, but its members are also integers and can be
used anywhere that an integer can be used.

>>> from enum import IntFlag, auto
Expand All @@ -596,12 +596,12 @@ Data Types
>>> Color.RED + 2
3

If a *Flag* operation is performed with an *IntFlag* member and:
If a :class:`Flag` operation is performed with an *IntFlag* member and:

* the result is a valid *IntFlag*: an *IntFlag* is returned
* the result is not a valid *IntFlag*: the result depends on the *FlagBoundary* setting
* the result is not a valid *IntFlag*: the result depends on the :class:`FlagBoundary` setting

The *repr()* of unnamed zero-valued flags has changed. It is now:
The :func:`repr()` of unnamed zero-valued flags has changed. It is now:

>>> Color(0)
<Color: 0>
Expand Down Expand Up @@ -697,7 +697,7 @@ Data Types

.. class:: FlagBoundary

*FlagBoundary* controls how out-of-range values are handled in *Flag* and its
``FlagBoundary`` controls how out-of-range values are handled in :class:`Flag` and its
subclasses.

.. attribute:: STRICT
Expand All @@ -720,7 +720,7 @@ Data Types

.. attribute:: CONFORM

Out-of-range values have invalid values removed, leaving a valid *Flag*
Out-of-range values have invalid values removed, leaving a valid :class:`Flag`
value::

>>> from enum import Flag, CONFORM, auto
Expand All @@ -734,7 +734,7 @@ Data Types

.. attribute:: EJECT

Out-of-range values lose their *Flag* membership and revert to :class:`int`.
Out-of-range values lose their :class:`Flag` membership and revert to :class:`int`.

>>> from enum import Flag, EJECT, auto
>>> class EjectFlag(Flag, boundary=EJECT):
Expand All @@ -747,7 +747,7 @@ Data Types

.. attribute:: KEEP

Out-of-range values are kept, and the *Flag* membership is kept.
Out-of-range values are kept, and the :class:`Flag` membership is kept.
This is the default for :class:`IntFlag`::

>>> from enum import Flag, KEEP, auto
Expand Down Expand Up @@ -809,10 +809,10 @@ Utilities and Decorators
.. class:: auto

*auto* can be used in place of a value. If used, the *Enum* machinery will
call an *Enum*'s :meth:`~Enum._generate_next_value_` to get an appropriate value.
For *Enum* and *IntEnum* that appropriate value will be the last value plus
one; for *Flag* and *IntFlag* it will be the first power-of-two greater
than the highest value; for *StrEnum* it will be the lower-cased version of
call an :class:`Enum`'s :meth:`~Enum._generate_next_value_` to get an appropriate value.
For :class:`Enum` and :class:`IntEnum` that appropriate value will be the last value plus
one; for :class:`Flag` and :class:`IntFlag` it will be the first power-of-two greater
than the highest value; for :class:`StrEnum` it will be the lower-cased version of
the member's name. Care must be taken if mixing *auto()* with manually
specified values.

Expand Down