After many searches and attempts I have not found a solution to this problem...
I am using Sphinx to generate documentation for a Python package. You can see the code here: https://github.com/jajimer/energym/tree/documentation. The part of the package we are interested in is organized as follows:
In energym/docs/source/conf.py
I have configured the path as follows:
import os
import sys
sys.path.insert(0, os.path.abspath('../../energym/'))
And now I'm trying to add to the API documentation (energym/doc/source/pages/API-reference.rst
) the description of this utils
module and all its components. For this, I am using Sphinx's autosummary
:
.. autosummary::
:toctree: modules
:template: custom-module-template.rst
:recursive:
utils
So, after doing make clean && make html
, the documentation for utils.common
, utils.rewards
and utils.rewards
is perfectly created, but not for utils.controllers
. According to Sphinx, the following exception occurs:
File "/home/user/projects/energym/energym/utils/controllers.py", line 8, in <module>
from ..utils.common import parse_variables
ValueError: attempted relative import beyond top-level package
And here is my question. How can I fix it? Is it a relative path problem? I've seen that the problem is due to the following import:
from ..utils.common import parse_variables
But I don't really know the reason, as the path seems to be perfectly set.