New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow specifying multiple CSS files in themes #10465
Allow specifying multiple CSS files in themes #10465
Conversation
…es via "stylesheet" setting
Thanks @tk0miya, this works great! Since html_style can be used to overwrite this, wouldn't it make sense to extend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also remove the private _get_style_filename
method if it is no longer used.
A
sphinx/builders/html/__init__.py
Outdated
def get_style_filenames(self) -> str: | ||
if self.config.html_style is not None: | ||
return [self.config.html_style] | ||
elif self.theme: | ||
stylesheet = self.theme.get_config('theme', 'stylesheet') | ||
return [s.strip() for s in stylesheet.split(',')] | ||
else: | ||
return ['default.css'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def get_style_filenames(self) -> str: | |
if self.config.html_style is not None: | |
return [self.config.html_style] | |
elif self.theme: | |
stylesheet = self.theme.get_config('theme', 'stylesheet') | |
return [s.strip() for s in stylesheet.split(',')] | |
else: | |
return ['default.css'] | |
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: | |
stylesheet = self.theme.get_config('theme', 'stylesheet') | |
yield from (s.strip() for s in stylesheet.split(', ')) | |
else: | |
yield 'default.css' |
sphinx/builders/html/__init__.py
Outdated
@@ -309,7 +318,9 @@ def init_highlighter(self) -> None: | |||
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(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for filename in self.get_style_filenames(): | |
for filename in self._get_style_filenames(): |
CHANGES
Outdated
* #10444: html theme: Allow to specify multiple CSS files via ``stylesheet`` | ||
setting on ``theme.conf`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* #10444: html theme: Allow to specify multiple CSS files via ``stylesheet`` | |
setting on ``theme.conf`` | |
* #10444: html theme: Allow specifying multiple CSS files through the ``stylesheet`` | |
setting in ``theme.conf`` or by setting ``html_style`` to an iterable of strings. |
# Conflicts: # doc/templating.rst # sphinx/builders/html/__init__.py # tests/test_build_html.py
Feature or Bugfix
Purpose