@@ -1594,23 +1594,25 @@ struct enum_base {
15941594 }, name (" name" ), is_method (m_base)
15951595 );
15961596
1597- m_base.attr (" __doc__" ) = static_property (cpp_function (
1598- [](handle arg) -> std::string {
1599- std::string docstring;
1600- dict entries = arg.attr (" __entries" );
1601- if (((PyTypeObject *) arg.ptr ())->tp_doc )
1602- docstring += std::string (((PyTypeObject *) arg.ptr ())->tp_doc ) + " \n\n " ;
1603- docstring += " Members:" ;
1604- for (auto kv : entries) {
1605- auto key = std::string (pybind11::str (kv.first ));
1606- auto comment = kv.second [int_ (1 )];
1607- docstring += " \n\n " + key;
1608- if (!comment.is_none ())
1609- docstring += " : " + (std::string) pybind11::str (comment);
1610- }
1611- return docstring;
1612- }, name (" __doc__" )
1613- ), none (), none (), " " );
1597+ if (options::show_enum_members_docstring ()) {
1598+ m_base.attr (" __doc__" ) = static_property (cpp_function (
1599+ [](handle arg) -> std::string {
1600+ std::string docstring;
1601+ dict entries = arg.attr (" __entries" );
1602+ if (((PyTypeObject *) arg.ptr ())->tp_doc )
1603+ docstring += std::string (((PyTypeObject *) arg.ptr ())->tp_doc ) + " \n\n " ;
1604+ docstring += " Members:" ;
1605+ for (auto kv : entries) {
1606+ auto key = std::string (pybind11::str (kv.first ));
1607+ auto comment = kv.second [int_ (1 )];
1608+ docstring += " \n\n " + key;
1609+ if (!comment.is_none ())
1610+ docstring += " : " + (std::string) pybind11::str (comment);
1611+ }
1612+ return docstring;
1613+ }, name (" __doc__" )
1614+ ), none (), none (), " " );
1615+ }
16141616
16151617 m_base.attr (" __members__" ) = static_property (cpp_function (
16161618 [](handle arg) -> dict {
0 commit comments