python – 无法使用Sphinx可读性主题

python – 无法使用Sphinx可读性主题,第1张

概述我想为我的Sphinx使用Readability主题,它可用于 here.但是,当我按照说明中的建议修改我的conf.py文件来尝试使用此主题时,它会在make html时显示此错误: sphinx-build -b html -d build/doctrees source build/htmlRunning Sphinx v1.3.1loading pickled environmen 我想为我的Sphinx使用Readability主题,它可用于 here.但是,当我按照说明中的建议修改我的conf.py文件来尝试使用此主题时,它会在make HTML时显示此错误:

sphinx-build -b HTML -d build/doctrees   source build/HTMLRunning Sphinx v1.3.1loading pickled environment... donetheme error:no theme named 'readability' found (missing theme.conf?)make: *** [HTML] Error 1

我看到人们之前遇到过像in this question报道的其他一些主题的问题.但是,在我的情况下,conf.py文件存在于那里.

UPDATE

我尝试使用更新的狮身人面像在virtualenv中的主题.并且在执行make HTML时显示此错误:

sphinx-build -b HTML -d build/doctrees   source build/HTMLRunning Sphinx v1.3.1loading pickled environment... donebuilding [mo]: targets for 0 po files that are out of datebuilding [HTML]: targets for 1 source files that are out of dateupdating environment: 0 added,0 changed,0 removedlooking for Now-outdated files... none foundpreparing documents... donewriting output... [100%] indexgenerating indices... genindexException occurred:  file "~/DEVEL/python/sphinx/sphinx2/local/lib/python2.7/site-packages/sphinx/jinja2glue.py",line 159,in get_source    raise TemplateNotFound(template)TemplateNotFound: readability/layout.HTMLThe full traceback has been saved in /tmp/sphinx-err-q42_PH.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.A BUG report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!make: *** [HTML] Error 1
解决方法 所以我能够通过应用 patch到 sphinxtheme-readability来解决这个问题.还有一个 bug report.

组态:

我的source / conf.py看起来像这样:

import sphinxthemeHTML_theme = 'readability'HTML_theme_path = sphinxtheme.get_HTML_theme_path()

补丁:

这是我必须应用于sphinxtheme / __ init__.py的补丁:

diff --git a/sphinxtheme/__init__.py b/sphinxtheme/__init__.pyindex b0d6433..a3edbe0 100644--- a/sphinxtheme/__init__.py+++ b/sphinxtheme/__init__.py@@ -1 +1,7 @@-__import__('pkg_resources').declare_namespace(__name__)\ No newline at end of file+import os+++def get_HTML_theme_path():+    """Return List of HTML theme paths."""+    cur_dir = os.path.abspath(os.path.dirname(__file__))+    return [cur_dir]

> sphinxtheme-readability的My Fork
> sphinxtheme-readability的My Test

> Demo

我还提交了一份Pull Request来解决这个问题.

您只需执行以下 *** 作即可对此进行测试:

mkvirtualenv test-sphinxtheme-readabilitygit clone https://github.com/prologic/test-sphinxtheme-readability.gitcd test-sphinxtheme-readabilitypip install -r requirements.txtmake clean HTMLcircuits.web build/HTML

并访问:http://localhsot:8000/

说明:您遇到此问题的原因以及我认为主题及其示例配置有点不合理的原因是因为路径非常错误.看到:

$make clean HTMLrm -rf build/*sphinx-build -b HTML -d build/doctrees   source build/HTMLRunning Sphinx v1.3.1making output directory...readability_path:  /home/prologic/.virtualenvs/sphinx-readability/lib/python2.7/site-packages/sphinxthemerelative_path:  ../../../.virtualenvs/sphinx-readability/lib/python2.7/site-packages/sphinxthemeloading pickled environment... not yet createdbuilding [mo]: targets for 0 po files that are out of datebuilding [HTML]: targets for 1 source files that are out of dateupdating environment: 1 added,0 removedreading sources... [100%] index                                                                                         looking for Now-outdated files... none foundpickling environment... donechecking consistency... donepreparing documents... donewriting output... [100%] index                                                                                          generating indices... genindexException occurred:  file "/home/prologic/.virtualenvs/sphinx-readability/lib/python2.7/site-packages/sphinx/jinja2glue.py",in get_source    raise TemplateNotFound(template)TemplateNotFound: readability/layout.HTMLThe full traceback has been saved in /tmp/sphinx-err-8zoG8h.log,so that a better error message can be provIDed next time.A BUG report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!Makefile:55: recipe for target 'HTML' Failedmake: *** [HTML] Error 1$ls -lah /home/prologic/.virtualenvs/sphinx-readability/lib/python2.7/site-packages/sphinxthemetotal 32Kdrwxr-xr-x  3 prologic users 4.0K Jun 15 09:30 .drwxr-xr-x 37 prologic users 4.0K Jun 15 09:30 ..-rw-r--r--  1 prologic users   55 Jun 15 09:30 __init__.py-rw-r--r--  1 prologic users  243 Jun 15 09:30 __init__.pycdrwxr-xr-x  3 prologic users 4.0K Jun 15 09:30 readability-rw-r--r--  1 prologic users 5.6K Jun 15 09:30 readability_theme_support.py-rw-r--r--  1 prologic users 2.8K Jun 15 09:30 readability_theme_support.pyc$ls -lah ../../../.virtualenvs/sphinx-readability/lib/python2.7/site-packages/sphinxthemels: cannot access ../../../.virtualenvs/sphinx-readability/lib/python2.7/site-packages/sphinxtheme: No such file or directory

请注意我在source / conf.py中打印的两个路径:

readability_path:  /home/prologic/.virtualenvs/sphinx-readability/lib/python2.7/site-packages/sphinxthemerelative_path:  ../../../.virtualenvs/sphinx-readability/lib/python2.7/site-packages/sphinxtheme
总结

以上是内存溢出为你收集整理的python – 无法使用Sphinx可读性主题全部内容,希望文章能够帮你解决python – 无法使用Sphinx可读性主题所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1197360.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存