简体   繁体   中英

Documenting python script entry (__name__ == '__main__') using sphinx

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__':

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

您应该将该块中的代码提取到一个带有文档字符串的函数中,然后从该块中调用该函数。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM