Skip to content

Automodule interprets the definition of descriptor types as attributes #1526

@shimizukawa

Description

@shimizukawa
  1. Create a descriptor type in a module

  2. create a document with

     .. automodule:: <module>
        :members:
        :show-inheritance:
    

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


Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions