Skip to content

[BUG]: the new native_enum does not support class doc strings #5615

Closed
@dyollb

Description

@dyollb

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

master

Problem description

py::enum_ supported class docstrings (as did boost::python::enum_). It would be nice if the new py::native_enum would support class docstrings.

Since the native enum type (a string) is optional, converting my code to use thew new native_enum forced me to review each instance, since by default my docstrings were interpreted as the native enum. Maybe the native enum could be an enum or a class type, so we could have a constructor like

template <typename... Extra>
native_enum(const object &parent_scope,
                const char *name,
                const Extra &...extra)

where the extra arguments could be a docstring and/or a native enum.

This would allow a "complete" replacement and less error-prone conversion to the new native_enum. An alternative could be to add a method native_enum::set_doc(const char* doc).

Reproducible example code


Is this a regression? Put the last known working version here if it is.

Not a regression

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNew bug, unverified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions