2

I am using Sphinx for documenting my project. when i am running make html i am getting this error.

I have installed Sphinx v1.1.2 . There might be some error in some of .rst, files but This error message is unhelpful since i do not know which file to check as i have more than 100 .rst files. So it is difficult to check files one by one.

Is there any way to solve this error or at-least to find out which file is erroneous?

Thanks in advance.

mzjn
  • 48,958
  • 13
  • 128
  • 248
shashaDenovo
  • 1,638
  • 21
  • 21
  • Is [argparse](http://docs.python.org/library/argparse.html) used in your project? That module has an "unrecognized arguments" error message. – mzjn Jun 11 '12 at 19:51
  • yes ``argparse`` is used in my project. – shashaDenovo Jun 12 '12 at 08:49
  • 1
    Then this might be a problem similar to http://stackoverflow.com/questions/6912025/is-optionparser-in-conflict-with-sphinx – mzjn Jun 12 '12 at 16:50

2 Answers2

3

Check the module that was being processed just before this error. That module is probably missing if __name__ == '__main__' check.

The issue here is that:

  • sphinx-apidoc (or whatever you used to generate your rsts) probably put automodule/autoclass/... in your rst.
  • sphinx uses autodoc extension to fetch doc strings from teh .py files when it encounters the autoXXX directive in rst file.
  • autodoc import the .py module to extract the doc strings from it.
  • on import if a module by default assumes it's an executable only (i.e. doesn't have the __main__ check) the you'll get the error.

What makes this is a pain in the a$$ error is that most developers would use sys.argv[0] and sys.argv[0:] in the error message displayed on wrong args, causing a completely unappropriate error message being printed in this case.

Kashyap
  • 15,354
  • 13
  • 64
  • 103
1

If you are using sphinx-apidoc and your package uses setuptools with setup.py in the same folder, make sure you hide away setup() call into if 'main' == __name__: construct.

mlt
  • 1,595
  • 2
  • 21
  • 52