@@ -1594,19 +1594,22 @@ struct enum_base {
1594
1594
}, name (" name" ), is_method (m_base)
1595
1595
);
1596
1596
1597
+ bool show_enum_members = options::show_enum_members_docstring ();
1597
1598
m_base.attr (" __doc__" ) = static_property (cpp_function (
1598
- [](handle arg) -> std::string {
1599
+ [show_enum_members ](handle arg) -> std::string {
1599
1600
std::string docstring;
1600
- dict entries = arg.attr (" __entries" );
1601
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);
1602
+ docstring += std::string (((PyTypeObject *) arg.ptr ())->tp_doc );
1603
+ if (show_enum_members) {
1604
+ docstring += " \n\n Members:" ;
1605
+ dict entries = arg.attr (" __entries" );
1606
+ for (auto kv : entries) {
1607
+ auto key = std::string (pybind11::str (kv.first ));
1608
+ auto comment = kv.second [int_ (1 )];
1609
+ docstring += " \n\n " + key;
1610
+ if (!comment.is_none ())
1611
+ docstring += " : " + (std::string) pybind11::str (comment);
1612
+ }
1610
1613
}
1611
1614
return docstring;
1612
1615
}, name (" __doc__" )
0 commit comments