Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sub folders and pdoc without __init__.py files #405

Closed
ferreteleco opened this issue Jun 10, 2022 · 1 comment
Closed

Sub folders and pdoc without __init__.py files #405

ferreteleco opened this issue Jun 10, 2022 · 1 comment
Labels

Comments

@ferreteleco
Copy link

Problem Description

Hi all! I've just discovered this awesome package and was giving it a try when I found something that doesn't fit (for me at least): I'm working on a project with many sub-folders inside without using init.py other than in the top level one. When I trigger pdoc, none of the sub-modules get documented. Including empty init.py files in each sub folder solves the problem, but I found it quite odd (since python does not need that in order to work properly).

Thanks in advance!

Steps to reproduce the behavior:

  1. Project with many sub-folders without init.py files
  2. Triggering pdoc does not generate documentation for files un those folders
  3. Including init.py files in each sub folder solves the problem

System Information

pdoc: 12.0.2
Python: 3.10.2
Platform: Linux-5.13.0-48-generic-x86_64-with-glibc2.31

@mhils
Copy link
Member

mhils commented Jun 10, 2022

The Python documentation states that __init__.py files are required:

The __init__.py files are required to make Python treat directories containing the file as packages.

A package directory without __init__.py is a PEP 420 "namespace package", not a regular package. See also https://dev.to/methane/don-t-omit-init-py-3hga, which is written by one of the CPython core developers.

I agree it's all a bit confusing, but for pdoc it boils down to the fact that pkgutil.walk_packages - which we use to discover packages - does not pick up namespace packages. See also: python/cpython#73444

Long story short, there's not much we can do here. I'd really recommend to add __init__.py files. As a workaround, you could maybe list all the sub-packages explicitly. Hope this helps!

@mhils mhils closed this as not planned Won't fix, can't repro, duplicate, stale Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants