Skip to content

fix: round-trip the credit-words justify attribute - #300

Merged
webern merged 2 commits into
mainfrom
credit-words-justify
Jul 5, 2026
Merged

fix: round-trip the credit-words justify attribute#300
webern merged 2 commits into
mainfrom
credit-words-justify

Conversation

@webern

@webern webern commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Human Summary

Looks like a straightforward and correct fix for a missing attribute to me.

Summary

The api round-trip dropped the justify attribute of <credit-words>: PageTextData had no field for it, so the impl reader never captured it and the writer never emitted it.

  • PageTextData (src/include/mx/api/PageTextData.h) gains a justify field using the existing HorizontalAlignment enum, with unspecified meaning the attribute is absent — the same idiom as its neighboring halign field (positionData.horizontalAlignmnet). justify is kept separate from halign because MusicXML defines both attributes on <credit-words>.
  • PageTextFunctions.cpp reads justify off the core FormattedTextID and writes it back, through the existing Converter halignMap (core::LeftCenterRight <-> api::HorizontalAlignment). No new enum and no new converter entries.

Non-breaking: one new defaulted field plus its equality line.

Testing

  • New unit tests in CreditRoundTripTest.cpp: justify="center" survives the api round trip and appears in the serialized XML; an absent justify stays absent (no attribute emitted)
  • Verified on the issue's repro: lysuite/ly52a_PageLayout.xml now surfaces justify=center in PageTextData and re-emits justify="center" — the file now survives the strict DOM compare entirely and is pinned in the baseline (121 -> 122 files, make test-api-roundtrip: 122 passed, 0 failed)
  • The other two candidate files (foundsuite Adagio and Fugue K.546, musetrainer Canon_in_D) no longer diverge at credit-words@justify; they remain blocked by unrelated gaps, so they are not pinned
  • Full unit suite passes (4465 assertions in 348 test cases), make fmt / make check clean

References

The api dropped the justify attribute of <credit-words>: PageTextData had
no field for it, so the impl reader never captured it and the writer never
emitted it.

- Add PageTextData::justify using the existing HorizontalAlignment enum
  (unspecified = attribute absent). Kept separate from positionData's
  halign because MusicXML defines both attributes on <credit-words>.
- Read/write it in PageTextFunctions via the existing Converter halignMap
  (core::LeftCenterRight <-> api::HorizontalAlignment); no new enum or
  converter entries.
- Unit tests: justify=center survives the round trip and appears in the
  serialized XML; an absent justify stays absent.
- Baseline: lysuite/ly52a_PageLayout.xml now survives the strict compare
  (its only divergence was the dropped attribute); pinned count 121 -> 122.

Closes #273
@webern webern added bug software defect api Affects the mx::api layer impl Affects the mx::impl layer ai Issues opened by, or through, a coding agent. labels Jul 5, 2026 — with Claude
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

Coverage report

Core-dev coverage src/private/mx/core/

Metric Coverage Covered / Total
Lines 77.8% 28487 / 36624
Functions 74.3% 6349 / 8550
Branches 50.6% 22632 / 44725

API coverage src/private/mx/{api,impl,utility}/

Metric Coverage Covered / Total
Lines 78.7% 6121 / 7780
Functions 64.3% 2091 / 3252
Branches 47.9% 5214 / 10876

Core HTML report | API HTML report

Commit 4182071428a0e060f345ac23c3e854217e41a48e.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

gen-quality gen/

gen-quality: 84.5 / 100   (floor 84.5, +0.0)

  structure     86.5  x0.50   [fn 90.5 / file 82.6]
  cyclomatic    88.4  x0.25
  cognitive     76.6  x0.25

  409 functions across 31 files, 7702 lines (largest file 1044)
  max cc 56  max cognitive 44  max fn loc 152

Worst offenders (top 5 per axis; full lists in score.json):
  cyclomatic gen/xsd/analyze.py:311     report                             56
  cyclomatic gen/plates/build.py:956    _validate_config_against_ir        35
  cyclomatic gen/press/context.py:145   plate_context                      34
  cyclomatic gen/__main__.py:46         _ir                                23
  cyclomatic gen/tests/test_ir.py:102   _check_references                  20
  cognitive  gen/xsd/analyze.py:311     report                             44
  cognitive  gen/ir/resolve.py:119      flat_elements                      40
  cognitive  gen/tests/test_ir.py:102   _check_references                  38
  cognitive  gen/press/context.py:145   plate_context                      37
  cognitive  gen/xsd/analyze.py:207     _sccs                              37
  size       gen/xsd/analyze.py:311     report                             152
  size       gen/press/context.py:145   plate_context                      96
  size       gen/plates/build.py:533    _value_plate                       89
  size       gen/plates/build.py:956    _validate_config_against_ir        89
  size       gen/ir/resolve.py:119      flat_elements                      78

Commit 4182071428a0e060f345ac23c3e854217e41a48e.

@webern
webern marked this pull request as ready for review July 5, 2026 10:09
@webern
webern merged commit c3dbc56 into main Jul 5, 2026
0 of 7 checks passed
@webern
webern deleted the credit-words-justify branch July 5, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai Issues opened by, or through, a coding agent. api Affects the mx::api layer bug software defect impl Affects the mx::impl layer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

api: round-trip drops credit-words justify attribute

1 participant