From cd56437d66865a2b3d52a57cb541854ec594be9d Mon Sep 17 00:00:00 2001 From: Erik Takke Date: Sat, 3 Jan 2026 15:19:30 +0100 Subject: [PATCH 1/3] spec: conditionally render constraint table headers --- spec/chip.typ | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/spec/chip.typ b/spec/chip.typ index 30b93373c..267aad258 100644 --- a/spec/chip.typ +++ b/spec/chip.typ @@ -160,6 +160,7 @@ groups = (groups,) } assert(groups.all(group => group in all_groups), message: "unknown group") + let selected_constraints = chip.constraints.pairs().filter(p => p.first() in groups).map(p => p.last()).flatten(); // Find the group definition in the constraint_groups let lookup_group(name) = chip.constraint_groups.filter((g) => g.name == name).at(0, default: (name: name)) @@ -220,13 +221,26 @@ (table.cell(align: right, colspan: 2, [_description_]), eval(constraint.desc, mode: "markup"), []) } + // Whether there is at least one constraint with a range + // This can be used to see whether the "Range" label should be displayed + let do_display_range = selected_constraints.any(x => "range" in x) + + // Whether there is at least one constraint with a multiplicity + // This can be used to see whether the "Multiplicity" label should be displayed + let do_display_multiplicity = selected_constraints.any(x => "multiplicity" in x) + show figure: set block(breakable: true) figure(table( columns: (auto, auto, 1fr, auto), inset: 6pt, align: (top + left, top + left, top + left, top + center), stroke: none, - table.header([*Tag*], [*Range*], [*Description*], [*Multiplicity*]), + table.header( + [*Tag*], + if do_display_range {[*Range*]} else {[]}, + [*Description*], + if do_display_multiplicity {[*Multiplicity*]} else {[]}, + ), table.hline(stroke: stroke(thickness: 2pt)), ..for group in groups { for constraint in chip.constraints.at(group) { From 87a4a191379430779635f48f9b9762b368462492 Mon Sep 17 00:00:00 2001 From: Erik Takke Date: Mon, 5 Jan 2026 15:06:43 +0100 Subject: [PATCH 2/3] spec: simplify `selected_constraints` expression --- spec/chip.typ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/chip.typ b/spec/chip.typ index 267aad258..53560c3f1 100644 --- a/spec/chip.typ +++ b/spec/chip.typ @@ -160,7 +160,7 @@ groups = (groups,) } assert(groups.all(group => group in all_groups), message: "unknown group") - let selected_constraints = chip.constraints.pairs().filter(p => p.first() in groups).map(p => p.last()).flatten(); + let selected_constraints = groups.map(g => chip.constraints.at(g)).flatten(); // Find the group definition in the constraint_groups let lookup_group(name) = chip.constraint_groups.filter((g) => g.name == name).at(0, default: (name: name)) From e13120773e4c116ad7cee5b78bb9978b91828339 Mon Sep 17 00:00:00 2001 From: Erik Takke Date: Mon, 5 Jan 2026 15:40:27 +0100 Subject: [PATCH 3/3] spec: repurpose `selected_constraints` --- spec/chip.typ | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/chip.typ b/spec/chip.typ index 53560c3f1..772078abd 100644 --- a/spec/chip.typ +++ b/spec/chip.typ @@ -160,7 +160,7 @@ groups = (groups,) } assert(groups.all(group => group in all_groups), message: "unknown group") - let selected_constraints = groups.map(g => chip.constraints.at(g)).flatten(); + let selected_constraints = groups.map(g => (g: chip.constraints.at(g))).join() // Find the group definition in the constraint_groups let lookup_group(name) = chip.constraint_groups.filter((g) => g.name == name).at(0, default: (name: name)) @@ -223,11 +223,11 @@ // Whether there is at least one constraint with a range // This can be used to see whether the "Range" label should be displayed - let do_display_range = selected_constraints.any(x => "range" in x) + let do_display_range = selected_constraints.values().flatten().any(x => "range" in x) // Whether there is at least one constraint with a multiplicity // This can be used to see whether the "Multiplicity" label should be displayed - let do_display_multiplicity = selected_constraints.any(x => "multiplicity" in x) + let do_display_multiplicity = selected_constraints.values().flatten().any(x => "multiplicity" in x) show figure: set block(breakable: true) figure(table( @@ -242,8 +242,8 @@ if do_display_multiplicity {[*Multiplicity*]} else {[]}, ), table.hline(stroke: stroke(thickness: 2pt)), - ..for group in groups { - for constraint in chip.constraints.at(group) { + ..for (group, group_constraints) in selected_constraints.pairs() { + for constraint in group_constraints { ( [#tag(constraint, lookup_group(group))], [#interval(constraint)], @@ -257,6 +257,6 @@ render_polynomial_constraints(constraint) } } - }, + } ), caption: [Constraint overview of #chip.name chip.]) }