Sphinx recursive autosummary not importing modules

685 Views Asked by At

I'm going crazy with Sphinx's recursive autosummary. My working directory is:

my_wd
|
|-- docs
|   |-- source
|      |--index.md
|      |--conf.py
|      |-- _templates
|          |-- custom-module-template.rst
|          |-- custom-class-template.rst
|-- my_library
|   |-- several .py modules

at the top of conf.pyis:

import os
import sys

sys.path.insert(0, os.path.abspath('../..'))

in index.md I have:

```{toctree}
:caption: 'Contents:'
:maxdepth: 2

Home <self>

```

```{include} ../../README.md
:relative-images:
```

```{eval-rst}
.. autosummary::
   :toctree: _autosummary
   :template: custom-module-template.rst
   :recursive:
   
   my_library
```

and the files custom-module-template.rst and custom-class-template.rst are filled according to this answer.

Still, the autosummary is not working. In the log I first get

[autosummary] generating autosummary for: _autosummary/module1.rst, _autosummary/module2.rst...  

(which doesn't seem right: why is it looking for rst files?)

Then I get

WARNING: [autosummary] failed to import my_library.
    Possible hints:
    * ValueError: not enough values to unpack (expected 2, got 1)
    * ModuleNotFoundError: No module named 'my_library'
    * KeyError: 'my_library'
    
failed to import my_library.module

for every module.py that is included in the my_library folder.

This means (I guess) that sphinx is actually seeing the different .py modules in the my_library folder (but it's then looking for the corresponding rst files?!). So the absolute path should be right.

This sounds like a path error to me, but I think the path is right. What am I doing wrong?

0

There are 0 best solutions below