diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-01-11 00:02:38 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-01-11 21:40:09 +0900 |
commit | 32ac5f2e57ae25d8b75e93a3fca4ad74327e72c7 (patch) | |
tree | 8a6f13ae52e82c040eade975d36812b638c3cdef /sphinx/config.py | |
parent | 98993b40c5451a6db84b4c1e8549c03a9ee24677 (diff) | |
download | sphinx-git-32ac5f2e57ae25d8b75e93a3fca4ad74327e72c7.tar.gz |
Close #207: Now highlight_language supports multiple languages
This changes the structure of `highlight_options` to a dictionary that
maps language names to option dictionary. It allows to setting pygments
options for multiple languages at once.
Diffstat (limited to 'sphinx/config.py')
-rw-r--r-- | sphinx/config.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/sphinx/config.py b/sphinx/config.py index 645b09272..4c038b061 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -367,6 +367,18 @@ def convert_source_suffix(app: "Sphinx", config: Config) -> None: "But `%r' is given." % source_suffix)) +def convert_highlight_options(app: "Sphinx", config: Config) -> None: + """Convert old styled highlight_options to new styled one. + + * old style: options + * new style: dict that maps language names to options + """ + options = config.highlight_options + if options and not all(isinstance(v, dict) for v in options.values()): + # old styled option detected because all values are not dictionary. + config.highlight_options = {config.highlight_language: options} # type: ignore + + def init_numfig_format(app: "Sphinx", config: Config) -> None: """Initialize :confval:`numfig_format`.""" numfig_format = {'section': _('Section %s'), @@ -487,6 +499,7 @@ def check_master_doc(app: "Sphinx", env: "BuildEnvironment", added: Set[str], def setup(app: "Sphinx") -> Dict[str, Any]: app.connect('config-inited', convert_source_suffix, priority=800) + app.connect('config-inited', convert_highlight_options, priority=800) app.connect('config-inited', init_numfig_format, priority=800) app.connect('config-inited', correct_copyright_year, priority=800) app.connect('config-inited', check_confval_types, priority=800) |