Is OptionParser in conflict with sphinx?

一曲冷凌霜 提交于 2019-11-27 15:32:07

Here is what I think happens:

When Sphinx runs, autodoc imports your module and the toplevel code in the module is executed. An OptionParser instance is created, and it processes the command line arguments and options passed to sphinx-build, one of which is -b. Your OptionParser does not allow this option.

I would put the OptionParser code in a function so that it is not executed when the module is imported.

This did the trick for me, add this at the bottom.

if __name__ == '__main__':

    parser = optparse.OptionParser()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!