Reputation: 7351
Suppose I have a folder structure
A\__init__.py
A\math\__init__.py
A\math\others.py
A\stats\__init__.py
A\stats\andthese.py
I have A
in my python path, so normally I do import math.others
, but import A.math.others
will fail.
Now in folder A
, I do
sphinx-apidoc -o ./documentation ./ --full --force
to generate the configuration files, eg
A\documentation\A.rst
A\documentation\A.math.rst
A\documentation\A.math.others.rst
Then in A\documentation
I do make html
. This will fail because it cannot import A.math.others
(I don't want to make A's parent folder a python path.)
How can I make sphinx-apidoc
to generate config files without the root directory included in the import path?
Upvotes: 0
Views: 628
Reputation: 7351
Figured it out myself.
In the generated A\documentation\conf.py
, uncomment the lines 18-20
import os
import sys
sys.path.insert(0, u'D:/A')
And modify the last line to
sys.path.insert(0, u'D:')
Now all imports will work.
Upvotes: 1