3

Is there a way, ideally using autodoc, to get sphinx to document a Python script? The section of the script I want documented is the portion protected by:

if __name__ == '__main__':

i.e. the bit that only runs if the module is used as a script instead of being imported.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Papadeltasierra
  • 233
  • 1
  • 9

1 Answers1

4

You should extract the code in that block into a function, with a docstring, and call that function from the block.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895