You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a package which contains a command line tool. Thus, for convenience, I have a __main__.py module, to allow to "execute" my package with python -m. That module simply runs the main() function defined elsewhere.
Because pdoc imports all the modules to extract documentation, it actually executes my main function (which starts the tool), obviously causing errors.
Proposal
I suggest that pdoc skips all the __main__.py modules. Or, even better, that an option to choose is added.
The __main__.py modules are added for the sole purpose of making a package "excutable", therefore are not likely to contain useful API documentation.
Alternatives
The issue could probably be circumvented with the guard if __name__ == "__main__" in __main__.py
However, that "if" is not necessary for the regular usage of the package, and the docs also suggest that.
We should not need to change working source code in order to make pdoc work.
Thank you
The text was updated successfully, but these errors were encountered:
Thanks for the pointer to the official docs, I somehow thought that __main__.py files should also have if __name__ == "__main__" guards. If the docs say that's not necessary we should absolutely respect that and ignore those files by default.
Problem Description
I have a package which contains a command line tool. Thus, for convenience, I have a
__main__.py
module, to allow to "execute" my package withpython -m
. That module simply runs themain()
function defined elsewhere.Because pdoc imports all the modules to extract documentation, it actually executes my main function (which starts the tool), obviously causing errors.
Proposal
I suggest that pdoc skips all the
__main__.py
modules. Or, even better, that an option to choose is added.The
__main__.py
modules are added for the sole purpose of making a package "excutable", therefore are not likely to contain useful API documentation.Alternatives
The issue could probably be circumvented with the guard
if __name__ == "__main__"
in__main__.py
However, that "if" is not necessary for the regular usage of the package, and the docs also suggest that.
We should not need to change working source code in order to make pdoc work.
Thank you
The text was updated successfully, but these errors were encountered: