Skip to content

fix(sphinxdocs): materialize source symlinks to resolve relative cross-references (#3977) - #4005

Open
rickeylev wants to merge 13 commits into
bazel-contrib:mainfrom
rickeylev:fix_sphinx_xref_resolution
Open

fix(sphinxdocs): materialize source symlinks to resolve relative cross-references (#3977)#4005
rickeylev wants to merge 13 commits into
bazel-contrib:mainfrom
rickeylev:fix_sphinx_xref_resolution

Conversation

@rickeylev

Copy link
Copy Markdown
Collaborator

In Sphinx with MyST, relative cross-references (myst.xref_missing)
break when resolving relative paths across symlinked source files inside
Bazel's _sources directory because Bazel symlinks resolve canonical
paths that escape the source tree.

To fix this, replaced input symlinking in _relocate with physical file
materialization in sphinx_build.py. Implemented DirectorySyncer to
concurrently synchronize files into a work-private
{srcdir}.worker-in.d directory using SHA-based change detection for
worker requests and full recursive copying for non-worker requests.

Fixes #3977

…e directory

Sphinx/MyST relative cross-reference resolution fails when input files are symlinks because os.path.realpath() resolves outside the source directory.

Add ConcurrentCopyTree in sphinx_build.py to recursively copy the source tree into a work-private '{srcdir}.worker-in.d' directory concurrently using a ThreadPoolExecutor before invoking Sphinx.
…ialization

Sphinx/MyST relative cross-reference resolution fails when input files are symlinks because os.path.realpath() resolves outside the source directory.

Add multi-threaded DirectorySyncer in sphinx_build.py supporting SHA-aware incremental sync(entries) and non-worker copytree(), forcing copied files to be user-writable and collecting errors into DirectorySyncerError. Add comprehensive unit test suite in tests/sphinx_build/.
…_create_executor helper

Improve DirectorySyncer in sphinx_build.py by using pathlib.Path objects directly, replacing numeric permission literals with stat module constants, making copied files user-writable via stat.S_IWUSR, and factoring ThreadPoolExecutor creation into a _create_executor context manager.
@rickeylev
rickeylev requested a review from aignas as a code owner August 5, 2026 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sphinxdocs: relative markdown links between pages fail to resolve (myst.xref_missing)

2 participants