[英]Documenting python script entry (__name__ == '__main__') using sphinx
Is there a way, ideally using autodoc
, to get sphinx to document a Python script?有没有办法,理想情况下使用
autodoc
,让 sphinx 记录 Python 脚本? The section of the script I want documented is the portion protected by:我想要记录的脚本部分是受以下保护的部分:
if __name__ == '__main__':
ie the bit that only runs if the module is used as a script instead of being imported.即仅当模块用作脚本而不是被导入时才运行的位。
您应该将该块中的代码提取到一个带有文档字符串的函数中,然后从该块中调用该函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.