-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin' into feature-linear-theme
- Loading branch information
Showing
14 changed files
with
258 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Tests | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- name: Install just from crates.io | ||
uses: baptiste0928/cargo-install@v2 | ||
with: | ||
crate: just | ||
- name: Install Typst | ||
uses: yusancky/setup-typst@v3 | ||
id: setup-typst | ||
- name: Run checks | ||
run: | | ||
just install | ||
just docs | ||
# TODO: run unit tests here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright © 2024 Felix Hass | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
typstfmt.packages.${system}.default | ||
pkgs.act | ||
pkgs.nodePackages_latest.prettier | ||
pkgs.just | ||
]; | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package target: | ||
./scripts/package "{{target}}" | ||
|
||
install: | ||
./scripts/package "@local" | ||
|
||
docs: | ||
typst compile docs.typ docs.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
# Credit to the Cetz package for this script | ||
# https://github.com/johannes-wolf/cetz/blob/master/scripts/package | ||
|
||
PKG_PREFIX="notebookinator" | ||
|
||
# List of all files that get packaged | ||
files=( | ||
lib.typ | ||
entries.typ | ||
glossary.typ | ||
utils.typ | ||
globals.typ | ||
internals.typ | ||
themes/ | ||
typst.toml | ||
LICENSE | ||
README.md | ||
docs.typ | ||
docs-template.typ | ||
docs.pdf | ||
) | ||
|
||
# Local package directories per platform | ||
if [[ "$OSTYPE" == "linux"* ]]; then | ||
DATA_DIR="${XDG_DATA_HOME:-$HOME/.local/share}" | ||
elif [[ "$OSTYPE" == "darwin"* ]]; then | ||
DATA_DIR="$HOME/Library/Application Support" | ||
else | ||
DATA_DIR="${APPDATA}" | ||
fi | ||
|
||
if (( $# < 1 )) || [[ "${1:-}" == "help" ]]; then | ||
echo "package TARGET" | ||
echo "" | ||
echo "Packages all relevant files into a directory named '${PKG_PREFIX}/<version>'" | ||
echo "at TARGET. If TARGET is set to @local, the local Typst package directory" | ||
echo "will be used so that the package gets installed for local use." | ||
echo "The version is read from 'typst.toml' in the project root." | ||
echo "" | ||
echo "Local package prefix: $DATA_DIR/typst/package/local" | ||
exit 1 | ||
fi | ||
|
||
function read-toml() { | ||
local file="$1" | ||
local key="$2" | ||
# Read a key value pair in the format: <key> = "<value>" | ||
# stripping surrounding quotes. | ||
perl -lne "print \"\$1\" if /^${key}\\s*=\\s*\"(.*)\"/" < "$file" | ||
} | ||
|
||
SOURCE="$(cd "$(dirname "$0")"; pwd -P)/.." # macOS has no realpath | ||
TARGET="${1:?Missing target path or @local}" | ||
VERSION="$(read-toml "$SOURCE/typst.toml" "version")" | ||
|
||
if [[ "$TARGET" == "@local" ]] || [[ "$TARGET" == "install" ]]; then | ||
TARGET="${DATA_DIR}/typst/packages/local/" | ||
echo "Install dir: $TARGET" | ||
fi | ||
|
||
TMP="$(mktemp -d)" | ||
|
||
for f in "${files[@]}"; do | ||
mkdir -p "$TMP/$(dirname "$f")" 2>/dev/null | ||
cp -r "$SOURCE/$f" "$TMP/$f" | ||
done | ||
|
||
TARGET="${TARGET:?}/${PKG_PREFIX:?}/${VERSION:?}" | ||
echo "Packaged to: $TARGET" | ||
if rm -rf "${TARGET:?}" 2>/dev/null; then | ||
echo "Overwriting existing version." | ||
fi | ||
mkdir -p "$TARGET" | ||
mv "$TMP"/* "$TARGET" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
#import "./headings.typ": * | ||
#import "./code-blocks.typ": * | ||
#import "./title.typ": * | ||
|
||
#import "./toc.typ": * | ||
#import "./glossary.typ": * | ||
|
||
#import "./admonitions.typ": * | ||
#import "./pro-con.typ": * | ||
#import "./decision-matrix.typ": * | ||
#import "./tournament.typ": * | ||
#import "./graphs.typ": * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#import "../colors.typ": * | ||
|
||
#import "@preview/cetz:0.1.2" | ||
|
||
/// Creates a labeled pie chart. | ||
/// | ||
/// Example Usage: | ||
/// | ||
/// ```typ | ||
/// #pie_chart( | ||
/// (8, green, "wins"), | ||
/// (2, red, "losses") | ||
/// ) | ||
/// ``` | ||
/// | ||
/// - ..data (array): Each array must contain 3 fields. | ||
/// + `<integer>` The value of the section | ||
/// + `<color>` The value of the section | ||
/// + `<string>` The name of the section | ||
/// Here's an example of one of these arrays: | ||
/// `(2, blue, "bicycles")` | ||
/// -> content | ||
#let pie_chart(..data) = { | ||
let total; | ||
let percentages = (); | ||
|
||
for value in data.pos() { | ||
total += value.at(0); | ||
} | ||
|
||
for value in data.pos() { | ||
percentages.push(calc.round(value.at(0) / total * 100)) | ||
} | ||
|
||
cetz.canvas( | ||
{ | ||
import cetz.draw: * | ||
|
||
let chart(..values, name: none) = { | ||
let values = values.pos() | ||
let anchor_angles = () | ||
|
||
let offset = 0 | ||
let total = values.fold(0, (s, v) => s + v.at(0)) | ||
|
||
let segment(from, to) = { | ||
merge-path(close: true, { | ||
stroke((paint: black, join: "round", thickness: 0pt)) | ||
line((0, 0), (rel: (360deg * from, 2))) | ||
arc((), start: from * 360deg, stop: to * 360deg, radius: 2) | ||
}) | ||
} | ||
|
||
let chart = group(name: name, { | ||
stroke((paint: black, join: "round")) | ||
|
||
for v in values { | ||
fill(v.at(1)) | ||
let value = v.at(0) / total | ||
|
||
// Draw the segment | ||
segment(offset, offset + value) | ||
|
||
// Place an anchor for each segment | ||
let angle = offset * 360deg + value * 180deg | ||
anchor(v.at(2), (angle, 1.75)) | ||
anchor_angles.push(angle) | ||
|
||
offset += value | ||
} | ||
}) | ||
|
||
return (chart, anchor_angles) | ||
} | ||
|
||
// Draw the chart | ||
let (chart, angles) = chart(..data, name: "chart") | ||
|
||
chart | ||
|
||
set-style(mark: (fill: white, start: "o", stroke: black), content: (padding: .1)) | ||
for (index, value) in data.pos().enumerate() { | ||
let anchor = "chart." + value.at(2) | ||
let angle = angles.at(index) | ||
|
||
let (line_end, anchor_direction) = if angle > 90deg and angle < 275deg { | ||
((-0.5, 0), "right") | ||
} else { | ||
((0.5, 0), "left") | ||
} | ||
|
||
line(anchor, (to: anchor, rel: (angle, 0.5)), (rel: line_end)) | ||
|
||
content((), [#value.at(2)], anchor: "bottom-" + anchor_direction) | ||
content((), [ #percentages.at(index)% ], anchor: "top-" + anchor_direction) | ||
} | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters