Repository navigation
fix: docs data handling and improve bundle documentation #751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MaximilianSoerenPollak
merged 2 commits into
eclipse-score:main
from
etas-contrib:bundle-docs
Aug 26, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| .. | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
|
|
||
| Bundle examples | ||
| =============== | ||
|
|
||
| This page is a catalog of focused bundle patterns. Start with | ||
| :doc:`index` for the basic workflow; use these examples when documentation is | ||
| split across bundles, generated during the build, or published by another | ||
| Bazel module. Each example shows the bundle declaration, its placement in the | ||
| consuming project, and the resulting location in the documentation output. | ||
|
|
||
| Nest bundles | ||
| ------------ | ||
|
|
||
| Use nested bundles when one bundle contains another. The child bundle chooses | ||
| its entry page, the parent chooses the child's relative location, and the | ||
| consuming project chooses where the assembled bundle appears. | ||
|
|
||
| The tested parent bundle composes the child like this: | ||
|
|
||
| .. literalinclude:: ../../../src/tests/docs_bzl/scenarios/nested_bundles/BUILD | ||
| :language: starlark | ||
| :start-after: BEGIN docs-bundle-howto: parent-composition | ||
| :end-before: END docs-bundle-howto: parent-composition | ||
|
|
||
| See the `complete nested-bundles fixture on GitHub | ||
| <https://github.com/eclipse-score/docs-as-code/tree/main/src/tests/docs_bzl/scenarios/nested_bundles>`_. | ||
|
|
||
| If the parent is mounted at ``guides/example``, its page is rendered at | ||
| ``guides/example/index.html`` and the child landing page at | ||
| ``guides/example/child/landing.html``. The consuming project can change | ||
| ``guides/example`` without changing either bundle. | ||
|
|
||
| Mount generated documentation | ||
| ----------------------------- | ||
|
|
||
| Use a data-only bundle when a build action produces the documentation rather | ||
| than a source-tree ``.rst`` file. It has no ``source_dir``; its generated files | ||
| are the bundle's complete payload. You can generate and mount a page like this: | ||
|
|
||
| .. literalinclude:: ../../../src/tests/docs_bzl/scenarios/data_files_runfiles/BUILD | ||
| :language: starlark | ||
| :start-after: BEGIN docs-bundle-howto: generated-data | ||
| :end-before: END docs-bundle-howto: generated-data | ||
|
|
||
| See the `complete generated-data fixture on GitHub | ||
| <https://github.com/eclipse-score/docs-as-code/tree/main/src/tests/docs_bzl/scenarios/data_files_runfiles>`_. | ||
|
|
||
| The generated page is rendered at ``data_test/index.html`` and is added to the | ||
| consuming project's index page's toctree. Although this bundle is data-only, | ||
| it is mounted and navigated in exactly the same way as a bundle with source | ||
| files. | ||
|
|
||
| Mount documentation from another module | ||
| ---------------------------------------- | ||
|
|
||
| Every project using ``docs()`` exposes its own documentation as a | ||
| ``:docs_bundle`` target. The external-bundle test fixture mounts that target | ||
| like this: | ||
|
|
||
| .. literalinclude:: ../../../src/tests/docs_bzl/scenarios/external_bundle/BUILD | ||
| :language: starlark | ||
| :start-after: BEGIN docs-bundle-howto: external-bundle | ||
| :end-before: END docs-bundle-howto: external-bundle | ||
|
|
||
| See the `complete external-bundle fixture on GitHub | ||
| <https://github.com/eclipse-score/docs-as-code/tree/main/src/tests/docs_bzl/scenarios/external_bundle>`_. | ||
|
|
||
| The external bundle's entry page is rendered at ``process/index.html`` and is | ||
| added to the consuming project's index by ``attach_to``. Mounted sources also | ||
| bring their Need directives with them, so do not import the same module's | ||
| ``needs_json`` separately. | ||
|
|
||
| .. seealso:: | ||
|
|
||
| :ref:`howto_mount_external_sources` for the full mount reference and | ||
| :ref:`docs_bazel-macros` for the ``docs`` and ``docs_bundle`` attributes. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| .. | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
|
|
||
| .. _howto_mount_external_sources: | ||
|
|
||
| How to use bundles | ||
| ================== | ||
|
|
||
| This page is the getting-started guide for documentation bundles: define a | ||
| bundle, mount it in a project, compose it with other bundles, and consume a | ||
| bundle from another module. For focused patterns and test-backed examples, | ||
| see :doc:`examples`. | ||
|
|
||
| Declare a bundle | ||
| ---------------- | ||
|
|
||
| Create a ``docs_bundle`` next to the source directory that it exports: | ||
|
|
||
| .. code-block:: starlark | ||
|
|
||
| # src/BUILD | ||
| load("//:docs.bzl", "docs_bundle") | ||
|
|
||
| docs_bundle( | ||
| name = "docs_dir", | ||
| source_dir = "docs", | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
|
|
||
| ``source_dir`` is the root of the mounted tree. Its supported documentation | ||
| files are collected like those of ``docs()``; for example, | ||
| ``src/docs/overview.rst`` becomes ``overview`` within the bundle. | ||
| ``entry_doc`` names the bundle-relative page used for navigation when the | ||
| bundle is mounted. | ||
|
|
||
| Mount a bundle in a project | ||
| --------------------------- | ||
|
|
||
| Pass a placement dictionary to ``docs(bundles = [...])``: | ||
|
|
||
| .. code-block:: starlark | ||
|
|
||
| load("//:docs.bzl", "docs") | ||
|
|
||
| docs( | ||
| bundles = [ | ||
| { | ||
| "bundle": "//src:docs_dir", | ||
| "mount_at": "internals/code_docs", | ||
| }, | ||
| ], | ||
| source_dir = "docs", | ||
| ) | ||
|
|
||
| ``bundle`` identifies the ``docs_bundle`` target and ``mount_at`` selects the | ||
| docname prefix in this project. In this example, ``overview.rst`` is available | ||
| as ``internals/code_docs/overview``. | ||
|
|
||
| Every mount adds the bundle's configured entry document to a host toctree. By | ||
| default that is the ``index`` beside ``mount_at``; ``attach_to`` overrides the | ||
| host document whose first toctree receives the entry. The entry itself belongs | ||
| to the ``docs_bundle`` and defaults to ``index``. | ||
|
|
||
| The configuration has two separate responsibilities: | ||
|
|
||
| .. plantuml:: | ||
|
|
||
| @startuml | ||
| left to right direction | ||
| rectangle "docs_bundle\ncontent" as bundle | ||
| rectangle "docs(bundles = [...])\nplacement" as docs | ||
| rectangle "Rendered docs" as output | ||
| bundle --> docs : select bundle | ||
| docs --> output : mount_at / attach_to | ||
| @enduml | ||
|
|
||
| For nested composition, generated bundle data, and bundles published by | ||
| another Bazel module, see :doc:`examples`. | ||
|
|
||
| Refresh the generated project configuration | ||
| ------------------------------------------- | ||
|
|
||
| After changing ``bundles``, run either command once: | ||
|
|
||
| .. code-block:: console | ||
|
|
||
| $ bazel run //:docs | ||
| $ bazel run //:docs_check | ||
|
|
||
| Both commands refresh the repository-root ``ubproject.toml`` used by IDE tools. | ||
| ``bazel build //:needs_json`` checks the sandboxed needs build without creating | ||
| that developer-facing file. | ||
|
|
||
| Further Examples | ||
| ---------------- | ||
|
|
||
| The :doc:`examples` page shows nested composition, generated bundle data, and | ||
| the declaration for a bundle exported by another Bazel module. | ||
|
|
||
| .. toctree:: | ||
| :maxdepth: 1 | ||
| :hidden: | ||
|
|
||
| examples | ||
|
|
||
| Further reading | ||
| --------------- | ||
|
|
||
| * :ref:`docs_concept_mounts` — bundle and mount semantics. | ||
| * `sphinx-mounts documentation <https://sphinx-mounts.useblocks.com/>`_ — the underlying mechanism. |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice (for future us) to add
input => output