17.3 Using Sphinx autodoc to create the API reference
One of the huge strengths of Sphinx is being able to generate the API documentation using the autodoc extension. A series of commands can extract the docstrings from modules, classes, functions, and methods. Options are available to fine-tune exactly what members are included or excluded.
We’ll refer back to Chapter 7, the Extending a built-in collection – a list that does statistics recipe. In there is this Statslist class:
class StatsList(list[float]):
def sum(self) -> float:
return sum(v for v in self)
def size(self) -> float:
return sum(1 for v in self)
def mean(self) -> float:
return self.sum() / self.size() ...