I am trying to do python documentation generation with Sphinx. The problem is that sphinx-build ends up executing the module/evaluating anything in global scope. Is there a reason it does this? And does anyone know of a flag that can be set to disable this?
It seems like Sphinx is trying to do code-coverage or something equivalent, which is definitely not what I want it doing. Normally this wouldn't be an issue, but a particular set of modules are very specific to an environment.
Sphinx evaluates everything in the global scope because the autodoc plugin imports modules, and importing a module evaluates everything in the global scope.
To stop this, either:
autodoc
in the sphinx config file), orif __name__ == "__main__": do_stuff()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With