RTFM !
Warning: autodoc imports the modules to be documented. If any modules have side effects on import, these will be executed by autodoc when sphinx-build is run. If you document scripts (as opposed to library modules), make sure their main routine is protected by a if __name__ == '__main__' condition. So, if the __init__.py has active code, it is not possible to include in as autodoc ! ________________________________ De : [email protected] <[email protected]> de la part de andre seame <[email protected]> Envoyé : mardi 28 février 2017 17:28 À : [email protected]; [email protected] Objet : [sphinx-users] how to add doc into __init__.py where there is active code ? Hello, I have MyPackage __init__.py fct1.py fct2.py I use __init__.py to declare the public element of MyPackage: import fct1 as internal1 import fct2 as internal2 def fct1(): internal1.fct1() def fct2(): internal2.fct2() So, I add the sphinx commands: .. automodule:: MyPackage.fct1 :members: .. automodule:: MyPackage.fct2 :members: This works without any problem. In fact, there is a runtime iniatialization code in the __init__.py like: do_init_with_runtime_paramter(runtime_parameter) Now, when I generate the sphinx documentation, sphinx says: - Hello, I read the MyPackage.__init__.py file - Hello, I execute do_init_with_runtime_paramter(runtime_parameter) that fails because runtime_parameter is not defined ! The question is it possible to generate sphinx documentation where there is a __init__.py with active code ? Thanks, PHL. -- You received this message because you are subscribed to the Google Groups "sphinx-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]<mailto:[email protected]>. To post to this group, send email to [email protected]<mailto:[email protected]>. Visit this group at https://groups.google.com/group/sphinx-users. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sphinx-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sphinx-users. For more options, visit https://groups.google.com/d/optout.
