You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected: documents the class as a class, documents its members and shows its inheritance
Observed: documents the class as an attribute, just shows its docstring
Problem source
AttributeDocumenter has a higher priority than ClassDocumenter and if the member being checked (in can_document_member) is a descriptor all other checks are ignored
Partial solution
put the isdatatesc check under not isinstance(parent, ModuleDocumenter) somehow: descriptors don't work at the module-level (save through shenanigans of explicitly creating a ModuleType subclass and shoving it into sys.modules by hand)
Issue remaining
defining a descriptor type as an inner class will still be incorrectly documented as an attribute
Alternative solution
Add not isinstance(member, class_types) in the decision tree for isdatadesc
However, I do see a slightly more complex bug. If the descriptor type has a metaclass (like, say, abc.ABCMeta), the issue reappears. This is apparently because the pull request compares the __name__ of the type() of the thing being documented (i.e. member) to (among other things) "type". Since metaclasses can have arbitrary names, it is not at all obvious how this approach can be generalized. I'd recommend replacing the string compare with a isinstance(member, type) check or something similar.
Create a descriptor type in a module
create a document with
Expected: documents the class as a class, documents its members and shows its inheritance
Observed: documents the class as an attribute, just shows its docstring
Problem source
AttributeDocumenter
has a higher priority thanClassDocumenter
and if the member being checked (incan_document_member
) is a descriptor all other checks are ignoredPartial solution
put the
isdatatesc
check undernot isinstance(parent, ModuleDocumenter)
somehow: descriptors don't work at the module-level (save through shenanigans of explicitly creating aModuleType
subclass and shoving it intosys.modules
by hand)Issue remaining
defining a descriptor type as an inner class will still be incorrectly documented as an attribute
Alternative solution
Add
not isinstance(member, class_types)
in the decision tree forisdatadesc
The text was updated successfully, but these errors were encountered: