What is the proper way to hide imports from a documentation generator like pdoc?
Specifically, what is best practice for generating docs on adhoc scripts?
For example:
import someThirdPartyLibrary
def main():
someThirdPartyLibrary.somefunc()
if __name__ == '__main__':
main()
One needs to have someThirdPartyLibrary
installed in the environment or pdoc will FAIL.
The options seem to be:
A. Install all 3rd party libraries to whatever environment I'm running pdoc from. This seems totally unnecessary since pdoc doesn't need to actually run the code only load it.
B. Hide imports in main and violate PEP8
def main():
import someThirdPartyLibrary
someThirdPartyLibrary.somefunc()
if __name__ == '__main__':
main()
C. Something better than A and B that is best practice?
This may not be the answer you are looking for, but pdoc needs to import your code to parse out (dynamic) annotations. As such, I would really recommend to just go with option A: install all third-party libraries.