Skip to content

style: put each attribute of a Citry UI snippet tag on its own line - #345

Merged
JuroOravec merged 1 commit into
mainfrom
chore/citry-ui-template-layout
Oct 24, 2026
Merged

JuroOravec merged 1 commit into
mainfrom
chore/citry-ui-template-layout

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

Part of #141: the snippet tag layout. Quality scenarios and runtime templates follow in a second PR, and the multiline :on* handlers in a third.

What changes

In the Citry UI docs snippets, a template tag with more than two attributes now has one attribute per line, with the closing > or /> on its own line at the tag's indent (the CLAUDE.md template rule). This applies to tags that sat on one line or put two attributes on one line. 373 tags in 260 files change:

  • 363 tags in triple-quoted templates. A script rewrote these. It changes only the whitespace between a start tag's attributes.
  • 9 one-line templates written as single-quoted or parenthesized strings become triple-quoted multiline templates. The ctree_grid/custom_cells template is reflowed onto separate lines.
  • ccarousel/controlled. This template was flattened onto one line; it is reflowed so each element starts its own line.
  • Unused noqa comments. # ruff: noqa: E501 is removed from the 24 files that no longer need it.

Proof that rendering is unchanged

I rendered every snippet and quality scenario on origin/main and on this branch: 716 pages, plus the compiled Vue definitions each snippet page loads. Render ids are made deterministic, and the per-render random app ids and signed state tokens are normalized.

  • Markup: everything outside the embedded Vue document manifest is byte-identical on all 716 pages. 485 pages are identical in full.
  • Manifests: they differ only in values computed from a tag's position in the template source: sourceStart/sourceEnd, ids hashed from those positions, and the content hashes of definitions that carry them.
    • With those values replaced, the manifests are equal under a strict one-to-one id mapping, with no list sorting, on 630 of 631 pages.
    • The exception is ctour/targeted. Its two tour steps have the same shape, so the mapping search can't tell them apart; it passes a structural check.
  • Compiled Vue render code: equal on all 562 snippet pages that load definitions.
  • Comparison sanity check: planting a real attribute change and a real handler change makes the comparison fail.
  • Dead ends: two candidate reflows changed output and were reverted. cbreadcrumbs/customization and cskeleton/motion render without Vue, so whitespace added between their elements reaches the HTML.

Kept compact, on purpose

Breaking these lines would add whitespace inside the parent element, and snippets rendered without Vue keep that whitespace in their output.

  • after another tag on the same line (36): cdate_picker/snippets/form.py:16, cdate_picker/snippets/placement.py:13, cdate_picker/snippets/states.py:16, cdate_picker/snippets/states.py:17, cnavigation_menu/snippets/variants.py:11, cskeleton/snippets/motion.py:21, cslider/snippets/marks.py:13, ctree_grid/snippets/controlled.py:21, cdate_input/snippets/birthday.py:15, cdate_input/snippets/bounds.py:17, ccolor_picker/snippets/formats.py:10, ccolor_picker/snippets/formats.py:10, ccolor_picker/snippets/native_form.py:10, ccarousel/snippets/variants.py:11, cpin_input/snippets/alphanumeric.py:15, ccalendar/snippets/natural_weeks.py:16, ccalendar/snippets/form.py:17, ccalendar/snippets/locales.py:16, ccalendar/snippets/states.py:15, ccalendar/snippets/states.py:16, ccalendar/snippets/states.py:17, ccalendar/snippets/states.py:18, cdate_range/snippets/form.py:12, cdate_range/snippets/locales.py:13, cdate_range/snippets/states.py:12, cdate_range/snippets/states.py:13, cdate_range/snippets/states.py:14, cdate_range/snippets/states.py:15, cnumber_input/snippets/forms.py:13, cnumber_input/snippets/constraints.py:10, cnumber_input/snippets/constraints.py:15, cprogress/snippets/intents.py:13, cprogress/snippets/customization.py:10, cprogress/snippets/customization.py:11, ctime_picker/snippets/form.py:12, ctime_picker/snippets/basic.py:12
  • inside text (12): cvirtual_list/snippets/controlled.py:12, cvirtual_list/snippets/controlled.py:13, ccommand_palette/snippets/form_safe_palette.py:29, ctime_input/snippets/constraints.py:12, ctime_input/snippets/constraints.py:13, ctime_input/snippets/states.py:11, ctime_input/snippets/states.py:12, cprogress/snippets/controlled.py:16, cform_collection/snippets/field_groups.py:19, cform_collection/snippets/field_groups.py:23, cform_collection/snippets/server_actions.py:31, cform_collection/snippets/at_a_glance.py:17

cbreadcrumbs/customization stays single-quoted for the same reason.

These templates are still flattened onto one line, and reflowing them is left to a follow-up: cnavigation_menu/variants, ccolor_picker/formats, ccolor_picker/native_form, ccarousel/variants, and ctree_grid/controlled.

Evidence

  • Independent review, twice, with its own stricter scripts, plus a separate prose pass. All findings are folded in.
  • packages/py/citry_ui tests pass (3114 passed, not e2e), as do the real docs build guard suite, ruff, ruff format, and the validators. The cargo phases are left to PR CI.
  • No changelog entry: this is a formatting-only change to docs snippets.

🤖 Generated with Claude Code

Part of #141 (snippets). In the Citry UI docs snippets, a template tag
with more than two attributes that sat on one line, or put two
attributes on one line, now has one attribute per line. The closing `>`
or `/>` starts its own line at the tag's indent, as CLAUDE.md asks for
template strings. 373 tags in 260 snippet files change:

- 363 tags in triple-quoted templates, rewritten by a script that
  changes only the whitespace between a start tag's attributes.
- 9 one-line templates written as single-quoted or parenthesized
  strings become triple-quoted multiline templates, and the
  ctree_grid custom_cells template is reflowed onto separate lines.
- The carousel `controlled` template, flattened onto one line, is
  reflowed so each element starts its own line, which expands its
  CCarousel tag.

The `# ruff: noqa: E501` comment is removed from the 24 files that no
longer have a line over 119 characters; 18 files keep it for other long
lines.

48 tags keep their compact form: 36 follow another tag on the same line
and 12 follow text on the same line (for example
`<label>Email <input ... />`). Breaking those lines adds whitespace inside the
parent element, and snippets rendered without Vue keep that whitespace
in their output. The cbreadcrumbs customization template stays
single-quoted for the same reason. Several templates are still
flattened onto one line (cnavigation_menu variants, ccolor_picker formats and
native_form, ccarousel variants, ctree_grid controlled); reflowing them
is left to a follow-up.

Proof: every snippet and quality scenario (716 pages) was rendered on
origin/main and on this commit. After replacing the per-render random
ids, everything outside the embedded Vue document manifest (the JSON
that tells the browser which compiled Vue definitions to load) is
byte-identical on all 716 pages, and 485 pages are identical in full.
On the others, the manifests differ only in values Citry computes from
a tag's position in the template source: `sourceStart`/`sourceEnd`
offsets, ids hashed from those positions, and the content hashes of the
definitions that carry them. With those replaced by placeholders, and
lists compared without regard to order (some lists are sorted by these
ids), the manifests are equal. The compiled Vue render code of the 562
snippet pages that load definitions is also equal under the same
mapping.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec merged commit b3491f0 into main Oct 24, 2026
20 of 26 checks passed
@JuroOravec
JuroOravec deleted the chore/citry-ui-template-layout branch October 24, 2026 22:06
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.

1 participant