From f67f0747b9dfdb16b746c2f419572b2fff319d1a Mon Sep 17 00:00:00 2001 From: BattleCh1cken Date: Sat, 13 Jul 2024 20:09:31 -0400 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=91=B7=20Added=20a=20script=20to=20ch?= =?UTF-8?q?eck=20the=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- justfile | 3 +++ scripts/check-format | 12 ++++++++++++ scripts/format | 1 - 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 scripts/check-format delete mode 100755 scripts/format diff --git a/justfile b/justfile index 22c8281..99f9427 100644 --- a/justfile +++ b/justfile @@ -13,3 +13,6 @@ gallery: for f in "{{gallery_dir}}"/*.typ; do typst c "$f" --format png "${f/.typ}-{n}.png" --root ./ done + +check-format: + ./scripts/check-format diff --git a/scripts/check-format b/scripts/check-format new file mode 100755 index 0000000..73c6137 --- /dev/null +++ b/scripts/check-format @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -e + +check_file() { + echo "=============" + echo "Checking $1" + typstyle "$1" --check +} + +export -f check_file + +find ./ -type f -name "*.typ" -print0 | xargs -0 -n 1 bash -c 'check_file "$0"' diff --git a/scripts/format b/scripts/format deleted file mode 100755 index 24db378..0000000 --- a/scripts/format +++ /dev/null @@ -1 +0,0 @@ -find ./ -iname "*.typ" | xargs typstfmt From 3ab479af8e9a470b5be8101d73a31895a1390a2a Mon Sep 17 00:00:00 2001 From: BattleCh1cken Date: Sat, 13 Jul 2024 20:09:47 -0400 Subject: [PATCH 2/4] :arrow_up: Updated Typstyle --- flake.nix | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/flake.nix b/flake.nix index 11391d4..e54b581 100644 --- a/flake.nix +++ b/flake.nix @@ -26,6 +26,27 @@ cargoHash = "sha256-KD6J8dTIPaII4ISh0PW6u1EMj5JVEDYcXuZ75ycbSys="; }; + typstyle = pkgs.rustPlatform.buildRustPackage rec { + pname = "typstyle"; + version = "v0.11.29"; + + src = pkgs.fetchFromGitHub { + owner = "Enter-tainer"; + repo = pname; + rev = version; + sha256 = "sha256-7BjbML7mz5ohEdh+x6qL8pH2BTFW8WdtB0g91NHFIBY="; + }; + + nativeBuildInputs = [ + pkgs.pkg-config + ]; + + + checkFlags = [ + "--skip=e2e" + ]; + cargoHash = "sha256-m1C48OUOyUW4ANuVOhGcTYw3/nJ3WdqQ5kjQB2iLzrc="; + }; in { devShell = pkgs.mkShell { From 54dc38637eedde5012bc8d8aa6126ad2f4189603 Mon Sep 17 00:00:00 2001 From: BattleCh1cken Date: Sat, 13 Jul 2024 20:11:35 -0400 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=8E=A8=20Formatted?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/src/reference.typ | 45 ++++---- entries.typ | 2 +- gallery/radial.typ | 3 +- internals.typ | 12 ++- themes/default/components.typ | 31 +++--- themes/linear/components/pro-con.typ | 4 +- themes/radial/components/pro-con.typ | 1 + themes/radial/components/team.typ | 3 +- themes/radial/components/tournament.typ | 5 +- themes/radial/entries.typ | 138 +++++++++++++++++------- utils/components.typ | 53 +++++---- utils/theme.typ | 2 +- 12 files changed, 188 insertions(+), 111 deletions(-) diff --git a/docs/src/reference.typ b/docs/src/reference.typ index ed82d89..a70e608 100644 --- a/docs/src/reference.typ +++ b/docs/src/reference.typ @@ -13,27 +13,30 @@ #let def-arg(term, t, default: none, description) = { if type(t) == str { t = t.replace("?", "|none") - t = `<` + t.split("|").map(s => { - if s == "b" { - `boolean` - } else if s == "s" { - `string` - } else if s == "i" { - `integer` - } else if s == "f" { - `float` - } else if s == "c" { - `coordinate` - } else if s == "d" { - `dictionary` - } else if s == "a" { - `array` - } else if s == "n" { - `number` - } else { - raw(s) - } - }).join(`|`) + `>` + t = `<` + t + .split("|") + .map(s => { + if s == "b" { + `boolean` + } else if s == "s" { + `string` + } else if s == "i" { + `integer` + } else if s == "f" { + `float` + } else if s == "c" { + `coordinate` + } else if s == "d" { + `dictionary` + } else if s == "a" { + `array` + } else if s == "n" { + `number` + } else { + raw(s) + } + }) + .join(`|`) + `>` } stack( diff --git a/entries.typ b/entries.typ index e163efe..9a2fae5 100644 --- a/entries.typ +++ b/entries.typ @@ -48,7 +48,7 @@ date: date, author: author, witness: witness, - participants: participants + participants: participants, ), body: final-body, )) diff --git a/gallery/radial.typ b/gallery/radial.typ index 2f1d08a..98a7a57 100644 --- a/gallery/radial.typ +++ b/gallery/radial.typ @@ -95,8 +95,7 @@ #grid( columns: (1fr, 1fr), gutter: 20pt, - components.admonition(type: "warning")[#lorem(20)], - lorem(20), + components.admonition(type: "warning")[#lorem(20)], lorem(20), ) ] diff --git a/internals.typ b/internals.typ index a948894..d77176d 100644 --- a/internals.typ +++ b/internals.typ @@ -6,12 +6,14 @@ /// - theme (theme): /// -> content #let print-entries(theme: (:)) = { - let print-helper(section, state) = context { - for entry in state.final() { - let entry-func = theme.at(section + "-entry") - entry-func(entry.body, ctx: entry.ctx) + let print-helper(section, state) = ( + context { + for entry in state.final() { + let entry-func = theme.at(section + "-entry") + entry-func(entry.body, ctx: entry.ctx) + } } - } + ) print-helper("frontmatter", globals.frontmatter-entries) print-helper("body", globals.entries) diff --git a/themes/default/components.typ b/themes/default/components.typ index fd5d3ae..e8e1d78 100644 --- a/themes/default/components.typ +++ b/themes/default/components.typ @@ -36,22 +36,23 @@ stack( spacing: 0.5em, ..for entry in appendix { - ( - [ - #entry.title - #box( - width: 1fr, - line( - length: 100%, - stroke: ( - dash: "dotted", + ( + [ + #entry.title + #box( + width: 1fr, + line( + length: 100%, + stroke: ( + dash: "dotted", + ), ), - ), - ) - #entry.page-number - ], - ) - }) + ) + #entry.page-number + ], + ) + }, + ) }) /// Prints out the glossary. diff --git a/themes/linear/components/pro-con.typ b/themes/linear/components/pro-con.typ index 3b103ed..2f61a0f 100644 --- a/themes/linear/components/pro-con.typ +++ b/themes/linear/components/pro-con.typ @@ -21,7 +21,7 @@ center, text(size: 14pt, weight: "semibold", [Cons]), ), - pros, - cons, + + pros, cons, ) }) diff --git a/themes/radial/components/pro-con.typ b/themes/radial/components/pro-con.typ index b2e9e84..2a5c57a 100644 --- a/themes/radial/components/pro-con.typ +++ b/themes/radial/components/pro-con.typ @@ -18,6 +18,7 @@ fill: red, radius: (top: 1.5pt), )[*Cons*], + cell( fill: green.lighten(80%), radius: (bottom: 1.5pt), diff --git a/themes/radial/components/team.typ b/themes/radial/components/team.typ index fbf4a78..12a4d31 100644 --- a/themes/radial/components/team.typ +++ b/themes/radial/components/team.typ @@ -40,8 +40,7 @@ #grid( columns: (1fr, 1fr), gutter: 20pt, - align(center, member.picture), - align(left, member.about), + align(center, member.picture), align(left, member.about), ) ], ) diff --git a/themes/radial/components/tournament.typ b/themes/radial/components/tournament.typ index a48d1aa..ebc1c9d 100644 --- a/themes/radial/components/tournament.typ +++ b/themes/radial/components/tournament.typ @@ -31,12 +31,12 @@ [ #alliance.teams.at(0) \ #alliance.teams.at(1) \ - ], [ + ], + [ #set text(size: 15pt) #set align(horizon + center) #alliance.score ], - ) ] } @@ -60,6 +60,7 @@ header-cell[*Blue Alliance*], header-cell[*Auton Bonus*], header-cell(radius: (top-right: 1.5pt))[*AWP*], + cell[#match.match], alliance-info(alliance: match.red-alliance), alliance-info(alliance: match.blue-alliance), diff --git a/themes/radial/entries.typ b/themes/radial/entries.typ index 46f7c22..a200a0c 100644 --- a/themes/radial/entries.typ +++ b/themes/radial/entries.typ @@ -6,55 +6,119 @@ #import "./metadata.typ": entry-type-metadata // TODO: make an actual cover -#let cover = utils.make-cover(ctx =>{ - import components: label - let label = label.with(size: 4.7em, radius: 6pt) - - align(center + horizon, text(size: 24pt)[ - Radial Theme - ]) - - place(dx: 90pt, dy: -340pt, label("identify")) - place(dx: 52pt, dy: -295pt, label("brainstorm")) - - place(dx: 520pt, dy: 190pt, label("decide")) - place(dx: 490pt, dy: 240pt, label("build")) - place(dx: 460pt, dy: 290pt, label("test")) - - place(dx: 150pt, dy: -160pt, rect(width: 50%, height: 300pt, fill: rgb("#eeeeeeff"), radius: (right: 20pt, left: 20pt))) - - place(dx: 125pt, dy: -180pt, label("management")) - place(dx: 425pt, dy: 105pt, label("management")) +#let cover = utils.make-cover(ctx => { + import components: label + let label = label.with(size: 4.7em, radius: 6pt) + + align( + center + horizon, + text(size: 24pt)[ + Radial Theme + ], + ) - place(dx: 520pt, dy: -270pt, rect(width: 9%, height: 55pt, fill: rgb("#eeeeeeff"), radius: (right: 5pt, left: 5pt))) - place(dx: 455pt, dy: -335pt, rect(width: 9%, height: 55pt, fill: rgb("#eeeeeeff"), radius: (right: 5pt, left: 5pt))) - place(dx: 490pt, dy: -300pt, label("program")) + place(dx: 90pt, dy: -340pt, label("identify")) + place(dx: 52pt, dy: -295pt, label("brainstorm")) + + place(dx: 520pt, dy: 190pt, label("decide")) + place(dx: 490pt, dy: 240pt, label("build")) + place(dx: 460pt, dy: 290pt, label("test")) + + place( + dx: 150pt, + dy: -160pt, + rect( + width: 50%, + height: 300pt, + fill: rgb("#eeeeeeff"), + radius: (right: 20pt, left: 20pt), + ), + ) - place(dx: 55pt, dy: 205pt, rect(width: 9%, height: 55pt, fill: rgb("#eeeeeeff"), radius: (right: 5pt, left: 5pt))) - place(dx: 120pt, dy: 275pt, rect(width: 9%, height: 55pt, fill: rgb("#eeeeeeff"), radius: (right: 5pt, left: 5pt))) - place(dx: 90pt, dy: 240pt, label("notebook")) + place(dx: 125pt, dy: -180pt, label("management")) + place(dx: 425pt, dy: 105pt, label("management")) + + place( + dx: 520pt, + dy: -270pt, + rect( + width: 9%, + height: 55pt, + fill: rgb("#eeeeeeff"), + radius: (right: 5pt, left: 5pt), + ), + ) + place( + dx: 455pt, + dy: -335pt, + rect( + width: 9%, + height: 55pt, + fill: rgb("#eeeeeeff"), + radius: (right: 5pt, left: 5pt), + ), + ) + place(dx: 490pt, dy: -300pt, label("program")) + + place( + dx: 55pt, + dy: 205pt, + rect( + width: 9%, + height: 55pt, + fill: rgb("#eeeeeeff"), + radius: (right: 5pt, left: 5pt), + ), + ) + place( + dx: 120pt, + dy: 275pt, + rect( + width: 9%, + height: 55pt, + fill: rgb("#eeeeeeff"), + radius: (right: 5pt, left: 5pt), + ), + ) + place(dx: 90pt, dy: 240pt, label("notebook")) - place(dx: 165pt, dy: 200pt, line(length: 45%, stroke: 3.5pt + black)) + place(dx: 165pt, dy: 200pt, line(length: 45%, stroke: 3.5pt + black)) - place(dx: 165pt, dy: -215pt, line(length: 45%, stroke: 3.5pt + black)) + place(dx: 165pt, dy: -215pt, line(length: 45%, stroke: 3.5pt + black)) - place(dx: 250pt, dy: -280pt, text(size: 18pt)[ + place( + dx: 250pt, + dy: -280pt, + text(size: 18pt)[ *Radial Theme* - ]) + ], + ) - place(dx: 225pt, dy: -250pt, text(size: 24pt)[ + place( + dx: 225pt, + dy: -250pt, + text(size: 24pt)[ *[Game Season]* - ]) + ], + ) - place(dx: 235pt, dy: 165pt, text(size: 24pt)[ + place( + dx: 235pt, + dy: 165pt, + text(size: 24pt)[ *[Team Name]* - ]) + ], + ) + + place( + dx: 0pt, + dy: -370pt, + figure( + image("Mediamodifier-Design.svg", width: 118%), + ), + ) - place(dx: 0pt, dy: -370pt, figure( - image("Mediamodifier-Design.svg", width: 118%) - )) - }) diff --git a/utils/components.typ b/utils/components.typ index af819ee..9ef1ae1 100644 --- a/utils/components.typ +++ b/utils/components.typ @@ -44,9 +44,11 @@ let result = () for (index, entry) in state.final().enumerate() { - let page-number = counter(page).at( - markers.at(index).location(), - ).at(0) + let page-number = counter(page) + .at( + markers.at(index).location(), + ) + .at(0) let ctx = entry.ctx ctx.page-number = page-number result.push(ctx) @@ -54,17 +56,19 @@ return result } - return () => context { - let frontmatter-entries = helper("frontmatter") - let body-entries = helper("body") - let appendix-entries = helper("appendix") + return () => ( + context { + let frontmatter-entries = helper("frontmatter") + let body-entries = helper("body") + let appendix-entries = helper("appendix") - callback( - frontmatter-entries, - body-entries, - appendix-entries, - ) - } + callback( + frontmatter-entries, + body-entries, + appendix-entries, + ) + } + ) } /// Constructor for a glossary component @@ -89,12 +93,14 @@ /// - callback (function): A function that returns the content of the glossary. The function must take a `glossary` argument. /// -> function #let make-glossary(callback) = { - return () => context { - let sorted-glossary = globals.glossary-entries.final().sorted(key: ( - (word: word, definition: definition), - ) => word) - callback(sorted-glossary) - } + return () => ( + context { + let sorted-glossary = globals.glossary-entries.final().sorted(key: ( + (word: word, definition: definition), + ) => word) + callback(sorted-glossary) + } + ) } /// Constructor for a pro / con component @@ -199,9 +205,11 @@ let weighted-values = values.enumerate().map(( (index, value), - ) => value * properties.at(index).at( - "weight", - default: 1, + ) => ( + value * properties.at(index).at( + "weight", + default: 1, + ) )) let weighted-total = weighted-values.sum() @@ -294,7 +302,6 @@ "warning", "quote", "equation", - "identify", "brainstorm", "decide", diff --git a/utils/theme.typ b/utils/theme.typ index 8129f08..0f5012d 100644 --- a/utils/theme.typ +++ b/utils/theme.typ @@ -145,7 +145,7 @@ All of the constructors also perform checks to ensure that all of the types are ( "title", "type", - "author", + "author", "witness", ), str, From 19d5aaad52c7812dd8481484a3308bf6ef8c7e5f Mon Sep 17 00:00:00 2001 From: BattleCh1cken Date: Sat, 13 Jul 2024 20:54:39 -0400 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=91=B7=20Formatting=20script=20now=20?= =?UTF-8?q?tells=20you=20which=20file=20failed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/check-format | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/check-format b/scripts/check-format index 73c6137..bc1a0e4 100755 --- a/scripts/check-format +++ b/scripts/check-format @@ -2,9 +2,11 @@ set -e check_file() { - echo "=============" - echo "Checking $1" - typstyle "$1" --check + typstyle "$1" --check 1>/dev/null + if [ "$?" == 1 ]; then + echo Failed on "$1", please format the file and try again. + exit 1 + fi } export -f check_file