Skip to content

Commit 1eefa80

Browse files
committed
draft DR-008-infra
1 parent 5b8a1e3 commit 1eefa80

1 file changed

Lines changed: 143 additions & 0 deletions

File tree

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
..
2+
Copyright (c) 2026 Contributors to the Eclipse Foundation
3+
4+
See the NOTICE file(s) distributed with this work for additional
5+
information regarding copyright ownership.
6+
7+
This program and the accompanying materials are made available under the
8+
terms of the Apache License Version 2.0 which is available at
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
SPDX-License-Identifier: Apache-2.0
12+
13+
DR-008-Infra: Generating documentation sources via Bazel
14+
========================================================
15+
16+
- **Date:** 2026-04-23
17+
18+
.. dec_rec:: Generating documentation sources via Bazel
19+
:id: dec_rec__infra__docs_src_dir
20+
:status: proposed
21+
:context: Infrastructure
22+
:decision: Option B because Option B loses wrt flexibility
23+
24+
Context / Problem
25+
-----------------
26+
27+
The docs-as-code system builds documentation by reading from a static ``source_dir`` (default ``"docs/"``) on the workspace filesystem.
28+
Three build paths coexist:
29+
30+
1. **Live preview** β€” Local development via `sphinx-autobuild <https://github.com/sphinx-doc/sphinx-autobuild>`_.
31+
2. **Direct Sphinx** β€” Sphinx invoked in the same venv for fast iteration or CI.
32+
3. **Bazel sandbox** β€” ``needs_json`` and similar targets run Sphinx in a hermetic sandbox.
33+
34+
We have no generic solution for generating parts of the documentation source directory via Bazel.
35+
See `issue 423 <https://github.com/eclipse-score/docs-as-code/issues/423>`_ for an open feature request
36+
to implement "Extra docs pages from artifacts".
37+
38+
Workarounds we already have in place are:
39+
40+
* Use ``.`` as source directory to place sources anywhere.
41+
This implies a careful maintenance of include/exclude patterns in ``conf.py``.
42+
* Generate json files for special inputs like source links or test reports.
43+
This is limiting because we cannot generate whole pages or directories with this approach.
44+
* The ``:docs_combo`` does compose a sources directory via `sphinx-collections <https://sphinx-collections.readthedocs.io/>`_.
45+
It allows no control over the folder hierarchy
46+
and symlinks in the git workspace can be confusing.
47+
48+
We look for a solution which is simpler and easier to maintain.
49+
50+
Additionally, we repeatedly has issues with caching.
51+
Since we don't rely on Bazel sandbox for docs building, Bazel cannot help with hermeticity and determinism.
52+
We need incremental builds locally and determinism with caching in CI.
53+
See `rules_python sphinxdocs <https://rules-python.readthedocs.io/en/latest/sphinxdocs+/docs/#optimization>`_
54+
how an idea how to achieve this using Bazel.
55+
56+
Goals
57+
^^^^^
58+
59+
- **Effort**: Minimise one-time implementation and ongoing maintenance cost.
60+
- **Flexibility**: Minimise the effort for potential future extensions.
61+
- **Speed**: Minimise the build time for documentation builds, especially for live preview.
62+
- ...
63+
64+
Non-Goals
65+
^^^^^^^^^
66+
67+
- Replacing Sphinx or Sphinx-Needs as documentation tools.
68+
- Keep Esbonio language server alive as we assume nobody is using it.
69+
70+
Options Considered
71+
------------------
72+
73+
Option N: No change (status quo)
74+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
75+
76+
Keep the current architecture.
77+
The ``docs()`` macro in ``docs.bzl`` accepts a ``source_dir`` parameter and reads
78+
documentation sources directly from that directory on the workspace filesystem.
79+
80+
.. mermaid::
81+
82+
graph LR
83+
docs@{ shape: docs, label: "docs/" }
84+
docs --> :docs
85+
docs --> :live_preview
86+
:live_preview -- watch --> docs
87+
88+
89+
Effort πŸ’š: No implementation work required.
90+
91+
Flexibility 😑: More workarounds instead of generic solution.
92+
93+
Speed πŸ’š: Fast but only covers source updates (not test result updates, for example).
94+
95+
96+
Option B: Introduce ``:docs_src_dir`` Bazel target
97+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
98+
99+
Add a new ``:docs_src_dir`` target that composes the documentation source
100+
directory inside Bazel using symlinks, generated files, and so on.
101+
102+
.. mermaid::
103+
104+
graph LR
105+
docs@{ shape: docs, label: "docs/" }
106+
preview@{ shape: subproc, label: "live_preview" }
107+
docs --> :docs_src_dir --> :docs --> preview
108+
preview -- rebuild --> :docs
109+
110+
The live preview is replaced by a custom implementation.
111+
This live preview cannot be executed via ``bazel run`` because of the need to rebuild via Bazel internally.
112+
Thus, there is no ``:live_preview`` target but a ``live_preview`` script.
113+
We cannot rely on watching file system changes to trigger rebuilds because the source directory is composed by Bazel
114+
and may contain generated files.
115+
116+
Effort 😑: Significant implementation effort.
117+
118+
Flexibility πŸ’š: Generic solution for all build paths and future extensions.
119+
120+
Speed: unclear
121+
122+
Evaluation
123+
----------
124+
125+
In order of importance, most important first.
126+
127+
.. csv-table::
128+
:header: Goals, Option N, Option B
129+
:widths: 2, 1, 1
130+
131+
Flexibility, 😑, πŸ’š
132+
Effort, πŸ’š, 😑
133+
Speed, πŸ’š, ?
134+
135+
**Decision:** Option B because Option B loses wrt flexibility
136+
137+
Appendix: any_folder experiment
138+
-------------------------------
139+
140+
For a brief moment, we had an ``any_folder`` extension but removed it before the docs-as-code release.
141+
It breaks when using such documentation in ``:docs_combo``:
142+
It relied on configuration in ``conf.py`` but with ``:docs_combo``
143+
the modules' ``conf.py`` is ignored and only the root ``conf.py`` is used.

0 commit comments

Comments
Β (0)