fix(sphinxdocs): fix path resolution for conf.py in separate directory - #4006
Merged
Merged
Conversation
rickeylev
force-pushed
the
repro_sphinx_config_path
branch
from
August 6, 2026 03:47
d1bb8b1 to
be8f311
Compare
rickeylev
marked this pull request as draft
August 6, 2026 03:48
rickeylev
force-pushed
the
repro_sphinx_config_path
branch
6 times, most recently
from
August 6, 2026 06:36
952fa5a to
02f3b10
Compare
…y and default strip_prefix Sphinx documentation builds failed when conf.py was generated or located in a separate directory because _relocate used the relative short_path of config, setting sphinx_source_dir_path to the config subdirectory rather than the source tree root. Relocate ctx.file.config to "conf.py" at the root of the generated _sources directory. Additionally, align the sphinx_docs macro implementation with its docstring so that strip_prefix defaults to native.package_name() when None, making doc files automatically relative to the rule location. Work towards bazel-contrib#3977.
rickeylev
force-pushed
the
repro_sphinx_config_path
branch
from
August 6, 2026 06:38
02f3b10 to
e75de12
Compare
rickeylev
marked this pull request as ready for review
August 6, 2026 06:49
rickeylev
enabled auto-merge
August 6, 2026 06:50
aignas
approved these changes
Aug 6, 2026
| # Though Sphinx has a -c flag, we move the config file into the sources | ||
| # directory to make the config more intuitive because some configuration | ||
| # options are relative to the config location, not the sources directory. | ||
| source_conf_file = _relocate(ctx.file.config) |
Collaborator
There was a problem hiding this comment.
I am wondering if the relocation trick should be also done for the lock rule so that the workspaces can be more easily included.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sphinx documentation builds failed when conf.py was generated or located
in a separate directory because _relocate used the relative short_path of
config, setting sphinx_source_dir_path to the config subdirectory rather
than the source tree root.
Relocate ctx.file.config using paths.basename(ctx.file.config.path) so it
is always placed at the root of the generated _sources directory.
Work towards #3977.
Fixes #3999