Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sphinxdocs/sphinxdocs/private/sphinx.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def _sphinx_source_tree_impl(ctx):
# 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)
source_conf_file = _relocate(ctx.file.config, paths.basename(ctx.file.config.path))
sphinx_source_dir_path = paths.dirname(source_conf_file.path)

for src in ctx.attr.srcs:
Expand Down
38 changes: 38 additions & 0 deletions sphinxdocs/tests/sphinx_docs_conf_in_other_dir/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs")

_TARGET_COMPATIBLE_WITH = select({
"@platforms//os:linux": [],
"@platforms//os:macos": [],
"//conditions:default": ["@platforms//:incompatible"],
})

genrule(
name = "gen_conf",
srcs = ["src_conf.py"],
outs = ["other_dir/conf.py"],
cmd = "cp $(location src_conf.py) $@",
)

sphinx_docs(
name = "docs",
srcs = ["index.md"],
config = ":gen_conf",
formats = ["html"],
sphinx = ":sphinx-build",
target_compatible_with = _TARGET_COMPATIBLE_WITH,
)

sphinx_build_binary(
name = "sphinx-build",
tags = ["manual"],
deps = [
"@dev_pip//myst_parser",
"@dev_pip//sphinx",
],
)

build_test(
name = "docs_build_test",
targets = [":docs"],
)
3 changes: 3 additions & 0 deletions sphinxdocs/tests/sphinx_docs_conf_in_other_dir/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Test Documentation

This is a test document for reproducing conf.py in a separate directory.
4 changes: 4 additions & 0 deletions sphinxdocs/tests/sphinx_docs_conf_in_other_dir/src_conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
project = "Repro Test"
copyright = "2026, Test"
author = "Test"
extensions = ["myst_parser"]