如何解决theme theme-name没有在狮身人面像中自定义主题的“ theme”设置?
我想为python-sphinx创建自己的主题-mytheme
。
tree project
project
├── build
├── make.bat
├── Makefile
├── mytheme
│ ├── static
│ │ └── style.css
│ └── theme.conf
└── source
└── conf.py
theme.conf中的内容:
cat project/mytheme/theme.conf
[theme]
inherit = default
stylesheet = style.css
同意project/source/conf.py
cat project/source/conf.py
def setup(app):
app.add_stylesheet('static/style.css')
app.add_html_theme('mytheme',os.path.abspath(os.path.dirname(__file__)))
html_theme = 'mytheme'
html_theme_path = ['.']
现在让我们在源代码中创建所有* .rst文件。
cd project
make html
Running Sphinx v2.4.4
loading pickled environment... done
Theme error:
theme 'mytheme' doesn't have "theme" setting
Makefile:19: recipe for target 'html' failed
make: *** [html] Error 2
如何修复?
解决方法
您使用两种互斥的方法-使用文件系统中的本地主题,并同时注册主题(作为以Python PyPI软件包分发的主题)。
如果您希望主题成为Sphinx项目的一部分,则此类特定于项目的主题的好去处是_themes/
在带有conf.py的目录中,并设置html_theme = "mytheme"
和{{1 }}中。
html_theme_path = ["_themes"]
(从https://blog.documatt.com/sphinx-theming/themes.html#project-specific-themes借来)
完全删除区块
_themes/
mytheme/
static/
css/
main.css
theme.conf
layout.html
conf.py
index.rst
second.rst
third.rst
...
def setup(app):
app.add_stylesheet('static/style.css')
app.add_html_theme('mytheme',os.path.abspath(os.path.dirname(__file__)))
是用于打包分发的主题。 add_html_theme()
用于添加其他(而不是替换现有的)样式表。主题的主要样式表位于其theme.conf add_stylesheet()
选项中。
我在您的示例中看到的最后一个问题是您的主题继承自stylesheet
主题。它可以工作,看起来它是default
主题(https://www.sphinx-doc.org/en/master/usage/theming.html#builtin-themes)的旧名称,但是使用其正式名称-classic
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。