pdoc3 / pdoc

:snake: :arrow_right: :scroll: Auto-generate API documentation for Python projects
https://pdoc3.github.io/pdoc/
GNU Affero General Public License v3.0
1.12k stars 145 forks source link

added support for nested classes; this is basically a newer version o… #390

Open frank101010 opened 2 years ago

frank101010 commented 2 years ago

Adds support for nested classes to pdoc3.

This is basically a newer version of angeloskath's commit 467350c12894e66d45151e274db79e2cb7df5906, https://github.com/pdoc3/pdoc/pull/176, but since I need support for nested classes, and the original merge request hasn't changed status since June 2020, I decided to apply most of angeloskath's changes into a branch derived from the most recent master.

(deleted section about unit test problems, which were resolved after running tests on an os supporting symbolic links)

frank101010 commented 2 years ago

@kernc: you might want to wait with the next review, I've discovered a problem regarding warnings being issued, which I've already resolved. But there are also cases where member types are not properly rendered as hyperlinks in html output. The latter problem is due to the usage of inspect.formatannotations(), which does not format built-in container types like dict[str, int] properly (works with typing.Dict[str. int], though); but I'm going to create a new pull request for this.

frank101010 commented 2 years ago

@kernc: I just pushed new changes which fix a problem nested classes being recognized as pdoc.External instead of pdoc.Class. This required adding the nested classes into pdoc.Module's context. Unfortunately, this also breaks one unit test, namely ApiTest.test__all__. Since I don't really understand how that test works, could you please have a look at it?

kernc commented 2 years ago

The test tries to ensure that only the identifiers in __all__ are exposed. Interestingly, I'm not sure where the value 'B.B.C' comes from. I'd understand 'B.C' since that's what's nested. :thinking: https://github.com/pdoc3/pdoc/blob/2cce30a9b55eeeddc1ed826c8a2ada53777c3eea/pdoc/test/example_pkg/__init__.py#L111-L112

JPHutchins commented 9 months ago

@frank101010 @kernc Is this good to go? I require this functionality and can work on the PR by reopening on my own fork if you don't have time.

Thanks, JP