我在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 = []' –
謝謝,我編輯了答案,包括正確的語法。 –