2

I'm trying to implement one of the answers to this question. However, I haven't been successful because when I run

> sphinx-autogen -o generated  *.rst

I get the errors

Failed to import 'MyMod.X': no module named MyMod.X

Failed to import 'MyMod.Y': no module named MyMod.Y

Failed to import 'MyMod.Z': no module named MyMod.Z

Within my .rst files, there is one with the line:

.. automodule:: MyMod.X

(and similarly for MyMod.Y and MyMod.Z).

I'm running this within a subdirectory docs. In the parent directory containing docs, there is also a subdirectory MyMod which contains __init__.py, X.py, Y.py, and Z.py. The conf.py file within docs has the line sys.path.insert(0, os.path.abspath('../')) immediately after import sys.

The closest related question I can find is this, but the answers there seem to suggest that it is solved by inserting '../' into the path, which I had already done. Also, sphinx-autobuild can find these modules happily, so I don't think this is the issue.

Interestingly, changing the line in my .rst file to be .. automodule:: ../MyMod.X gets rid of the error message, though nothing seems to be generated in the directory I expect, and I then get error messages in sphinx-autobuild.

How can I get sphinx-autogen to read in these modules?

Community
  • 1
  • 1
Joel
  • 22,598
  • 6
  • 69
  • 93
  • 1
    I can reproduce the error with sphinx-autogen. But when I set `autosummary_generate = True` in conf.py and run sphinx-build instead, it works. – mzjn Apr 25 '17 at 09:14

1 Answers1

0

if anyone else has a better answer, or an explanation for this please post it, but here is what I learned about my question

Although sphinx-autogen gives error messages, in the case that I was looking at, the files I was trying to get it to create were still created. While it could not find the modules (and indeed, they were functions, not modules, so it's not a surprise that it couldn't), it still produced the expected output.

Joel
  • 22,598
  • 6
  • 69
  • 93