summaryrefslogtreecommitdiff
path: root/sphinx/builders/html
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2022-07-17 20:27:43 +0900
committerGitHub <noreply@github.com>2022-07-17 12:27:43 +0100
commite7fc03bce2c2577a9c5331ce5b2fa43a66ce7773 (patch)
tree30681bb1ddf2b1bb4a92d81d3f023a30cdd54b51 /sphinx/builders/html
parent8f893a625d1a2768caebc79c0e6d3e3e89c4b9e7 (diff)
downloadsphinx-git-e7fc03bce2c2577a9c5331ce5b2fa43a66ce7773.tar.gz
Allow specifying multiple CSS files in themes (#10465)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
Diffstat (limited to 'sphinx/builders/html')
-rw-r--r--sphinx/builders/html/__init__.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/sphinx/builders/html/__init__.py b/sphinx/builders/html/__init__.py
index 4a6bc6ce0..c9832d1c5 100644
--- a/sphinx/builders/html/__init__.py
+++ b/sphinx/builders/html/__init__.py
@@ -279,13 +279,16 @@ class StandaloneHTMLBuilder(Builder):
return jsfile
return None
- def _get_style_filename(self) -> str:
- if self.config.html_style is not None:
- return self.config.html_style
+ def _get_style_filenames(self) -> Iterator[str]:
+ if isinstance(self.config.html_style, str):
+ yield self.config.html_style
+ elif self.config.html_style is not None:
+ yield from self.config.html_style
elif self.theme:
- return self.theme.get_config('theme', 'stylesheet')
+ stylesheet = self.theme.get_config('theme', 'stylesheet')
+ yield from map(str.strip, stylesheet.split(','))
else:
- return 'default.css'
+ yield 'default.css'
def get_theme_config(self) -> Tuple[str, Dict]:
return self.config.html_theme, self.config.html_theme_options
@@ -324,7 +327,9 @@ class StandaloneHTMLBuilder(Builder):
def init_css_files(self) -> None:
self.css_files = []
self.add_css_file('pygments.css', priority=200)
- self.add_css_file(self._get_style_filename(), priority=200)
+
+ for filename in self._get_style_filenames():
+ self.add_css_file(filename, priority=200)
for filename, attrs in self.app.registry.css_files:
self.add_css_file(filename, **attrs)
@@ -525,6 +530,7 @@ class StandaloneHTMLBuilder(Builder):
# back up script_files and css_files to allow adding JS/CSS files to a specific page.
self._script_files = list(self.script_files)
self._css_files = list(self.css_files)
+ styles = list(self._get_style_filenames())
self.globalcontext = {
'embedded': self.embedded,
@@ -552,7 +558,8 @@ class StandaloneHTMLBuilder(Builder):
'sphinx_version': __display_version__,
'sphinx_version_tuple': sphinx_version,
'docutils_version_info': docutils.__version_info__[:5],
- 'style': self._get_style_filename(),
+ 'styles': styles,
+ 'style': styles[-1], # xref RemovedInSphinx70Warning
'rellinks': rellinks,
'builder': self.name,
'parents': [],
@@ -1356,7 +1363,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
lambda self: _('%s %s documentation') % (self.project, self.release),
'html', [str])
app.add_config_value('html_short_title', lambda self: self.html_title, 'html')
- app.add_config_value('html_style', None, 'html', [str])
+ app.add_config_value('html_style', None, 'html', [list, str])
app.add_config_value('html_logo', None, 'html', [str])
app.add_config_value('html_favicon', None, 'html', [str])
app.add_config_value('html_css_files', [], 'html')