Commit 684d546
committed
feat: integrate sphinx-mounts for external source bundles
Wires the sphinx-mounts extension into the docs() Bazel macro so RST
or Markdown content that lives outside docs/ (generated under bazel-bin,
or in-repo next to its source code) can be surfaced in the Sphinx build
without copying or symlinking. Files stay where they live and are
visible to Sphinx via absolute paths registered through TOML.
Why the TOML angle matters: ubCode (and any non-Python tool) reads
ubproject.toml to discover the project. With mount entries in the host
TOML and a sanitized ubproject.toml at each in-repo bundle's source root,
the IDE resolves both the host and the bundle without ever invoking
Sphinx -- giving as-you-type validation that a Sphinx-mediated workflow
cannot match. This is an alternative to the materialize-a-tree approach;
both can coexist, but the mount surface is lighter-weight and IDE-friendly.
Surface added
-------------
* mount(label, mount_at, attach_to=None, entry_doc="index", src_root=None)
helper in docs.bzl. Mount entries pass through env MOUNTS as JSON,
symmetric to data = [...] / external_needs_source.
* files_to_dir Starlark rule that materialises a glob of files into a
single declared-directory output under bazel-bin (the shape that
sphinx-mounts' dir mode walks).
* score_mounts Sphinx extension that:
- parses MOUNTS, resolves runfile paths,
- sets config.mounts in-memory for sphinx-mounts at build time,
- emits a [[mounts]] fragment with portable confdir-relative paths
pointing at the *real source location* (not the bazel-bin copy),
so IDE jump-to-definition lands on the file the author wrote,
- generates a sanitized per-bundle ubproject.toml at each in-repo
bundle's src_root for ubCode's directory-walk project lookup.
* New //:docs_html sandboxed HTML build target alongside //:needs_json.
* Comprehensive how-to at docs/how-to/mount_external_sources.rst.
Demo
----
* src/docs/ ships a small "Code Docs" bundle (index, overview,
requirements). Mounted under docs/internals/code_docs/ with
attach_to = "internals/index" so the host toctree auto-extends.
* tool_req__docs_mounts (in the bundle) is referenced from the host
via :implements:, exercising cross-bundle traceability as a
first-class sphinx-needs link relation.
Required ancillary changes
--------------------------
* score_sync_toml: flip needscfg_exclude_defaults to False. needs.types,
needs.links, needs.fields were being stripped from the generated
ubproject.toml because they happen to compare equal to sphinx-needs'
declared defaults; the result was a TOML with no type catalogue, so
IDE tooling could not resolve project directives like tool_req.
* score_metamodel/metamodel.yaml: allow tool_req -> tool_req via
:implements: (existing optional_links only permitted satisfies to
gd_req/stkh_req/feat_req/comp_req).
* sphinx_mounts and tomli-w added to src/requirements.{in,txt}.1 parent c6e9f81 commit 684d546
25 files changed
Lines changed: 1420 additions & 30 deletions
File tree
- docs
- how-to
- internals/requirements
- reference
- src
- docs
- extensions
- score_metamodel
- score_mounts
- tests
- score_sphinx_bundle
- score_sync_toml
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
23 | 31 | | |
24 | 32 | | |
25 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
48 | 80 | | |
49 | 81 | | |
50 | 82 | | |
| |||
125 | 157 | | |
126 | 158 | | |
127 | 159 | | |
128 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
129 | 188 | | |
130 | 189 | | |
131 | 190 | | |
| |||
138 | 197 | | |
139 | 198 | | |
140 | 199 | | |
| 200 | + | |
| 201 | + | |
141 | 202 | | |
142 | 203 | | |
143 | 204 | | |
| |||
153 | 214 | | |
154 | 215 | | |
155 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
156 | 229 | | |
157 | 230 | | |
158 | 231 | | |
| |||
163 | 236 | | |
164 | 237 | | |
165 | 238 | | |
166 | | - | |
| 239 | + | |
167 | 240 | | |
168 | 241 | | |
169 | 242 | | |
| |||
198 | 271 | | |
199 | 272 | | |
200 | 273 | | |
201 | | - | |
202 | | - | |
| 274 | + | |
| 275 | + | |
203 | 276 | | |
204 | 277 | | |
205 | 278 | | |
206 | 279 | | |
| 280 | + | |
207 | 281 | | |
208 | 282 | | |
209 | 283 | | |
210 | 284 | | |
211 | 285 | | |
| 286 | + | |
212 | 287 | | |
213 | 288 | | |
214 | 289 | | |
| |||
304 | 379 | | |
305 | 380 | | |
306 | 381 | | |
| 382 | + | |
307 | 383 | | |
308 | 384 | | |
309 | 385 | | |
310 | 386 | | |
311 | 387 | | |
312 | | - | |
| 388 | + | |
313 | 389 | | |
314 | 390 | | |
315 | 391 | | |
316 | 392 | | |
317 | 393 | | |
318 | 394 | | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
319 | 417 | | |
320 | 418 | | |
321 | 419 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
0 commit comments