From 3c6e571d62ddc5a07900e8b35fe75c8da4b2c235 Mon Sep 17 00:00:00 2001 From: Remo Senekowitsch Date: Wed, 13 Sep 2023 08:21:16 +0200 Subject: [PATCH] Symlink problem-specifications for easy reference This is handy when referring to `canonical-data.json` of an exercise, while creating / updating the test template for it. It's all available in the same spot. --- .gitignore | 1 + bin/symlink_problem_specifications.sh | 12 ++++++++++++ docs/CONTRIBUTING.md | 5 +++++ 3 files changed, 18 insertions(+) create mode 100755 bin/symlink_problem_specifications.sh diff --git a/.gitignore b/.gitignore index edcc454ae..5af0f3619 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ tmp exercises/*/*/Cargo.lock exercises/*/*/clippy.log .vscode +.prob-spec diff --git a/bin/symlink_problem_specifications.sh b/bin/symlink_problem_specifications.sh new file mode 100755 index 000000000..bf86ebaa9 --- /dev/null +++ b/bin/symlink_problem_specifications.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -eo pipefail + +cd "$(git rev-parse --show-toplevel)" + +for exercise in exercises/practice/*; do + name="$(basename "$exercise")" + if [ -d "problem-specifications/exercises/$name" ]; then + [ -e "$exercise/.prob-spec" ] && rm "$exercise/.prob-spec" + ln -s "../../../problem-specifications/exercises/$name" "$exercise/.prob-spec" + fi +done diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index eef87865c..7d2e57e05 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -101,6 +101,11 @@ Find some tips about writing tera templates [in the next section](#tera-template The full documentation for tera templates is [here][tera-docs]. Following are some approaches that have worked for our specific needs. +You will likely want to look at the exercise's `canonical-data.json` +to see what structure your input data has. +You can use `bin/symlink_problem_specifications.sh` to have this data +symlinked into the actual exercise directory. Handy! + The name of the input property is different for each exercise. The default template will be something like this: