Skip to content

Commit abb7897

Browse files
committed
feat: update with more PoC work
1 parent faf0a7f commit abb7897

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

docs/design_decisions/DR-008-infra.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,21 @@ The ``score_sync_toml`` extension's write to the source directory is redirected
173173
``--define=needscfg_outpath=<workspace>/docs/ubproject.toml``,
174174
which works without modifications to the extension itself.
175175

176+
Because Sphinx sees the materialized tree rather than the original workspace files,
177+
warnings would normally cite ``bazel-out/…`` paths.
178+
This is addressed by a ``_sourcemap.json`` sidecar emitted by the ``docs_src_dir``
179+
Bazel action alongside the declared directory.
180+
The sidecar maps each materialized path back to its original workspace-relative path.
181+
A ``score_sourcemap`` Sphinx extension reads the sidecar on ``builder-inited``,
182+
then installs a ``logging.Filter`` on every Sphinx log handler that rewrites
183+
materialized paths in warning/error records before they are emitted.
184+
The filter runs after Sphinx's own ``WarningLogRecordTranslator``, which has already
185+
converted ``(docname, lineno)`` tuples to strings, so the rewrite is purely textual.
186+
The extension is a no-op when no sidecar is present (direct Sphinx invocations
187+
via ``esbonio`` or ``.venv_docs`` are unaffected).
188+
The sidecar travels with the materialized tree, so path rewriting works inside
189+
the Bazel sandbox (``bazel build``) as well as under ``bazel run`` and ``live_preview``.
190+
176191
Effort 💛: Some implementation effort but prototype already works.
177192

178193
Flexibility 💚: Generic solution for all build paths and future extensions.
@@ -251,6 +266,15 @@ Known constraints from the PoC:
251266
* Per-bundle ``ubproject.toml`` generation is workspace-only (``bazel run``),
252267
while sandboxed ``bazel build`` skips those workspace writes by design.
253268
* Nested mounts are not supported.
269+
* Sphinx warnings and errors point to the ``bazel-bin`` copy of each file,
270+
not to the original source.
271+
``sphinx-mounts`` registers the absolute path of the materialised directory
272+
(resolved from Bazel runfiles) in ``sphinx.project.Project._docname_to_path``,
273+
so that is what Sphinx embeds in its diagnostic output.
274+
The ``src_root`` mechanism only generates a ``ubproject.toml`` for IDE use;
275+
it does not change the path seen by Sphinx.
276+
This violates the hard requirement "errors and warnings point to the original
277+
source files if they are in the repo".
254278

255279
Effort 💛: Similar order of magnitude as Option B prototype work.
256280

0 commit comments

Comments
 (0)