运行`make html`

问题描述

我有一个项目,使用 Sphinx 与 sphinx_rtd_theme 结合生成文档。

基本上,当我运行 make html 命令来构建文档时,当我尝试打开 .html 时,它看起来就像没有 CSS 的裸 html。完全没有样式。

raw html sphinx docs page

在这里和 Github 上看到了一些发生这种情况的帖子,但这似乎与有人在 Github Pages 上托管并拥有 .nojekyll 文件有关。在我的场景中,我只是想在本地渲染它,但它仍然没有样式?

我还要注意,虽然在下面您会看到我正在尝试使用 sphinx_rtd_theme,但我尝试仅使用 html_theme = "classic",但仍然无法呈现任何样式。

谁能帮忙解决这个问题?如果有帮助,我很乐意发布更多信息。

配置文件

conf.py 如下所示。我已经包含了我认为相关的内容,并遗漏了中间用 ...标记内容

...

import codecs
import os
import re
import sys
import sphinx_rtd_theme
from recommonmark.parser import commonmarkParser

...


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


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

# If your documentation needs a minimal Sphinx version,state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here,as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
    "sphinx.ext.autodoc","sphinx.ext.doctest","sphinx.ext.todo","sphinx.ext.coverage","sphinx.ext.imgmath","sphinx.ext.viewcode","sphinx.ext.githubpages","sphinx.ext.napoleon","sphinx_rtd_theme",]

# Add any paths that contain templates here,relative to this directory.
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
source_parsers = {
    ".md": commonmarkParser,}
source_suffix = [".rst",".md"]

# The master toctree document.
master_doc = "index"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# List of patterns,relative to source directory,that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = []

# The name of the Pygments (Syntax highlighting) style to use.
pygments_style = "sphinx"


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

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"

...
相关安装版本
sphinx-rtd-theme               0.5.1
sphinxcontrib-applehelp        1.0.2
sphinxcontrib-devhelp          1.0.2
sphinxcontrib-htmlhelp         1.0.3
sphinxcontrib-jsmath           1.0.1
sphinxcontrib-qthelp           1.0.3
sphinxcontrib-serializinghtml  1.1.4
Sphinx                         3.4.3

编辑

当我运行make html时,终端中的输出如下:

(proejct_name) [...]$ make html
sphinx-apidoc -f ../project_name -o source/
Creating file source/project_name.rst.
Creating file source/modules.rst.
Regenerated API docs in ./source
sphinx-build -b html  source build/html
Running Sphinx v3.4.3
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 0 source files that are out of date
updating environment: [config changed ('source_parsers')] 8 added,0 changed,0 removed
reading sources... [100%] update_assumptions                                                                                                                                                       
looking for Now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] update_assumptions                                                                                                                                                        
generating indices... genindex py-modindex done
highlighting module code... [100%] project_name.utilities                                                                                                                        
writing additional pages... search done
copying images... [100%] _static/update_assumptions.png                                                                                                                                            
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded.

The HTML pages are in build/html.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)