【发布时间】:2020-08-18 13:29:20
【问题描述】:
我想为 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
如何解决?
【问题讨论】:
-
看起来您遵循了文档sphinx-doc.org/en/master/development/theming.html 中的每一步,
setup.py除外。此外,文档没有提到如何安装您的主题,这可能是一个遗漏。配置你的setup.py后,尝试pip install -e ."[docs]"以可编辑模式安装你的包,然后尝试使用它。我从来没有这样做过,但是为了使用它而安装你的包是有意义的。
标签: themes customization python-sphinx