1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-12-20 22:29:12 +02:00
Files
comprehensive-rust/.github/workflows/build.sh
Martin Geisler 1063356a1d Re-enable the red box to show available space (#2932)
Way back in #187, I introduced a hacky tool to show the available space
on a slide: it was a `mdbook` plugin which injected the necessary CSS on
each slide. Crude, but it got the job done.

The logic was moved from Python to a real CSS file with associated
JavaScript in #1842. In #1917, the functionality was moved to a
dedicated “instructor menu”, together with functionality for saving the
state of the Playground on each slide.

Unfortunately, the whole thing was disabled in #1935 since I found that
the Playgrounds lost their code with the saving logic. I was also not
100% happy with dedicating space on each slide for a menu only used by
instructors.

However, I really think we need a tool to let slide editors know about
the available space, so I would like to re-introduce the red box. This
time via a keyboard shortcut to make it easy to toggle as needed.

I’m suggesting enabling this for everyone, with the expectation that
most people won’t find the shortcut and will quickly disable the box if
they do (there is a dedicated button to hide it again).

End-to-end tests have been added for the new functionality.
2025-10-19 15:10:01 +00:00

50 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
set -Eeuo pipefail
# Usage: build.sh <book-lang> <dest-dir>
#
# Build the course as of the date specified specified in the
# POT-Creation-Date header of po/$book_lang.po. The output can be
# found in $dest_dir.
#
# The src/ and third_party/ directories are left in a dirty state so
# you can run `mdbook test` and other commands afterwards.
#
# See also TRANSLATIONS.md.
book_lang=${1:?"Usage: $0 <book-lang> <dest-dir>"}
dest_dir=${2:?"Usage: $0 <book-lang> <dest-dir>"}
if [ "$book_lang" = "en" ]; then
echo "::group::Building English course"
else
pot_creation_date=$(grep --max-count 1 '^"POT-Creation-Date:' "po/$book_lang.po" | sed -E 's/".*: (.*)\\n"/\1/')
pot_creation_date=${pot_creation_date:-now}
echo "::group::Building $book_lang translation as of $pot_creation_date"
# Back-date the sources to POT-Creation-Date. The content lives in two
# directories:
rm -r src/ third_party/
git restore --source "$(git rev-list -n 1 --before "$pot_creation_date" @)" src/ third_party/ book.toml
# Set language and adjust site URL. Clear the redirects since they are
# in sync with the source files, not the translation.
export MDBOOK_BOOK__LANGUAGE=$book_lang
export MDBOOK_OUTPUT__HTML__SITE_URL=/comprehensive-rust/$book_lang/
export MDBOOK_OUTPUT__HTML__REDIRECT='{}'
# Include language-specific Pandoc configuration
if [ -f ".github/pandoc/$book_lang.yaml" ]; then
export MDBOOK_OUTPUT__PANDOC__PROFILE__PDF__DEFAULTS=".github/pandoc/$book_lang.yaml"
fi
fi
# Enable mdbook-pandoc to build PDF version of the course
export MDBOOK_OUTPUT__PANDOC__DISABLED=false
mdbook build -d "$dest_dir"
mv "$dest_dir/pandoc/pdf/comprehensive-rust.pdf" "$dest_dir/html/"
(cd "$dest_dir/exerciser" && zip --recurse-paths ../html/comprehensive-rust-exercises.zip comprehensive-rust-exercises/)
echo "::endgroup::"