Skip to content
Draft
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
64 changes: 46 additions & 18 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ on:
description: The branch, tag or SHA in https://github.com/typst/typst.
default: main
type: string
docs_base:
description: |
The base URL for the documentation. For example, `/` or `/docs/`.
Refer to typst-docs CLI for more info.
default: /DOCS-BASE/
type: string
release:
description: Whether to publish artifacts in a new release.
default: false
Expand All @@ -31,16 +25,12 @@ jobs:
contents: write
env:
INPUT_REF: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || 'main' }}
INPUT_DOCS_BASE: ${{ github.event_name == 'workflow_dispatch' && inputs.docs_base || '/DOCS-BASE/' }}
INPUT_RELEASE: ${{ github.event_name == 'workflow_dispatch' && inputs.release || false }}
steps:
- uses: actions/checkout@v6
with:
repository: typst/typst
# Temporary workaround for using the old docs infrastructure
ref: main
fetch-depth: 20
- run: git switch --detach ${{ env.INPUT_REF }}
ref: ${{ env.INPUT_REF }}

- uses: actions/checkout@v6
with:
Expand All @@ -66,26 +56,64 @@ jobs:
${{ runner.os }}-cargo-typst
${{ runner.os }}-cargo

- name: Switch the profile for cargo docit
run: |
git apply <<'EOF'
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -8,7 +8,5 @@ testit = "run --quiet --package=test-wrapper --"

# Runs the documentation generator.
#
-# We use the `dev-fast` profile as a reasonable trade-off between Rust and Typst
-# compilation speed. Just `dev` makes the Typst compilation very slow, while
-# `release` makes the Rust compilation very slow.
-docit = "run --profile dev-fast --package=typst-docs --"
+# We use the `release` profile to optimize the resulting binary.
+docit = "run --release --package=typst-docs --"
EOF

- name: Build cargo docit CLI
run: |
cargo docit --help
- name: Build docs
run: |
cargo run --package typst-docs --release -- --assets-dir assets/ --out-file docs.json --base "${{ env.INPUT_DOCS_BASE }}"
cargo docit compile --format website
cargo docit compile --format pdf

- name: Prepare to upload
shell: bash
run: |
set -euxo pipefail
7z a docs-assets.zip assets/

- name: Upload docs.json
7z a docs-website.zip docs/dist/site/

directory=docs-cli-${{ matrix.target }}
mkdir $directory
cp README.md LICENSE NOTICE $directory
if [ -f target/${{ matrix.target }}/release/typst-docs.exe ]; then
cp target/${{ matrix.target }}/release/typst-docs.exe $directory
7z a -r $directory.zip $directory
else
cp target/${{ matrix.target }}/release/typst-docs $directory
tar cJf $directory.tar.xz $directory
fi

- name: Upload docs.pdf
uses: actions/upload-artifact@v7
with:
name: docs.json
path: docs.json
name: docs.pdf
path: docs/dist/docs.pdf
archive: true
- name: Upload docs-assets
- name: Upload docs-website
uses: actions/upload-artifact@v7
with:
path: docs-website.zip
archive: false
- name: Upload docs-cli
uses: actions/upload-artifact@v7
with:
path: docs-assets.zip
path: "docs-cli-${{ matrix.target }}.*"
archive: false

- uses: softprops/action-gh-release@v2
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ Unofficial builds of [Typst](https://typst.app/home) artifacts for development p

## Additional explanation for `docs`

### Future builds

<!-- TODO -->

### `docs-main.2026-05-05.0d72726`, `docs-v0.14.2`, and earlier builds

`docs.json` is the HTML-in-JSON representation of the [documentation](https://typst.app/docs/), and `docs-assets` contains preview images for the examples. Both are generated by the official [typst-docs](https://github.com/typst/typst/blob/main/docs/Cargo.toml#L2) crate.

You can build a docs website from these files yourself by leveraging [typst-docs-web](https://github.com/typst-community/typst-docs-web) and [other](https://ydx-2147483647.github.io/best-of-typst/#docs-infra) unofficial tools.
Expand All @@ -47,6 +53,12 @@ gh workflow run

### `docs`

Future builds:

<!-- TODO -->

`docs-main.2026-05-05.0d72726`, `docs-v0.14.2`, and earlier builds:

```shell
gh run download --name docs.json

Expand Down