@@ -556,7 +556,7 @@ The binding code for this example looks as follows:
556556 .def_readwrite("type", &Pet::type)
557557 .def_readwrite("attr", &Pet::attr);
558558
559- py::native_enum<Pet::Kind>(pet, "Kind")
559+ py::native_enum<Pet::Kind>(pet, "Kind", "enum.Enum" )
560560 .value("Dog", Pet::Kind::Dog)
561561 .value("Cat", Pet::Kind::Cat)
562562 .export_values()
@@ -593,16 +593,20 @@ once. To achieve this, ``py::native_enum`` acts as a buffer to collect the
593593name/value pairs. The ``.finalize() `` call uses the accumulated name/value
594594pairs to build the arguments for constructing a native Python enum type.
595595
596- The ``py::native_enum `` constructor supports a third optional
597- ``native_type_name `` string argument, with default value ``"enum.Enum" ``.
598- Other types can be specified like this:
596+ The ``py::native_enum `` constructor takes a third argument,
597+ ``native_type_name ``, which specifies the fully qualified name of the Python
598+ base class to use — e.g., ``"enum.Enum" `` or ``"enum.IntEnum" ``. A fourth
599+ optional argument, ``class_doc ``, provides the docstring for the generated
600+ class.
601+
602+ For example:
599603
600604.. code-block :: cpp
601605
602- py::native_enum<Pet::Kind>(pet, "Kind", "enum.IntEnum")
606+ py::native_enum<Pet::Kind>(pet, "Kind", "enum.IntEnum", "Constant specifying the kind of pet" )
603607
604- Any fully- qualified Python name can be specified. The only requirement is
605- that the named type is similar to
608+ You may use any fully qualified Python name for `` native_type_name ``.
609+ The only requirement is that the named type is similar to
606610`enum.Enum <https://docs.python.org/3/library/enum.html#enum.Enum >`_
607611in these ways:
608612
0 commit comments