summaryrefslogtreecommitdiff
path: root/sphinx/builders
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-04-06 00:23:29 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-04-06 00:23:29 +0900
commit4860b451f2abab11255ecb87449638f0113e2300 (patch)
tree9322af37c3c2682bc3f3a876408743f22330f3fe /sphinx/builders
parent50fd2ff51056d7f000a9e3ebeb7c4b6e5a84e387 (diff)
parent713bbf5cafa3fc5e143ced59dafe56f4b802ef80 (diff)
downloadsphinx-git-4860b451f2abab11255ecb87449638f0113e2300.tar.gz
Merge branch '3.x'
Diffstat (limited to 'sphinx/builders')
-rw-r--r--sphinx/builders/__init__.py2
-rw-r--r--sphinx/builders/_epub_base.py23
-rw-r--r--sphinx/builders/epub3.py2
-rw-r--r--sphinx/builders/html/__init__.py12
-rw-r--r--sphinx/builders/latex/__init__.py2
5 files changed, 21 insertions, 20 deletions
diff --git a/sphinx/builders/__init__.py b/sphinx/builders/__init__.py
index 327172961..f7da7d762 100644
--- a/sphinx/builders/__init__.py
+++ b/sphinx/builders/__init__.py
@@ -378,7 +378,7 @@ class Builder:
added, changed, removed = self.env.get_outdated_files(updated)
# allow user intervention as well
- for docs in self.events.emit('env-get-outdated', self, added, changed, removed):
+ for docs in self.events.emit('env-get-outdated', self.env, added, changed, removed):
changed.update(set(docs) & self.env.found_docs)
# if files were added or removed, all documents with globbed toctrees
diff --git a/sphinx/builders/_epub_base.py b/sphinx/builders/_epub_base.py
index 0f440dc9b..d39362eb9 100644
--- a/sphinx/builders/_epub_base.py
+++ b/sphinx/builders/_epub_base.py
@@ -278,6 +278,15 @@ class EpubBuilder(StandaloneHTMLBuilder):
Some readers crash because they interpret the part as a
transport protocol specification.
"""
+ def update_node_id(node: Element) -> None:
+ """Update IDs of given *node*."""
+ new_ids = []
+ for node_id in node['ids']:
+ new_id = self.fix_fragment('', node_id)
+ if new_id not in new_ids:
+ new_ids.append(new_id)
+ node['ids'] = new_ids
+
for reference in tree.traverse(nodes.reference):
if 'refuri' in reference:
m = self.refuri_re.match(reference['refuri'])
@@ -287,22 +296,14 @@ class EpubBuilder(StandaloneHTMLBuilder):
reference['refid'] = self.fix_fragment('', reference['refid'])
for target in tree.traverse(nodes.target):
- for i, node_id in enumerate(target['ids']):
- if ':' in node_id:
- target['ids'][i] = self.fix_fragment('', node_id)
+ update_node_id(target)
next_node = target.next_node(ascend=True) # type: Node
if isinstance(next_node, nodes.Element):
- for i, node_id in enumerate(next_node['ids']):
- if ':' in node_id:
- next_node['ids'][i] = self.fix_fragment('', node_id)
+ update_node_id(next_node)
for desc_signature in tree.traverse(addnodes.desc_signature):
- ids = desc_signature.attributes['ids']
- newids = []
- for id in ids:
- newids.append(self.fix_fragment('', id))
- desc_signature.attributes['ids'] = newids
+ update_node_id(desc_signature)
def add_visible_links(self, tree: nodes.document, show_urls: str = 'inline') -> None:
"""Add visible link targets for external links"""
diff --git a/sphinx/builders/epub3.py b/sphinx/builders/epub3.py
index 7caac74d3..b70f7b7cb 100644
--- a/sphinx/builders/epub3.py
+++ b/sphinx/builders/epub3.py
@@ -286,7 +286,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 {
diff --git a/sphinx/builders/html/__init__.py b/sphinx/builders/html/__init__.py
index 0974081dc..0e74c0df8 100644
--- a/sphinx/builders/html/__init__.py
+++ b/sphinx/builders/html/__init__.py
@@ -1227,12 +1227,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)
diff --git a/sphinx/builders/latex/__init__.py b/sphinx/builders/latex/__init__.py
index 1348f0e12..390a5d9c7 100644
--- a/sphinx/builders/latex/__init__.py
+++ b/sphinx/builders/latex/__init__.py
@@ -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'))