我在从Sphinx Tutorial开始跑doctest
时遇到了问题.我有下面的目录树,但我不能运行doctest
for lumache.py
.如何才能使lumache.py
可以导入conf.py
中的pathlib
函数,即sys.path.insert(0, pathlib.Path(__file__).parents[2].resolve().as_posix())
.我试图执行的代码与教程中的代码相同(第一句中提到了超链接).
conf.py Contents
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here.
import pathlib
import sys
sys.path.insert(0, pathlib.Path(__file__).parents[2].resolve().as_posix())
extensions = [
'sphinx.ext.duration',
'sphinx.ext.doctest',
]
...
Contents of lumache.py
def get_random_ingredients(kind=None):
return ["shells", "gorgonzola", "parsley"]
CMD execution
C:\docs>make doctest
ModuleNotFoundError: No module named 'lumache'
Directory Tree:
docs/
├─build/
│ ├─doctest/
│ │ └─0 folder(s), 1 file(s)
│ ├─doctrees/
│ │ └─0 folder(s), 3 file(s)
│ └─html/
│ └─3 folder(s), 7 file(s)
├─make.bat
├─Makefile
└─source/
├─conf.py
├─index.rst
├─lumache.py
├─usage.rst
├─_static/
│ └─0 folder(s), 0 file(s)
└─_templates/
└─0 folder(s), 0 file(s)