4

I've created a Python module from Fortran files with:

f2py -c -m mymod file1.f90 file2.f90 file3.f90

file1.f90 contains Fortran modules: foo, bar, bar. Module foo contains functions: f,g,h.

f2py automatically write docstring for function f.

mymod.so is contained in directory ROOT, and I've added ROOT in my PYTHONPATH.

I can access docstring of f function with:

import mymod
mymod.foo.f.__doc__

I now want write documenation for function f using autodoc extension of sphinx:

.. autofunction:: mymod.foo.f

But it fails with:

ImportError: No module named mymod.foo

I think sphinx is trying to import like this, which does not work:

import mymod.foo
foo.f.__doc__

I tried to import a package containing __init__.py.

How can I make sphinx find mymod.foo.f doctring?

barryhunter
  • 20,886
  • 3
  • 30
  • 43
user744629
  • 1,961
  • 1
  • 18
  • 27
  • A function `mymod.foo.f` cannot be anything else than a function inside a `mymod/foo.py` file, right? So an `import mymod.foo;mymod.foo.__doc__` would be right. And there *has* to be an `__init__.py` in the package. So... can you give more setup details? – Reinout van Rees Nov 18 '12 at 17:52

0 Answers0