Skip to content
Merged
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
32 changes: 28 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install just
uses: taiki-e/install-action@v2
with:
tool: just

- name: Install tytanic (binary)
if: ${{ !contains(matrix.typst-version.tytanic, '-rc') }}
uses: taiki-e/install-action@v2
Expand All @@ -48,8 +53,7 @@ jobs:
tool: tytanic@${{ matrix.typst-version.tytanic }}

- name: Run test suite
id: run-suite
run: tt run --no-fail-fast --max-delta 1
run: just test

- name: Archive artifacts
uses: actions/upload-artifact@v4
Expand All @@ -62,6 +66,26 @@ jobs:
tests/**/ref/*.png
retention-days: 5

formatting:
name: Check formatting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install just
uses: taiki-e/install-action@v2
with:
tool: just

- name: Install typstyle
uses: taiki-e/install-action@v2
with:
tool: typstyle@0.13

- name: Check formatting
run: just check-format

assets:
name: Check assets and documentation
runs-on: ubuntu-latest
Expand All @@ -77,7 +101,7 @@ jobs:
- name: Install typst
uses: typst-community/setup-typst@v3
with:
typst-version: 0.12
typst-version: 0.13

- name: Check assets
run: just generate
run: just check-doc
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@

---

# [v0.6.2](https://github.com/tingerrr/hydra/releases/tags/v0.6.2)
## Changed
- Bumped `oxifmt` from `0.2.1` to `1.0.0`
- Bumped `mantys` from `1.0.0` to `1.0.2`

## Fixed

---

# [v0.6.1](https://github.com/tingerrr/hydra/releases/tags/v0.6.1)
## Fixed
- Use the correct page length when calculating the top margin
Expand Down
104 changes: 75 additions & 29 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,83 +10,129 @@ thumbnail := images / 'thumbnail'
export TYPST_ROOT := justfile_directory()
export TYPST_FONT_PATHS := fonts

prompt := BOLD + GREEN + ">>>" + NORMAL

alias t := test
alias c := check
alias f := format
alias fmt := format
alias d := doc

# list recipes
[private]
default:
@just --list --unsorted

# run tytanic with the correct assets
[positional-arguments]
tt *args:
@tt "$@"
# run all tests
test: && test-unit
@echo "{{prompt}} Running all tests"

# run the Tytanic unit test suite
test-unit:
@echo "{{prompt}} Testing Tytanic suite (with max-delta: 1)"
@tt run --no-fail-fast --max-delta 1 --expression 'all()'

# run all checks
check: && check-format check-doc
@echo "{{prompt}} Running all checks"

# check the formatting
check-format:
@echo "{{prompt}} Checking Typst files for formatting"
@typstyle --diff {{ TYPST_ROOT }}

# check the documentation assets generation
check-doc: && doc-generate
@echo "{{prompt}} Checking documentation assets generation for errors"

# format all Typst files
format:
@echo "{{prompt}} Formatting Typst files in place"
@typstyle --inplace {{ TYPST_ROOT }}

# run the full test suite
test:
tt run --no-fail-fast --expression 'all()'
# generate the docs and thumbnail
doc: doc-generate

# update all persistent assets
update: update-manual update-thumbnail
# update persistent documentation assets
doc-update: && update-manual update-thumbnail
@echo "{{prompt}} Updating tracked manual and thumbnail"

# generate all non-persistent assets
generate: generate-manual generate-thumbnail
# generate non-persistent documentation assets
doc-generate: && generate-manual generate-thumbnail
@echo "{{prompt}} Generating local manual and thumbnail"

# clean all output directories
clean:
rm --recursive --force {{ manual / 'out' }}
rm --recursive --force {{ examples / 'book' / 'out' }}
rm --recursive --force {{ examples / 'skip' / 'out' }}
rm --recursive --force {{ thumbnail / 'out' }}
tt util clean
@echo "{{prompt}} Removing temporary directories"
@rm --recursive --force {{ manual / 'out' }}
@rm --recursive --force {{ examples / 'book' / 'out' }}
@rm --recursive --force {{ examples / 'skip' / 'out' }}
@rm --recursive --force {{ thumbnail / 'out' }}
@tt util clean

# run Tytanic with the correct environment
[positional-arguments]
tt *args:
@tt "$@"

# run the ci checks locally
ci: generate test
ci: test check

# update the package thumbnail
[private]
update-thumbnail: generate-thumbnail
oxipng --opt max {{ thumbnail / 'out' / 'thumbnail.png' }}
cp {{ thumbnail / 'out' / 'thumbnail.png' }} {{ images / 'thumbnail.png' }}
@echo "{{prompt}} Updating tracked thumbnail in {{ assets / 'thumbnail.png' }}"
@oxipng --opt max {{ thumbnail / 'out' / 'thumbnail.png' }}
@cp {{ thumbnail / 'out' / 'thumbnail.png' }} {{ images / 'thumbnail.png' }}

# generate the package thumbnail
[private]
generate-thumbnail: (clear-directory (thumbnail / 'out'))
typst compile \
@typst compile \
--ppi 300 \
{{ thumbnail / 'pages.typ' }} \
{{ thumbnail / 'out' / '{n}.png' }}
typst compile \
@typst compile \
{{ thumbnail / 'thumbnail.typ' }} \
{{ thumbnail / 'out' / 'thumbnail.png' }}

# generate all docs examples
[private]
generate-examples: (generate-example 'book') (generate-example 'skip')

# generate a single docs example
[private]
generate-example example: (clear-directory (examples / example / 'out'))
typst compile \
@typst compile \
--ppi 300 \
{{ examples / example / 'a.typ' }} \
{{ examples / example / 'out' / 'a{n}.png' }}
typst compile \
@typst compile \
--ppi 300 \
{{ examples / example / 'b.typ' }} \
{{ examples / example / 'out' / 'b{n}.png' }}

# generate a new manual and update it
[private]
update-manual: generate-manual
cp {{ manual / 'out' / 'manual.pdf' }} {{ assets / 'manual.pdf' }}
@echo "{{prompt}} Updating tracked manual in {{ assets / 'manual.pdf' }}"
@cp {{ manual / 'out' / 'manual.pdf' }} {{ assets / 'manual.pdf' }}

# generate the manual
[private]
generate-manual: (clear-directory (manual / 'out')) generate-examples
typst compile \
@typst compile \
{{ manual / 'manual.typ' }} \
{{ manual / 'out' / 'manual.pdf' }}

# watch the manual
# watch the manual after generating its dependencies once
[private]
watch-manual: (clear-directory (manual / 'out')) generate-examples
typst watch \
@typst watch \
{{ manual / 'manual.typ' }} \
{{ manual / 'out' / 'manual.pdf' }}

[private]
clear-directory dir:
rm --recursive --force {{ dir }}
mkdir {{ dir }}
@rm --recursive --force {{ dir }}
@mkdir {{ dir }}
23 changes: 9 additions & 14 deletions assets/images/thumbnail/thumbnail.typ
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
#page(
width: auto,
height: auto,
margin: 0pt,
block(
fill: gray,
inset: 1em,
radius: 1em,
grid(
columns: 4,
gutter: 1em,
..range(1, 5).map(i => image("out/" + str(i) + ".png"))
),
#page(width: auto, height: auto, margin: 0pt, block(
fill: gray,
inset: 1em,
radius: 1em,
grid(
columns: 4,
gutter: 1em,
..range(1, 5).map(i => image("out/" + str(i) + ".png"))
),
)
))
Binary file modified assets/manual.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/manual/chapters/guide/faq.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "/docs/manual/util.typ": issues, issue, mantys
#import "/docs/manual/util.typ": issue, issues, mantys
#import mantys: *

== Frequently Asked Questions <sec:faq>
Expand Down
14 changes: 11 additions & 3 deletions docs/manual/chapters/guide/features.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "/docs/manual/util.typ": load-examples, show-examples, issue, mantys
#import "/docs/manual/util.typ": issue, load-examples, mantys, show-examples
#import mantys: *

== Features
Expand All @@ -22,7 +22,11 @@ This is turned on by default.

#let skip = load-examples("skip")
#figure(
frame(grid(columns: 2, gutter: 1em, show-examples(skip.a), show-examples(skip.b))),
frame(grid(
columns: 2,
gutter: 1em,
show-examples(skip.a), show-examples(skip.b),
)),
caption: [
Two example documents showing the difference between #arg(skip-starting: true) (left) and #arg(skip-starting: false) (right).
],
Expand Down Expand Up @@ -58,7 +62,11 @@ This is turned off by default.

#let book = load-examples("book")
#figure(
frame(grid(columns: 2, gutter: 1em, show-examples(book.a), show-examples(book.b))),
frame(grid(
columns: 2,
gutter: 1em,
show-examples(book.a), show-examples(book.b),
)),
caption: [
Two example documents showing the difference between #arg(book: false) (left) and #arg(book: true) (right).
],
Expand Down
15 changes: 6 additions & 9 deletions docs/manual/chapters/reference.typ
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Defines the options passed to @cmd:hydra and resolved contextual information nee

#pagebreak()

// @typstyle off
#let mods = (
("hydra", "/src/lib.typ", true, [
The package entry point.
Expand All @@ -107,15 +108,11 @@ Defines the options passed to @cmd:hydra and resolved contextual information nee

#let render-module(name, path, is-stable, description) = [
#heading(depth: 3, name) #label("sec:mod:" + name)
#place(
right,
dy: -2.4em,
if is-stable {
bbox(fill: green.lighten(50%), `stable`)
} else {
bbox(fill: yellow.lighten(50%), `unstable`)
},
)
#place(right, dy: -2.4em, if is-stable {
bbox(fill: green.lighten(50%), `stable`)
} else {
bbox(fill: yellow.lighten(50%), `unstable`)
})

#import "/docs/manual/util.typ": mantys
#description
Expand Down
9 changes: 5 additions & 4 deletions docs/manual/manual.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "util.typ": package, mantys
#import "util.typ": mantys, package

#show: mantys.mantys(
..package,
Expand All @@ -9,10 +9,11 @@
Hydra provides a simple API to query for headings und section like elements and display them in your document's headers.
It aids in creating headers and footers with navigational snippets.
],
theme: mantys.create-theme(
// TODO(tinger): This seems to be unaffected in typstyle `0.13.14`.
theme: /* @typstyle off */ mantys.create-theme(
fonts: (sans: "TeX Gyre Heros"),
heading: (font: "TeX Gyre Heros"),
)
),
)

// replace the version in all examples with the current version
Expand All @@ -34,7 +35,7 @@
[ ]
numbering(it.numbering, ..counter(figure.where(kind: it.kind)).get())
}),
it.body
it.body,
))

#include "chapters/guide.typ"
Expand Down
19 changes: 15 additions & 4 deletions docs/manual/util.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "@preview/mantys:1.0.0"
#import "@preview/mantys:1.0.2"

#let package = toml("/typst.toml").package

Expand All @@ -17,11 +17,22 @@
radius: 0.25em,
fill: theme.muted.bg,
inset: 0.5em,
grid(columns: (1fr, 1fr), gutter: 0.5em, align(center + horizon)[Binding], ..examples),
grid(
columns: (1fr, 1fr),
gutter: 0.5em,
align(
center + horizon,
)[Binding],
..examples,
),
)

#let issue(num) = text(eastern, link(package.repository + "/issues/" + str(num))[hydra\##num])
#let issue(num) = text(eastern, link(
package.repository + "/issues/" + str(num),
)[hydra\##num])

#let issues = text(eastern, link(package.repository + "/issues/")[GitHub:tingerrr/hydra])
#let issues = text(eastern, link(
package.repository + "/issues/",
)[GitHub:tingerrr/hydra])

#let bbox = box.with(inset: (x: 0.25em), outset: (y: 0.25em), radius: 0.25em)
2 changes: 1 addition & 1 deletion src/_pkgs.typ
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#import "@preview/oxifmt:0.2.1"
#import "@preview/oxifmt:1.0.0"
Loading