Skip to content

Commit

Permalink
Move tasks into parallel writing
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Jan 2, 2023
1 parent 087522c commit b32841e
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions sphinx/builders/html/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,12 +655,18 @@ def get_doc_context(self, docname: str, body: str, metatags: str) -> dict[str, A
}

def write_doc(self, docname: str, doctree: nodes.document) -> None:
self.imgpath = relative_uri(self.get_target_uri(docname), self.imagedir)
self.post_process_images(doctree)

title_node = self.env.longtitles.get(docname)
title = self.render_partial(title_node)['title'] if title_node else ''
self.index_page(docname, doctree, title)

destination = StringOutput(encoding='utf-8')
doctree.settings = self.docsettings

self.secnumbers = self.env.toc_secnumbers.get(docname, {})
self.fignumbers = self.env.toc_fignumbers.get(docname, {})
self.imgpath = relative_uri(self.get_target_uri(docname), '_images')
self.dlpath = relative_uri(self.get_target_uri(docname), '_downloads')
self.current_docname = docname
self.docwriter.write(doctree, destination)
Expand All @@ -671,13 +677,6 @@ def write_doc(self, docname: str, doctree: nodes.document) -> None:
ctx = self.get_doc_context(docname, body, metatags)
self.handle_page(docname, ctx, event_arg=doctree)

def write_doc_serialized(self, docname: str, doctree: nodes.document) -> None:
self.imgpath = relative_uri(self.get_target_uri(docname), self.imagedir)
self.post_process_images(doctree)
title_node = self.env.longtitles.get(docname)
title = self.render_partial(title_node)['title'] if title_node else ''
self.index_page(docname, doctree, title)

def finish(self) -> None:
self.finish_tasks.add_task(self.gen_indices)
self.finish_tasks.add_task(self.gen_pages_from_extensions)
Expand Down Expand Up @@ -904,7 +903,7 @@ def post_process_images(self, doctree: Node) -> None:
"""Pick the best candidate for an image and link down-scaled images to
their high res version.
"""
Builder.post_process_images(self, doctree)
super().post_process_images(doctree)

if self.config.html_scaled_image_link and self.html_scaled_image_link:
for node in doctree.findall(nodes.image):
Expand Down

0 comments on commit b32841e

Please sign in to comment.