Documenting python script entry (__name__ == '

2020-04-15 14:46发布

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条回答
闹够了就滚
2楼-- · 2020-04-15 15:29

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

查看更多
登录 后发表回答