【问题标题】:Using a custom theme inside a zip file在 zip 文件中使用自定义主题
【发布时间】:2018-01-18 12:09:40
【问题描述】:

我已设置好 sphinx 文档并想使用自定义主题。我已经阅读了 sphinx 网站上的主题说明:http://www.sphinx-doc.org/en/stable/theming.html,但它不起作用。

我的主题名称与 conf.py 文件中的相同,并且它位于同一目录中的 zip 文件夹中,但我不断收到以下错误:

Theme error:
no theme named 'tera' found (missing theme.conf?)
make: *** [html] Error 2

我的 conf.py 代码是:

html_theme = "tera"

html_theme_options = {

}

html_theme_path = ['.']

按照说明,我在.zip 文件中有一个theme.conf 文件以及我需要的所有其他文件。不知道如何修复。

在我的 theme.conf 文件中,我有:

[theme] 
inherit = basic 
stylesheet = css/Terra.css 
pygments_style = default 

文件结构如下:Documents > Documentation >_themes。在主题中,我有一个“tera”文件夹和一个“tera.zip”文件。

我也试过直接将 tera.zip 文件放在我的文档文件夹中,因此它与 conf.py 文件位于同一目录中,但仍然没有成功

【问题讨论】:

  • 它是 .zip 文件还是文件夹/目录?您的问题是“zip 文件夹”,这令人困惑。请包括您的目录和文件结构,以及您的theme.conf 的内容。
  • 在我的 theme.conf 文件中我有: [theme] inherit = basic stylesheet = css/Terra.css pygments_style = default 文件结构如下:Documents > Documentation >_themes。在主题中,我有一个“tera”文件夹和一个“tera.zip”文件
  • 我也试过直接将 tera.zip 文件放在我的文档文件夹中,所以它与 conf.py 文件位于同一目录中,但仍然没有成功
  • tera.zip 里面有什么?
  • theme.conf 文件和包含我的 css 和图像的 '_static' 文件夹

标签: python python-sphinx


【解决方案1】:

我目前遇到了同样的问题。我的问题是 zip 默认在 zip 文件中创建一个目录,因此 theme.conf 不在其根目录中。

在做

$ zip -r tera.zip tera/*

给出以下内容:

$ less tera.zip
... Name
... ----
... tera/theme.conf

我截断了无趣的输出 (...)。如果你这样做了

$ cd tera
$ zip -r tera.zip *

配置文件将位于根目录并且 sphinx 可以工作。

【讨论】:

  • 这似乎不是 OP 的问题。 theme.conf 已经位于 zip 文件内目录结构的根目录中。请参阅问题的 cmets。
  • 这很可能不是帖子中的问题。不过,我认为还是把它贴在这里是件好事,因为如果你用谷歌搜索这个问题,你就会发现这个问题。我遇到了同样的错误,因为我认为在根目录下有 theme.conf 就足够了。也许它可以帮助别人。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-04-26
  • 2018-07-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-15
  • 1970-01-01
相关资源
最近更新 更多