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.

1
  • I tried putting in a docstring just below the test. I finally 'saw the light' and used the strategy below (function). Commented Jul 14, 2015 at 7:47

1 Answer 1

6

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.