我在学码头工人
我有一个Python脚本,它使用mod library,而mod library没有安装在我的系统上。目标是在Docker容器中执行它。我写了Dockerfile。我在里面加了一行:
RUN pip install --trusted-host pypi.python.org -r requirements.txt
在requirements.txt中,我编写了mod
它工作了,在容器内安装mod,代码运行良好
现在,我想在同一个脚本上生成Sphinx文档。我知道狮身人面像的工作原理(基础)。我用sys.path.insert(0, os.path.abspath('..'))
修改了conf.py
,它指向包含Script.py的目录(与Dockerfile和requirements.txt一起),然后添加了以下内部索引。rst:Script.py位于名为DockerPython的文件夹中:
.. automodule:: DockerPython.Script
:members:
当我启动make html
(与其他示例配合使用)时,我得到以下结果:
Running Sphinx v2.0.1
making output directory... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment: 1 added, 0 changed, 0 removed
reading sources... [100%] index
WARNING: autodoc: failed to import module 'Script' from module 'DockerPython'; the following exception was raised:
No module named 'mod'
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index
generating indices... genindex
writing additional pages... search
copying static files... done
copying extra files... done
dumping search index in English (code: en) ... done
dumping object inventory... done
build succeeded, 1 warning.
The HTML pages are in build\html.
我得到的那一页是空的
所以,我的问题是:Sphinx能否在本地Python上编译和运行不好的脚本上执行(因为lib不是本地安装的)
如何让它在通过Docker使用特定设置的脚本上工作?谢谢你
冲浪两个小时后,我才明白
我只需要将这一行添加到
conf.py
:相关问题 更多 >
编程相关推荐