sphinx-rtd-主题格式不正确 - 缺少 theme.css

Lou*_*u K 3 python-sphinx read-the-docs

背景:我升级了我的存储库以使用 python 3.9(以前是 3.6)。将所有软件包升级到最新。注意到我的文档没有使用 sphinx-rtd-theme 进行格式化。请参阅https://docs.members.loutilities.com/en/1.4.1.dev1/https://docs.members.loutilities.com/en/1.4.0/进行比较

使用 chrome 控制台查看了差异,在 1.4.0 中,格式化是通过https://docs.members.loutilities.com/en/1.4.0/_static/css/theme.css完成的,但是 theme.css 1.4.1.dev1 中缺少文件。

注意:恢复到旧的、之前工作的 rtd-requirements.txt 并不能解决问题。

回购代码位于https://github.com/louking/members/tree/1.4.1.dev1/docs

具体来说,conf.py 有以下内容

# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


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

project = 'membertility'
copyright = '2021, loutilities (Lou King)'
author = 'Lou King'

# The full version, including alpha/beta/rc tags
release = '1.0'


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

# 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_rtd_theme',
    'sphinx.ext.autodoc',
    'sphinx.ext.doctest',
    'sphinx.ext.intersphinx',
    'sphinx.ext.todo',
    'sphinx.ext.ifconfig',
    'sphinx.ext.viewcode',
    'sphinx.ext.graphviz',
]

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

# 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 = ['_build', 'Thumbs.db', '.DS_Store']


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

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
# see https://sphinx-rtd-theme.readthedocs.io/en/stable/index.html
html_theme = 'sphinx_rtd_theme'
html_theme_path = ['_themes', ]

# Theme options are theme-specific and customize the look and feel of a theme
# further.  For a list of options available for each theme, see the
# documentation.
# set navigation depth
html_theme_options = {
    'navigation_depth': -1,
    'collapse_navigation': False,
    'sticky_navigation': True,
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# https://rackerlabs.github.io/docs-rackspace/tools/rtd-tables.html

html_context = {
    'css_files': [
        '_static/theme_overrides.css',  # override wide tables in RTD theme
        ],
     }
Run Code Online (Sandbox Code Playgroud)

小智 6

不要用于html_context自定义样式,它会破坏您的样式表。

html_static_path = ['_static']
html_css_files = ['theme_overrides.css']
Run Code Online (Sandbox Code Playgroud)

应该为你工作。