Skip to content Skip to sidebar Skip to footer

Does Sphinx Run My Code On Executing 'make Html'?

I inherited a rather large codebase that I want to create HTML documentation for. Since it is written in Python I decided to use Sphinx because the users of the code are accustomed

Solution 1:

When using autodoc, Sphinx imports the documented modules, so all module-level code is executed. This happens every time you do "make html". In that sense, Sphinx does "run" your code.

You may have to organize your code a bit differently to make the errors go away (move module-level code to functions). See this question for an example of what can happen.

This is my guess but it may not be the whole story. It's hard to say more without additional information.


Solution 2:

def main():

    print('hello world')

if __name__ == '__main__':

    main()

This way your code will not be run.


Post a Comment for "Does Sphinx Run My Code On Executing 'make Html'?"