pdoc
pdoc copied to clipboard
classmethods documented as a static method
Expected Behavior

Actual Behavior

Steps to Reproduce
Example code:
import documentation_test.submod1.submod1 as submod1
import documentation_test.submod2.submod2 as submod2
__all__ = ['testFunction', 'testClass']
class testClass(object):
"""Summary of class
Attributes
----------
arg : str
a string to print
"""
def __init__(self, arg: str):
"""Summary of init
Parameters
----------
arg : str, optional
a string to print
"""
super(testClass, self).__init__()
self.arg = arg
@classmethod
def createString(cls, aString: str):
"""create a string
Parameters
----------
aString : str
a string to print
"""
return cls(arg=aString)
def printString(self):
"""Print a string
"""
print(self.arg)
def testFunction(anything: str = 'test') -> None:
"""test function for a demo import of whole module
Parameters
----------
anything : str, optional
a test string
Returns
-------
None
"""
print(anything)
submod1.submod1('string from submod1 in base')
submod2.submod2('string from submod2 in base')
Command ran: pdoc --config show_type_annotations=True --html src/documentation_test --force
Additional info
- pdoc version: 0.7.2
- python 3.8
Not sure if this is intentional or I have done something nonstandard. No matter what I try; class in a submodule, class with both static and class methods, etc. I get the same result.
In a way it's intentional. pdoc.Function has historically only known functions and methods.
https://github.com/pdoc3/pdoc/blob/3a5e1d1241562691cb64584add3c8ed647ea2505/pdoc/init.py#L1028-L1033
The unbound functions are simplified into "Static methods" because they behave like so. I guess calling them "Functions" could be just as good.
I'm more confused that is it intentional, as a static method can’t access or modify class state - labeling a class method this way seems unintuative.
Agreed. If you'd like to propose a patch to fix this, it should be reviewed favorably.