我在Windows上使用Sphinx。
我的大部分文档都是针对普通用户的,但也有一些仅供管理员使用的内容。 所以我想构建我的文档的两个版本:一个完整的版本,第二个版本的“管理”页面排除在外。如何从命令行设置Sphinx的`exclude_patterns`?
我为此使用了exclude_patterns
in the build configuration。
到目前为止,它的工作。在每个子文件夹的名称包含当我把这个到conf.py
文件“管理员”被忽略的每个文件:
exclude_patterns = ['**/*admin*']
的问题是,我想运行构建一次获得两个版本。
我现在想要做的是运行make.bat
两次,并在每次运行时提供不同的参数。
根据the documentation,我可以通过设置BUILDDIR
和SPHINXOPTS
变量来实现此目的。
所以现在我有一个build.bat
,看起来是这样的:当我从狮身人面像生成make.bat
文件中删除线set BUILDDIR=build
path=%path%;c:\python27\scripts
rem BUILD ADMIN DOCS
set SPHINXOPTS=
set BUILDDIR=c:\build\admin
call make clean
call make html
rem BUILD USER DOCS
set SPHINXOPTS=-D exclude_patterns=['**/*admin*']
set BUILDDIR=c:\build\user
call make clean
call make html
pause
构建在两个不同的目录工作。
但是,排除模式确实不是的工作。
上面列出的批处理文件输出本作的第二个版本(一个与排除模式):
Making output directory...
Running Sphinx v1.1.3
loading translations [de]... done
loading pickled environment... not yet created
Exception occurred:
File "C:\Python27\lib\site-packages\sphinx-1.1.3-py2.7.egg\sphinx\environment.
py", line 495, in find_files
['**/' + d for d in config.exclude_dirnames] +
TypeError: coercing to Unicode: need string or buffer, list found
The full traceback has been saved in c:\users\myusername\appdata\local\temp\sphinx-err-kmihxk.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
Either send bugs to the mailing list at <http://groups.google.com/group/sphinx-dev/>,
or report them in the tracker at <http://bitbucket.org/birkenfeld/sphinx/issues/>. Thanks!
我在做什么错?
sphinx-build
命令行中exclude_patterns
的语法与conf.py
文件中的语法不同吗?
还是有更好的方法来一步建立两个不同的版本?
顺便说一句,不排除任何东西的正确语法是'exclude_patterns = []' –
谢谢,我编辑了答案,包括正确的语法。 –