Skip to content

sphinx_docs cannot use a generated conf.py when its output path conflicts with a sibling executable target #3999

Description

@AlexanderLanin

sphinx_docs currently derives the Sphinx source directory from the path of its config label after materialising it into its private source tree.

This becomes problematic when the config is generated and the documentation source directory has the same name as another Bazel target.

Minimal example:

_generated_conf(
    name = "generated_conf",
    output_path = "docs/conf.py",
)

py_binary(
    name = "docs",
    # ...
)

sphinx_docs(
    name = "needs_json",
    config = ":generated_conf",
    # ...
)

Bazel rejects this because the generated output docs/conf.py is below the executable output docs:

One of the output paths '.../docs/conf.py' and '.../docs'
is a prefix of the other.

Using a generated config at another output path avoids the Bazel conflict, but then sphinx_docs materialises the config at that path in its private source tree and uses its parent as the Sphinx source directory. Consequently, the actual documentation sources are no longer under the selected source root.

Sphinx itself supports separating the source directory and configuration directory, but this separation is currently not expressible through sphinx_docs.

Expected behavior: a generated config should be usable without requiring its Bazel output path to be located below the documentation source directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions