From 56a5f1161440c56a8850ee0f036de3a5235668ba Mon Sep 17 00:00:00 2001 From: Jakub Nowicki Date: Mon, 13 May 2024 12:46:25 +0200 Subject: [PATCH] chore: Add script for docs preview. --- .gitignore | 5 +++++ .rscignore | 3 +++ build_local_docs.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100755 build_local_docs.sh diff --git a/.gitignore b/.gitignore index 039024e..aa6dd36 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,8 @@ .Ruserdata .DS_Store .Renviron + +/.quarto/ +/_site/ +_quarto.yml +styles.css diff --git a/.rscignore b/.rscignore index fdd749b..e0f1e08 100644 --- a/.rscignore +++ b/.rscignore @@ -4,4 +4,7 @@ .Renviron .rhino .rscignore +build_local_docs.sh +docs +img tests diff --git a/build_local_docs.sh b/build_local_docs.sh new file mode 100755 index 0000000..6d44a08 --- /dev/null +++ b/build_local_docs.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# This script is used to build the local documentation for the project. + +remove_files() { + if [ -f _quarto.yml ]; then + echo "Removing _quarto.yml..." + rm _quarto.yml + fi + + if [ -f styles.css ]; then + echo "Removing styles.css..." + rm styles.css + fi +} + +cleanup() { + echo "Cleaning up..." + remove_files + exit 1 +} + +trap cleanup SIGINT + +if [ "$1" = "preview" ]; then + echo "Copying _quarto.yml..." + cp docs/_quarto.yml _quarto.yml + echo "Copying styles.css..." + cp docs/styles.css styles.css + + echo "Building local documentation preview..." + quarto preview +elif [ "$1" = "render" ]; then + echo "Copying _quarto.yml..." + cp docs/_quarto.yml _quarto.yml + echo "Copying styles.css..." + cp docs/styles.css styles.css + + echo "Rendering local documentation..." + quarto render + remove_files +fi