我正在尝试在本地为 sphinx 实现我自己的自定义主题。我一直遇到这个错误:
no theme named 'custom_theme' found (missing theme.conf?)
。
我的 theme.conf
目录中有一个 custom_theme/
。看起来像:
[theme]
inherit = basic
stylesheet = styles/site.min.css
在我的conf.py中,我有以下相关设置:
html_theme = 'custom_theme'
html_theme_path = ["."]
作为参考,我一直在尝试镜像此主题存储库上的设置https://github.com/snide/sphinx_rtd_theme。使用 grunt 来构建我的样式等。但仍然收到该错误。我希望有人找到了一些关于如何创建自己的狮身人面像主题和模板的详细文档。谢谢你。
我相信你想将主题放在 /usr/share/sphinx/themes 中。
在要应用主题的项目的
conf.py
目录中编辑source
并添加:
# Notice this is a list.
html_theme_path = [ '/path/to/theme/PARENT/directory/` ]
html_theme = 'basename_of_theme_directory'
主题文件中没有任何用于识别主题的内容;它只是目录的基本名称。举个例子,如果您的主题是
/home/projects/sphinx_themes/mytheme/
:
html_theme_path = [ '/home/projects/sphinx_themes' ]
html_theme = 'mytheme'
我意识到在这个问题中你声称或多或少做了这件事。我敢打赌问题出在使用“.”作为主题路径;可能这并不指您认为的地方。相对路径是相对于项目源目录的,例如。您可以在那里添加
_themes/mytheme
并使用:
html_theme_path = [ '_themes' ]
html_theme = 'mytheme'
我最终只是覆盖了所有内容并将我的主题放入
source/