如何配置buildout以使用bin / sphinxbuilder创建sphinx文档

时间:2016-02-04 11:57:20

标签: python python-sphinx buildout

在我的 buildout.cfg 文件中,我有这样的代码:

parts =
    ...
    sphinxbuilder

接下来在同一个文件中:

eggs=
   ...
   jinja2
   markupsafe
   sphinx

然后,在文件末尾:

[sphinxbuilder]
recipe = collective.recipe.sphinxbuilder
source = ${buildout:directory}/docs-src
build = ${buildout:directory}/docs

我做:

bin/buildout

给出输出(一般来说:OK):

Updating sphinxbuilder.
collective.recipe.sphinxbuilder: writing MAKEFILE..
collective.recipe.sphinxbuilder: writing BATCHFILE..
collective.recipe.sphinxbuilder: writing custom sphinx-builder script..

在鸡蛋文件夹中,我有Sphinx eeg。

buildout之后,在项目目录下我有一个新目录:docs。 然后我运行命令:

bin/sphinx-quickstart

root path for the documentation我设置docs

然后我编辑docs/conf.py并取消注释

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

我运行命令bin/sphinxbuilder并收到错误:

Makefile:12: *** The 'sphinx-build' command was not found. 
Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the 'sphinx-build' executable.
Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/. Stop.

主要问题: (1)如何通过buildout自动运行sphinx? (2)如何在.rst文件中设置项目模块(apps)的正确路径? (3)放置conf.py文件的位置?

1 个答案:

答案 0 :(得分:1)

在这里的窗户上,但我似乎回想起类似的问题。

扩展以下cfg确保了两件事: 1)我们生成的所有入口点都可以访问狮身人面像蛋 2)依赖于狮身人面像入口点的部分将在生成这些入口点后执行

[sphinx]
eggs = 
    sphinx
    <if you have theme eggs or other extensions, put em here>

parts =
    sphinx.console_scripts

[sphinx.console_scripts]
recipe = zc.recipe.egg
dependent-scripts = true
eggs = 
    ${sphinx.eggs}
    ${buildout:eggs}

使用此功能,您还可以添加依赖于build / apidoc可执行文件的部件,并且您的文档生成将成为一键式构建的一部分:

[sphinx.apidoc]
recipe = plone.recipe.command
command = ${buildout:bin-directory}\sphinx-apidoc.exe <all your flags/settiongs based on buildout>