Skip to content

Commit

Permalink
Fix sphinx-doc#8933: viewcode: Failed to create back-links on paralle…
Browse files Browse the repository at this point in the history
…l build

On parallel build mode, viewcode losts the back-links information on
gathering results from each process.  As a result, some back-links are
missing in the generated viewcode pages.

This fixes the merging back-links process for parallel builds.
  • Loading branch information
tk0miya committed Feb 25, 2021
1 parent 4392557 commit 255b4ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Bugs fixed
:confval:`cpp_index_common_prefix` instead of the first that matches.
* C, properly reject function declarations when a keyword is used
as parameter name.
* #8933: viewcode: Failed to create back-links on parallel build

Testing
--------
Expand Down
9 changes: 8 additions & 1 deletion sphinx/ext/viewcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,14 @@ def env_merge_info(app: Sphinx, env: BuildEnvironment, docnames: Iterable[str],
if not hasattr(env, '_viewcode_modules'):
env._viewcode_modules = {} # type: ignore
# now merge in the information from the subprocess
env._viewcode_modules.update(other._viewcode_modules) # type: ignore
for modname, entry in other._viewcode_modules.items(): # type: ignore
if modname not in env._viewcode_modules: # type: ignore
env._viewcode_modules[modname] = entry # type: ignore
else:
used = env._viewcode_modules[modname][2] # type: ignore
for fullname, docname in entry[2].items():
if fullname not in used:
used[fullname] = docname


def env_purge_doc(app: Sphinx, env: BuildEnvironment, docname: str) -> None:
Expand Down

0 comments on commit 255b4ae

Please sign in to comment.