Skip to content

feat(sphinxdocs): make SphinxDocsLibraryInfo provider public - #4041

Open
JoHoenk wants to merge 1 commit into
bazel-contrib:mainfrom
JoHoenk:joho_make_sphinx_docs_lib_available
Open

feat(sphinxdocs): make SphinxDocsLibraryInfo provider public#4041
JoHoenk wants to merge 1 commit into
bazel-contrib:mainfrom
JoHoenk:joho_make_sphinx_docs_lib_available

Conversation

@JoHoenk

@JoHoenk JoHoenk commented Aug 13, 2026

Copy link
Copy Markdown

Custom rules that produce doc files for sphinx_docs currently must depend on the private sphinx_docs_library rule implementation, since SphinxDocsLibraryInfo lives under sphinxdocs/private. Expose it via //sphinxdocs:sphinx_docs_library_info.bzl so custom rules can supply docs without that dependency.

Add a custom_docs_library test rule and output test verifying a non-sphinx_docs_library rule can supply docs to sphinx_docs through the public provider.

@JoHoenk
JoHoenk requested a review from rickeylev as a code owner August 13, 2026 20:52
Copilot AI lite review requested due to automatic review settings August 13, 2026 20:52
@JoHoenk
JoHoenk requested a review from aignas as a code owner August 13, 2026 20:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR exposes SphinxDocsLibraryInfo as a public Starlark entry point so custom rules can supply documentation inputs to sphinx_docs/sphinx_docs_library without depending on the private rule implementation, and adds a regression test proving the public provider works end-to-end.

Changes:

  • Add a new public //sphinxdocs:sphinx_docs_library_info.bzl re-export for SphinxDocsLibraryInfo.
  • Add a custom test rule that returns SphinxDocsLibraryInfo, and extend the Sphinx output test to verify the generated HTML is produced via deps.
  • Wire the new .bzl into bzl_library targets and Sphinx stardocs generation, and add a news entry.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
sphinxdocs/tests/sphinx_docs/sphinx_docs_output_test.py Adds a test asserting output contains HTML generated from docs provided via the public provider.
sphinxdocs/tests/sphinx_docs/defs.bzl Introduces custom_docs_library test rule that returns SphinxDocsLibraryInfo.
sphinxdocs/tests/sphinx_docs/BUILD.bazel Hooks custom_docs_library into sphinx_docs(deps=...) and registers the rule in the package.
sphinxdocs/sphinxdocs/sphinx_docs_library_info.bzl New public .bzl entry point re-exporting the provider from the private implementation.
sphinxdocs/sphinxdocs/private/sphinx_docs_library_info.bzl Clarifies provider field documentation around transitive semantics.
sphinxdocs/sphinxdocs/BUILD.bazel Exposes a new public bzl_library target for the provider entry point.
sphinxdocs/docs/BUILD.bazel Ensures stardocs generation includes the new public provider entry point.
news/sphinx_docs_library_info.added.md Adds release note announcing the provider as public API.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread news/sphinx_docs_library_info.added.md Outdated
Comment on lines +1 to +4
(sphinxdocs) The `SphinxDocsLibraryInfo` provider is now public API and can be
loaded from `//sphinxdocs:sphinx_docs_library_info.bzl`. This allows custom
rules to provide doc files to `sphinx_docs` and `sphinx_docs_library` without
depending on the `sphinx_docs_library` rule implementation.

@rickeylev rickeylev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. This mostly LGTM.

May I ask what sort of customized logic you are needed to implement? I'm just curious to see if there's something to consider adding to the sphinx_docs_library rule.

Comment thread news/sphinx_docs_library_info.added.md Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't do news files for sphinxdocs, so go ahead and remove this.

@@ -24,7 +24,12 @@ is prepended.
:type: depset[struct]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're making this public, lets more formally define the type be:

  • Define a SphinxDocsFileset provider with fields (a provider is used for memory efficiency; it does dict key sharing)
  • Change the annotation here to depset[SphinxDocsFileset]
  • Update the plain struct(...) calls to SphinxDocsFileset

@@ -0,0 +1,50 @@
# Copyright 2026 The Bazel Authors. All rights reserved.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming you aren't a member of the Bazel organization who is contributing the code on behalf of them and asserting their copyright, so please remove the copyright text here

strip_prefix = entry.strip_prefix,
transitive = depset(
direct = [entry],
transitive = [d[SphinxDocsLibraryInfo].transitive for d in ctx.attr.deps],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets also create a merge() function to insulate callers from having to hard-code the fields that get copied over.

 Custom rules that produce doc files for sphinx_docs currently must
 depend on the private sphinx_docs_library rule implementation, since
 SphinxDocsLibraryInfo lives under sphinxdocs/private. Expose it via
 //sphinxdocs:sphinx_docs_library_info.bzl so custom rules can supply
 docs without that dependency.

 * Define a SphinxDocsFileset provider for the entries of the transitive
   field, so it types as depset[SphinxDocsFileset] instead of
   depset[struct].
 * Add create_sphinx_docs_library_info(), which builds the provider from
   direct files plus deps, so callers don't require any inside knowledge.
 * Add a custom_docs_library test rule and output tests verifying a
   non-sphinx_docs_library rule can supply docs to sphinx_docs through
   the public provider, both directly and via deps
@JoHoenk
JoHoenk force-pushed the joho_make_sphinx_docs_lib_available branch from 7892e2c to fe291bf Compare August 14, 2026 09:59
@JoHoenk

JoHoenk commented Aug 14, 2026

Copy link
Copy Markdown
Author

Thanks for this. This mostly LGTM.

May I ask what sort of customized logic you are needed to implement? I'm just curious to see if there's something to consider adding to the sphinx_docs_library rule.

Thanks a lot for the quick review and your interest!

So reason behind it is that currently we are developing rules_score which is basically a bazel framework for generating software in a safety reated context. This means that we are structuring our software into "dependable elements" which include both code and safety documentation. And there we want to build a sphinx documentation per dependable element. A dependable element itself however can also depend on another dependable element (with its own sphinx documenation).

So that we now can wire it together in sphinx we already load from the private path the SphinxDocsLibraryInfo and we would like to make this now a (stable) public api.

Also for our case one monolithic sphinx_docs (with its one big source tree) is really an issue for scaleability, as the complete Sphinx Build - including the deps - will be rebuild due to one tiny change. That´s why we implemented smaller scale sphinx invocations (per dependable element) which we then merge afterwards in a sphinx module.

@JoHoenk
JoHoenk requested a review from rickeylev August 14, 2026 13:54
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.

3 participants