4

Background: I upgraded my repo to use python 3.9 (was 3.6). Upgraded all the packages to latest. Noticed my docs are not formatting with the sphinx-rtd-theme. See https://docs.members.loutilities.com/en/1.4.1.dev1/ as compared to https://docs.members.loutilities.com/en/1.4.0/

Reviewed the difference using chrome console, and with 1.4.0, the formatting is being done with https://docs.members.loutilities.com/en/1.4.0/_static/css/theme.css, but the theme.css file is missing in 1.4.1.dev1.

Note: reversion to old, previously working rtd-requirements.txt did not fix the issue.

repo code is in https://github.com/louking/members/tree/1.4.1.dev1/docs

specifically, conf.py has the following

# 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
        ],
     }
mzjn
  • 48,958
  • 13
  • 128
  • 248
Lou K
  • 1,128
  • 2
  • 12
  • 31

1 Answers1

5

Don't use html_context for custom style, it will break your stylesheet.

html_static_path = ['_static']
html_css_files = ['theme_overrides.css']

Should work for you.

SilverRainZ
  • 156
  • 5
  • That seemed to fix it. Did something change in readthedocs? I've been using html_context for a while in multiple repos. Or was the change in the latest sphinx_rtd_theme? I noticed after making this fix I needed to force reload the page to see the style fixes, which maybe I didn't try when I reverted to the older theme. – Lou K Aug 03 '22 at 18:24
  • I am sorry that I do not know more about this, I just had this problem once. – SilverRainZ Aug 13 '22 at 11:43