def find_documented_methods()

in src/doc_builder/autodoc.py [0:0]


def find_documented_methods(clas):
    """
    Find all the public methods of a given class that have a nonempty documentation, filtering the methods documented
    the exact same way in a superclass.
    """
    public_attrs = {a: getattr(clas, a) for a in dir(clas) if not a.startswith("_")}
    public_methods = {a: m for a, m in public_attrs.items() if callable(m) and not isinstance(m, type)}
    documented_methods = {
        a: m for a, m in public_methods.items() if getattr(m, "__doc__", None) is not None and len(m.__doc__) > 0
    }

    superclasses = clas.mro()[1:]
    for superclass in superclasses:
        superclass_methods = {a: getattr(superclass, a) for a in documented_methods.keys() if hasattr(superclass, a)}
        documented_methods = {
            a: m
            for a, m in documented_methods.items()
            if (
                a not in superclass_methods
                or getattr(superclass_methods[a], "__doc__", None) is None
                or m.__doc__ != superclass_methods[a].__doc__
            )
        }
    return list(documented_methods.keys())