-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add class doc string to native_enum #5617
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
Conversation
include/pybind11/native_enum.h
Outdated
@@ -24,9 +24,10 @@ class native_enum : public detail::native_enum_data { | |||
|
|||
native_enum(const object &parent_scope, | |||
const char *name, | |||
const char *native_type_name = "enum.Enum") | |||
const char *native_type_name, | |||
const char *doc = "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by comment: Could you please use the same (longer) name consistently here and in native_enum_data.h?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Locally this test in assert m.member_doc.mem1.__doc__ == pure_native.mem.__doc__ It seems the class doc string is inherited (together with all public class methods) unless overridden in the value. |
I think we need to update the docs too? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@henryiii wrote: I think we need to update the docs too?
+1
An easy way to pin-point the documentation that needs to be tweaked is to look here:
https://github.com/pybind/pybind11/pull/5555/files
@@ -29,10 +29,12 @@ class native_enum_data { | |||
native_enum_data(const object &parent_scope, | |||
const char *enum_name, | |||
const char *native_type_name, | |||
const char *enum_doc, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're using "class doc" in the PR title and the added test: I think it's a much better name than enum_doc
here, because then it is crystal clear that it does not apply to the enum members. Could you please use class_doc
here (and in native_enum.h), too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dyollb for the work!
* add class doc string to native_enum * adapt doc argument name * fix test, make class enum doc None by default * fix other python versions? * make clang-tidy happy * rename 'enum_doc' to 'class_doc' * update documentation * [skip ci] Polish changed documentation (mostly done by ChatGPT). --------- Co-authored-by: Bryn Lloyd <[email protected]> Co-authored-by: Ralf W. Grosse-Kunstleve <[email protected]>
Description
Fixes #5615
Suggested changelog entry:
Add class doc string to `py::native_enum`