python - 通过 tox 运行 Sphinx

标签 python python-3.x python-sphinx tox

我有一个毒性配置,允许我对文档进行一些检查。这或多或少来自official documentation on tox .

[tox]
envlist = py36, flake8, docs

[testenv:docs]
basepython=python3.6
changedir=docs  # ← causes sphinx-apidoc to misbehave.
deps=-r{toxinidir}/requirements/requirements.txt
commands=
    sphinx-apidoc --force --separate --private --module-first -o docs site '*/*test*' '*/*migration*'
    pytest --maxfail=1 --tb=line -v --junitxml=junit_{envname}.xml check_sphinx.py

但是,第一个命令 (sphinx-apidoc ...) 需要在项目的根目录中运行,否则排除模式将不起作用。尽管我尝试了许多可能的变化,但还是如此。第二个命令需要在 docs 目录中运行。

如何让这两个命令在单独的目录中运行?

最佳答案

命令指向 shell 脚本,例如

#!/bin/bash

set -eux

sphinx-apidoc --force --separate --private --module-first -o docs site '*/*test*' '*/*migration*'
cd docs
pytest --maxfail=1 --tb=line -v --junitxml=junit_{envname}.xml check_sphinx.py

关于python - 通过 tox 运行 Sphinx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47224468/

相关文章:

python - Sphinx 文档在本地显示,但在推送到 GitHub 时不在 URL 处显示

python - 索引错误: list index out of range while writing to file

python - Selenium - 按字体过滤

python - int()的无效文字(以10为基础: '(1 + 1)(1 + 1)' )

python - 使用 PyQt5/QtDesigner 弹出窗口或多个窗口

python-sphinx - 如何引用以单数定义但以复数表示的词汇表术语?

python - 在 Sphinx 中保持 API 更新

python - Spotfire 我可以通过ironpython 脚本输入列吗?

python-3.x - 从生成器创建 numpy 数组,列表列表

python - 如何确保将数据保存到 csv 时保留逗号?