Skip to content

🐛 Ignore comments/targets in component child validation#271

Merged
chrisjsewell merged 1 commit into
mainfrom
brief/07-child-warnings
Jul 12, 2026
Merged

🐛 Ignore comments/targets in component child validation#271
chrisjsewell merged 1 commit into
mainfrom
brief/07-child-warnings

Conversation

@chrisjsewell

@chrisjsewell chrisjsewell commented Jul 12, 2026

Copy link
Copy Markdown
Member

Closes #86. Comments, hyperlink targets, and system messages inside grid, card-carousel, tab-set, and tab-set-code no longer trigger the confusing "All children of X should be Y" warnings.

  • New is_ignorable_child helper in shared.py (comment/target/system_message), applied in all four child-validation loops; behaviour for genuinely invalid children unchanged (existing Fix ValueError crash when tab-set contains non-tab-item children #258 regression passes as-is).
  • Targets are preserved through both tab-set child rebuilds (TabSetDirective and TabSetHtmlTransform), so references to a target placed before a tab-item still resolve; the HTML transform now enumerates only tab-items for the selected-index logic, so a leading target no longer shifts the default-checked tab.
  • Five new test cases (rst + myst parametrized): comment in each container type builds warning-free; target-before-tab-item resolves; control case asserting a bare paragraph in a tab-set still warns with [design.tab].

Validation: tox -e py311 (119 passed), mypy, ruff check, ruff format --check — all green; no regression files changed.

Comments, hyperlink targets, and system messages are structurally
inert, so they are now silently tolerated as children of the grid,
card-carousel, tab-set, and tab-set-code directives, rather than
emitting a confusing "All children of X should be Y" warning.

Hyperlink targets inside a tab-set are additionally preserved, both
when the directive rebuilds its children and when TabSetHtmlTransform
restructures the tab-set for HTML output (targets are moved to the
front of the rebuilt node), so that references to them still resolve.

Closes #86
@chrisjsewell chrisjsewell merged commit aa59d89 into main Jul 12, 2026
23 checks passed
@chrisjsewell chrisjsewell deleted the brief/07-child-warnings branch July 12, 2026 13:25
chrisjsewell pushed a commit that referenced this pull request Jul 12, 2026
The rst/myst comment/target tests added in #271 broke the
py311-no-myst tox env (not run in CI); guard the myst variants
with the same skipif pattern used in test_snippets.
chrisjsewell added a commit that referenced this pull request Jul 12, 2026
All global configuration is declared once on a dataclass with typed,
TOML-compatible fields, per-field validators and help text (modelled
on myst-parser's MdParserConfig). Flat sd_* confvals remain the public
interface; modules read via a typed get_sd_config accessor; invalid
values warn under design.config and fall back to defaults, with
per-entry pruning for sd_custom_directives. Also guards the
myst-parametrized tests from #271 so the no-myst tox env passes.
chrisjsewell pushed a commit that referenced this pull request Jul 12, 2026
Follow-up to #271, which preserved target nodes but not their anchors:

- docutils PropagateTargets moves a preceding target's ids onto the
  tab-item container, which TabSetHtmlTransform destroys — copy the
  container's ids onto the rendered label so href targets exist
- tab-set-code dropped targets entirely (asymmetric with tab-set) —
  preserve them the same way
- strengthen the target test to assert a rendered node carries the id
  and that it appears in the built HTML (the previous assertions
  passed against the broken output); add a tab-set-code variant
- get_started: clarify that examples may need extending
  myst_enable_extensions beyond the snippet shown
chrisjsewell added a commit that referenced this pull request Jul 12, 2026
Follow-up to #271: carry container-propagated target ids onto the
rendered tab label, and preserve targets in tab-set-code, so anchors
to targets inside tab components actually exist in HTML output.
Tests now assert the rendered id in built HTML.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

comments inside a grid generate confusing warnings

1 participant