Skip to content

👷 Integrate Typstyle into the CI #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions docs/src/reference.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion entries.typ
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
date: date,
author: author,
witness: witness,
participants: participants
participants: participants,
),
body: final-body,
))
Expand Down
21 changes: 21 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions gallery/radial.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)

]
Expand Down
12 changes: 7 additions & 5 deletions internals.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 14 additions & 0 deletions scripts/check-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -e

check_file() {
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

find ./ -type f -name "*.typ" -print0 | xargs -0 -n 1 bash -c 'check_file "$0"'
1 change: 0 additions & 1 deletion scripts/format

This file was deleted.

31 changes: 16 additions & 15 deletions themes/default/components.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions themes/linear/components/pro-con.typ
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
center,
text(size: 14pt, weight: "semibold", [Cons]),
),
pros,
cons,

pros, cons,
)
})
1 change: 1 addition & 0 deletions themes/radial/components/pro-con.typ
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
fill: red,
radius: (top: 1.5pt),
)[*Cons*],

cell(
fill: green.lighten(80%),
radius: (bottom: 1.5pt),
Expand Down
3 changes: 1 addition & 2 deletions themes/radial/components/team.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
],
)
Expand Down
5 changes: 3 additions & 2 deletions themes/radial/components/tournament.typ
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
[
#alliance.teams.at(0) \
#alliance.teams.at(1) \
], [
],
[
#set text(size: 15pt)
#set align(horizon + center)
#alliance.score
],

)
]
}
Expand All @@ -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),
Expand Down
138 changes: 101 additions & 37 deletions themes/radial/entries.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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%)
))



})

Expand Down
Loading
Loading