📚 Number syntax-example rubrics in the ubCode preview - #1747
Open
chrisjsewell wants to merge 1 commit into
Open
Conversation
Set `syntax_example_numbering = true` under `[parse]` in `docs/ubproject.toml`, mirroring the confval of the same name already set in `docs/conf.py` (#1746). The ubCode engine gained the option in useblocks/ubcode#2487, so its preview now numbers the example rubrics ("Example 1", "Example 2", ...) the way the Sphinx build does. The key is inert on ubCode builds that predate #2487: `ParseConfig` carries `#[serde(default)]` without `deny_unknown_fields`, so an unknown `[parse]` key is ignored rather than reported. The same is true of the `extensions` gate on the line above, which is likewise not in a release yet — both take effect together whenever the next ubCode ships. Nothing on the Sphinx side reads `[parse]`: `needs_from_toml` navigates straight to the `needs` table (`sphinx_needs/needs.py:471`) and ignores every other top-level table.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1747 +/- ##
==========================================
+ Coverage 86.87% 89.43% +2.55%
==========================================
Files 56 73 +17
Lines 6532 10618 +4086
==========================================
+ Hits 5675 9496 +3821
- Misses 857 1122 +265
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
The follow-up promised in #1746. That PR migrated the docs to the shared
sphinx-syntax-exampledirective and setsyntax_example_numbering = Truein
docs/conf.py, so the Sphinx build renders the example rubrics as"Example 1", "Example 2", … exactly as the old bespoke
need-exampledirectivedid. The ubCode engine had no counterpart option at the time, so its preview
rendered the same blocks with unnumbered rubrics.
useblocks/ubcode#2487 has since landed, adding
[parse].syntax_example_numbering. This PR sets it, so both engines produce thesame rubric text from the same sources.
The change
Three lines in
docs/ubproject.toml, next to theextensionsgate added in #1746:Compatibility with older ubCode builds
Unknown
[parse]keys are ignored, not an error — this is safe to mergebefore the option reaches a release.
ParseConfigderivesDeserializewith#[serde(default)]and no#[serde(deny_unknown_fields)](rust/ubc_config/src/parse.rs:14-15), so serdedrops keys it does not recognise. Verified against both current release tags:
deny_unknown_fieldsonParseConfigsyntax_example_numbering[parse].extensionsv0.30.3(latest stable, 2026-07-01)pre/v0.31.0b1(latest prerelease, 2026-07-16)main(with #2487)Two supporting checks:
(
rust/ubc_config/tests/fixtures/unknown_data.toml), and its snapshot(
test_config_read__from_config_unknown_data.toml.snap) records a plain"ok"result with no diagnostic — unknown data loads cleanly;"$schema"points at does not setadditionalProperties: falseonParseConfig, so schema-aware editors willnot flag the key either.
Worth noting: the
extensions = ["sphinx_syntax_example"]line merged in #1746is in exactly the same position —
[parse].extensionsarrived inuseblocks/ubcode#2381 and is also not in any release tag yet. So this PR does not
introduce a new class of forward reference; it adds a second key alongside an
existing one, and both start taking effect together on the first ubCode release
that includes #2381 and #2487 (i.e. the next one after
v0.30.3/pre/v0.31.0b1).Sphinx build impact: none
docs/ubproject.tomlis also read by the Sphinx build (docs/conf.py:301sets
needs_from_toml = "ubproject.toml"), but only the[needs]table isconsulted:
load_config_from_tomlnavigates straight to it(
sphinx_needs/needs.py:471-472,for key in (*toml_path, "needs"), withneeds_from_toml_tabledefaulting to[]—sphinx_needs/config.py:494-496)and never sees any other top-level table. Confirmed by parsing the file before
and after: the
[needs]table the loader resolves is unchanged, andparseisnot reachable from it.
TOML validity checked with
tomllib;taplo-formatpasses.