How should I solve the conflict of OptionParser an

2019-07-15 23:26发布

问题:

I have a large Python project with many external libraries I don't want to touch and I want to generate the documentation with sphinx. My problem is, whenever I execute "make html", I get this error:

...
usage: sphinx-build [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: sphinx-build --help [cmd1 cmd2 ...]
   or: sphinx-build --help-commands
   or: sphinx-build cmd --help

error: option -b not recognized
make: *** [html] Fehler 1

I already figured out that this problem occurs when there is an OptionParser in some of the directories that I want to document (Is OptionParser in conflict with sphinx?). I actually have many scripts that use the OptionParser in those directories and do not wrap it with if __name__ == "__main__": .... My question is:

How can I generate the documentation without touching any of these scripts?

Is there a way to exclude those files/paths? I already tried exclude_patterns in my conf.py but this did not work. I do not know why. Is there a way to catch that error?

Update

The issue turned out to be a setup.py file in the tree parsed by autodoc.