doc: Improve autodoc extension example

Enumerations can have aliases, which should be documented as well.
This commit is contained in:
Jouke Witteveen
2021-12-06 12:31:09 +01:00
committed by GitHub
parent edd14783f3
commit e200e7b7c1

View File

@@ -39,14 +39,13 @@ class IntEnumDocumenter(ClassDocumenter):
use_hex = self.options.hex
self.add_line('', source_name)
for enum_value in enum_object:
the_value_name = enum_value.name
the_value_value = enum_value.value
for the_member_name, enum_member in enum_object.__members__.items():
the_member_value = enum_member.value
if use_hex:
the_value_value = hex(the_value_value)
the_member_value = hex(the_member_value)
self.add_line(
f"**{the_value_name}**: {the_value_value}", source_name)
f"**{the_member_name}**: {the_member_value}", source_name)
self.add_line('', source_name)