2

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.

Community
  • 1
  • 1
alfa
  • 3,058
  • 3
  • 25
  • 36
  • 1
    The issue is not about OptionParser. Imagine one the scripts has `shutil.rmtree("/")` at the module level. Check whether autodoc extension respects `exclude_patterns` or that you specified correct glob patterns. Make sure to start from a clean state (no build artifacts). – jfs Feb 08 '13 at 10:45
  • 4
    You are right. It had nothing to do with OptionParser. I had a setup.py in one of the directories and this caused the error. Wrapping it with `if __name__ == "__main__": ...` is a quick fix that solved the problem. However, that does not solve the actual problem. How can I let autodoc respect the `exclude_patterns`? – alfa Feb 08 '13 at 11:18
  • `exclude_patterns` is for excluding .rst files, not for excluding Python source files. – mzjn Feb 23 '13 at 13:42
  • If you cannot touch the modules/scripts that give you problems, the only solution I can think of is to write the documentation for these modules by hand (i.e., do not use autodoc for these modules). – mzjn Feb 25 '13 at 10:30

0 Answers0