Merge branch '3.x' into 7410_suppress_circular_toctree_warning

This commit is contained in:
Takeshi KOMIYA 2020-04-12 15:41:25 +09:00 committed by GitHub
commit bbd673e253
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 21 deletions

View File

@ -13,6 +13,7 @@ Deprecated
Features added
--------------
* LaTeX: Make the ``toplevel_sectioning`` setting optional in LaTeX theme
* #7410: Allow to suppress "circular toctree references detected" warnings using
:confval:`suppress_warnings`

View File

@ -66,20 +66,30 @@ class BuiltInTheme(Theme):
class UserTheme(Theme):
"""A user defined LaTeX theme."""
REQUIRED_CONFIG_KEYS = ['docclass', 'wrapperclass']
OPTIONAL_CONFIG_KEYS = ['toplevel_sectioning']
def __init__(self, name: str, filename: str) -> None:
self.name = name
super().__init__(name)
self.config = configparser.RawConfigParser()
self.config.read(path.join(filename))
for key in self.REQUIRED_CONFIG_KEYS:
try:
self.docclass = self.config.get('theme', 'docclass')
self.wrapperclass = self.config.get('theme', 'wrapperclass')
self.toplevel_sectioning = self.config.get('theme', 'toplevel_sectioning')
value = self.config.get('theme', key)
setattr(self, key, value)
except configparser.NoSectionError:
raise ThemeError(__('%r doesn\'t have "theme" setting') % filename)
except configparser.NoOptionError as exc:
raise ThemeError(__('%r doesn\'t have "%s" setting') % (filename, exc.args[0]))
for key in self.OPTIONAL_CONFIG_KEYS:
try:
value = self.config.get('theme', key)
setattr(self, key, value)
except configparser.NoOptionError:
pass
class ThemeFactory:
"""A factory class for LaTeX Themes."""