python - 缺少 sphinx 命令的 conf 文件

标签 python python-sphinx tox

我在运行 tox 命令为我的 Python 项目生成 Sphinx 文档时遇到问题。这是错误:

docs runtests: PYTHONHASHSEED='1181019260'
docs runtests: commands[0] | sphinx-build -W -b html -c ./conf.py -d /Users/rakesh.kumar/ll/client-location/limekiln/.tox/docs/tmp/doctrees . /Users/rakesh.kumar/ll/client-location/limekiln/.tox/docs/tmp/html
Error: Config directory doesn't contain a conf.py file.
ERROR: InvocationError: '/Users/rakesh.kumar/ll/client-location/limekiln/.tox/docs/bin/sphinx-build -W -b html -c ./conf.py -d /Users/rakesh.kumar/ll/client-location/limekiln/.tox/docs/tmp/doctrees . /Users/rakesh.kumar/ll/client-location/limekiln/.tox/docs/tmp/html'
_________________________________________________ summary __________________________________________________
  py27: commands succeeded
  lint: commands succeeded
ERROR:   docs: commands failed

它基本上是在提示 conf.py,但是这个配置文件存在于 tox.ini 所在的同一目录中。我是 toxsphinx 的新手,不确定为什么会提示。 以下是 tox.ini 的内容。

[tox]
envlist = py27,lint,docs

[testenv]
commands =
    python setup.py nosetests --with-coverage --cover-package=limekiln --cover-erase --cover-html
    python setup.py sdist
deps =
    setuptools>=17.1

[testenv:docs]
basepython=python
changedir=docs
deps=sphinx
commands=
    sphinx-build -W -b html -c ./conf.py -d {envtmpdir}/doctrees .  {envtmpdir}/html

[testenv:lint]
commands=flake8 --max-line-length 99 limekiln
basepython=python2.7
deps=
    flake8
    flake8-print

这是我的 conf.py 文件。

import sys, os

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

extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo',
                    'sphinx.ext.coverage', 'sphinx.ext.pngmath', 'sphinx.ext.ifconfig',
                                  'epub2', 'mobi', 'autoimage', 'code_example', 'sphinx.ext.autodoc']

todo_include_todos = True
templates_path = ['_templates']
source_suffix = '.rst'
master_doc = 'index'
exclude_patterns = []
add_function_parentheses = True
#add_module_names = True
#modindex_common_prefix = []

project = u'Limekiln'
copyright = u'2015'

version = '1.0'
release = '1.0'

这是我的项目的目录结构。

Project-root-directory
├── conf.py
├── module directory
│   ├── module sub-directory1
│   ├── module sub-directory2
├── requirements.txt
├── setup.py
└── tox.ini

最佳答案

改变

commands=
sphinx-build -W -b html -c ./conf.py -d {envtmpdir}/doctrees .  {envtmpdir}/html

commands=
sphinx-build -W -b html -c ./ -d {envtmpdir}/doctrees .  {envtmpdir}/html

来自 sphinx-build 帮助:

-c <path>           path where configuration file (conf.py) is located

关于python - 缺少 sphinx 命令的 conf 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32813629/

相关文章:

pdf - 调整 pdf 输出的表格宽度以完美适合线宽

python - Tox:flake8 和 pylint 等工具的每个平台配置

python - 求解变量子集的多元方程

python - ctypes,python3.5,OSError : exception: access violation writing 0x00000000

python - 自动恢复最小化的 tkinter 窗口

python - 如何使用 Sphinx 的 autodoc 来记录类的 __init__(self) 方法?

python - 狮身人面像快速启动失败

python-2.7 - 在 python Tox ini 文件中使用源时出错

python - 如何使用tox仅测试一个功能?

python - 实现数值求解微分方程的初始条件