用sphinx_book_theme构建sphinx

发布于 2025-02-10 08:30:30 字数 1782 浏览 0 评论 0原文

我正在尝试将sphinx与 sphinx beam theme 在我的文档中构建文档的问题。

设置

我安装了sphinx和主题的

pip install sphinx
pip install sphinx_book_theme
sphinx-quickstart

,并使用以下文档启动了:然后我将主题更改为phinx beam them

我的conf.py看起来像这样(已删除自动化注释):

# -- Project information -----------------------------------------------------

project = 'mytest'
copyright = '2022, Me'
author = 'Me'
release = '0.1.0'


# -- General configuration ---------------------------------------------------

extensions = [
    'sphinx_book_theme' # I changed this
]
templates_path = ['_templates']
language = 'python'
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

html_theme = 'sphinx_book_theme' # I changed this
html_static_path = ['_static']

构建

但是,当我尝试构建文档时,

sphinx-build docs . _build/html

:我会收到此错误:

Running Sphinx v4.5.0
loading translations [python]... not available for built-in messages
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index
Theme error:
An error happened in rendering the page index.
Reason: TemplateNotFound('sidebar-logo.html')

如何解决此问题并使用书籍主题?我需要创建一个侧边栏模板吗?如果是这样,如何以及在哪里?我没有针对我的项目的徽标,也不想创建一个徽标。

I'm trying to use Sphinx with Sphinx book theme in my documentation but I'm having problems building the docs.

Setup

I installed Sphinx and the theme and initiated the docs with:

pip install sphinx
pip install sphinx_book_theme
sphinx-quickstart

Then I changed the theme to Sphinx book theme as described in the docs by adding the extension and changing the HTML theme in the conf.py.

My conf.py looks like this (removed autogenerated comments):

# -- Project information -----------------------------------------------------

project = 'mytest'
copyright = '2022, Me'
author = 'Me'
release = '0.1.0'


# -- General configuration ---------------------------------------------------

extensions = [
    'sphinx_book_theme' # I changed this
]
templates_path = ['_templates']
language = 'python'
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

html_theme = 'sphinx_book_theme' # I changed this
html_static_path = ['_static']

Building

However, when I try to build the docs:

sphinx-build docs . _build/html

I get this error:

Running Sphinx v4.5.0
loading translations [python]... not available for built-in messages
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index
Theme error:
An error happened in rendering the page index.
Reason: TemplateNotFound('sidebar-logo.html')

How do I fix this and use the book theme? Do I need to create a sidebar template? If so, how and where? I don't have a logo for my project and would not like to create one at this moment.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

隱形的亼 2025-02-17 08:30:30

我自己找到了答案。似乎如果您删除行templates_path = ['_templates']它有效:

# -- Project information -----------------------------------------------------

project = 'mytest'
copyright = '2022, Me'
author = 'Me'
release = '0.1.0'


# -- General configuration ---------------------------------------------------

extensions = [
    'sphinx_book_theme'
]
# templates_path = ['_templates'] # REMOVE THIS LINE TO WORK
language = 'python'
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

html_theme = 'sphinx_book_theme'
html_static_path = ['_static']

如果您在>“模板”中有某些内容,我怀疑您需要创建sidebar -logo.html在这里。不确定如何。

I found the answer myself. It seems if you remove the line templates_path = ['_templates'] it works:

# -- Project information -----------------------------------------------------

project = 'mytest'
copyright = '2022, Me'
author = 'Me'
release = '0.1.0'


# -- General configuration ---------------------------------------------------

extensions = [
    'sphinx_book_theme'
]
# templates_path = ['_templates'] # REMOVE THIS LINE TO WORK
language = 'python'
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

html_theme = 'sphinx_book_theme'
html_static_path = ['_static']

If you have something in the templates, I suspect you need to create the sidebar-logo.html here. Not sure how though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文