Is OptionParser in conflict with sphinx?

后端 未结 2 1137
天命终不由人
天命终不由人 2020-12-02 00:12

I\'m trying to write a documentation for my project in sphinx and whenever sphinx encounters OptionParser in my module it gives me:

sphinx-build: error: no s         


        
相关标签:
2条回答
  • 2020-12-02 00:36

    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.

    0 讨论(0)
  • 2020-12-02 00:51

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

    if __name__ == '__main__':
    
        parser = optparse.OptionParser()
    
    0 讨论(0)
提交回复
热议问题