Skip to content

Commit

Permalink
Fix #7409: Convert configuration values on late config-inited event
Browse files Browse the repository at this point in the history
This changes a priority for config-inited handlers of core modules
to invoke them at the late of the event.  It allows extensions to
modify configurations.
  • Loading branch information
tk0miya committed Apr 5, 2020
1 parent aa1f7fb commit 18a14e4
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Bugs fixed
* #6564: html: a width of table was ignored on HTML builder
* #7401: Incorrect argument is passed for :event:`env-get-outdated` handlers
* #7355: autodoc: a signature of cython-function is not recognized well
* #7409: intersphinx: ValueError is raised when an extension sets up
:confval:`intersphinx_mapping` on :event:`config-inited` event

Testing
--------
Expand Down
2 changes: 1 addition & 1 deletion sphinx/builders/epub3.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
ENUM('horizontal', 'vertical'))

# event handlers
app.connect('config-inited', convert_epub_css_files)
app.connect('config-inited', convert_epub_css_files, priority=800)
app.connect('builder-inited', validate_config_values)

return {
Expand Down
12 changes: 6 additions & 6 deletions sphinx/builders/html/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1231,12 +1231,12 @@ def setup(app: Sphinx) -> Dict[str, Any]:
app.add_config_value('html4_writer', False, 'html')

# event handlers
app.connect('config-inited', convert_html_css_files)
app.connect('config-inited', convert_html_js_files)
app.connect('config-inited', validate_html_extra_path)
app.connect('config-inited', validate_html_static_path)
app.connect('config-inited', validate_html_logo)
app.connect('config-inited', validate_html_favicon)
app.connect('config-inited', convert_html_css_files, priority=800)
app.connect('config-inited', convert_html_js_files, priority=800)
app.connect('config-inited', validate_html_extra_path, priority=800)
app.connect('config-inited', validate_html_static_path, priority=800)
app.connect('config-inited', validate_html_logo, priority=800)
app.connect('config-inited', validate_html_favicon, priority=800)
app.connect('builder-inited', validate_math_renderer)
app.connect('html-page-context', setup_js_tag_helper)

Expand Down
2 changes: 1 addition & 1 deletion sphinx/builders/latex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
app.setup_extension('sphinx.builders.latex.transforms')

app.add_builder(LaTeXBuilder)
app.connect('config-inited', validate_config_values)
app.connect('config-inited', validate_config_values, priority=800)

app.add_config_value('latex_engine', default_latex_engine, None,
ENUM('pdflatex', 'xelatex', 'lualatex', 'platex', 'uplatex'))
Expand Down
10 changes: 5 additions & 5 deletions sphinx/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,11 @@ 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)
app.connect('config-inited', init_numfig_format)
app.connect('config-inited', correct_copyright_year)
app.connect('config-inited', check_confval_types)
app.connect('config-inited', check_primary_domain)
app.connect('config-inited', convert_source_suffix, 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)
app.connect('config-inited', check_primary_domain, priority=800)
app.connect('env-get-outdated', check_master_doc)

return {
Expand Down
2 changes: 1 addition & 1 deletion sphinx/ext/intersphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
app.add_config_value('intersphinx_mapping', {}, True)
app.add_config_value('intersphinx_cache_limit', 5, False)
app.add_config_value('intersphinx_timeout', None, False)
app.connect('config-inited', normalize_intersphinx_mapping)
app.connect('config-inited', normalize_intersphinx_mapping, priority=800)
app.connect('builder-inited', load_mappings)
app.connect('missing-reference', missing_reference)
return {
Expand Down
2 changes: 1 addition & 1 deletion sphinx/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def verify_needs_extensions(app: "Sphinx", config: Config) -> None:


def setup(app: "Sphinx") -> Dict[str, Any]:
app.connect('config-inited', verify_needs_extensions)
app.connect('config-inited', verify_needs_extensions, priority=800)

return {
'version': 'builtin',
Expand Down
2 changes: 1 addition & 1 deletion sphinx/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def merge_source_suffix(app: "Sphinx", config: Config) -> None:


def setup(app: "Sphinx") -> Dict[str, Any]:
app.connect('config-inited', merge_source_suffix)
app.connect('config-inited', merge_source_suffix, priority=800)

return {
'version': 'builtin',
Expand Down

0 comments on commit 18a14e4

Please sign in to comment.