-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Describe the bug
While playing at building a theme, I noticed that when I use sphinx.application.Sphinx.add_css_file, the file gets added twice in the generated HTML.
To Reproduce
Steps to reproduce the behavior:
Create a new theme and setup it with the following setup function
def setup(app):
app.require_sphinx("3")
theme_path = Path(__file__).parent.resolve()
app.add_html_theme("mytheme", str(theme_path))
# This call behaves wierdly
app.add_css_file("basic.css")add also the theme conf file:
[theme]
inherit = basic
stylesheet = mytheme.css
[options]The whether or not I'm using add_css_file("basic.css"), the generated HTML/_static folder contains
mytheme.cssbasic.css
in either case.
With add_css_file("basic.css"), the HTML <head> looks like (comment added for emphasis on duplicated link tag)
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>A theme — mytheme 0.0.1 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/mytheme.css" />
<!-- HERE notice there are two -->
<link rel="stylesheet" type="text/css" href="_static/basic.css" />
<link rel="stylesheet" type="text/css" href="_static/basic.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
</head>Without add_css_file("basic.css"), the _stagic/basic.css link tag is added 0 times.
Expected behavior
I am not sure was would be the expected behavior. Should the parent theme CSS always be added implicitely? I am not sure. But having it linked twice seams weird to me.