Skip to content
Snippets Groups Projects
Verified Commit 89344005 authored by Rok Štular's avatar Rok Štular
Browse files

feat(build): Remove some chapters from published book

parent 172fff27
No related branches found
No related tags found
2 merge requests!80check toc purge,!77feat(build): Remove some chapters from published book
Pipeline #207222 passed
......@@ -142,6 +142,7 @@ parts:
- file: sandbox/1-5-NumericalMethods/1-general-solvers.ipynb
- file: sandbox/1-5-NumericalMethods/2-implicit-ode-solver.ipynb
# START REMOVE-FROM-PUBLISH
- caption: MUDE Cookbook
chapters:
- file: cookbook/blank
......@@ -159,6 +160,7 @@ parts:
- file: cookbook/example_quiz_interactive.ipynb
- file: cookbook/coding_theory_widgets.ipynb
- file: cookbook/theory_questions
# END REMOVE-FROM-PUBLISH
- caption: Old Material
chapters:
- file: old/blank
......
......@@ -4,13 +4,20 @@ set -euo pipefail
START_SERVER=${1:-false}
PAGE_ROOT=${2:-"/"}
USE_TOC_BLACKLIST=${3:-false}
# Pre-process the book using the blacklist comment
if [ "$USE_TOC_BLACKLIST" = true ]; then
echo "Using TOC blacklist"
sed --in-place=".bak" '/# START REMOVE-FROM-PUBLISH/,/# END REMOVE-FROM-PUBLISH/{//!d}' book/_toc.yml
fi
# Build the jupyter book, everything else is post-processing
jupyter-book build book/
# Note: the structure of thebe_lite mimicks where thing are needed in the html folder
cp thebe_lite/* book/_build/html/ -r
sed "s,const PAGE_ROOT = \"/\";,const PAGE_ROOT = \"$PAGE_ROOT\";,g" thebe_lite/_static/sphinx-thebe.js > book/_build/html/_static/sphinx-thebe.js
sed "s,const PAGE_ROOT = \"/\";,const PAGE_ROOT = \"$PAGE_ROOT\";,g" thebe_lite/_static/sphinx-thebe.js >book/_build/html/_static/sphinx-thebe.js
rm book/_build/html/THEBE_LITE.md
# Copy all non notebook, markdown or build files into the build for local access in pyodide etc.
......@@ -21,28 +28,25 @@ rm book/_build/html/THEBE_LITE.md
# 4. xargs: will execute the script inside the quotes
# 5. grep: finds a file's parent's path by matching against the section of the string ending in a '/'
# 6. mkdir: makes all the parent directories, -p will do so recrusively
# 7. cp: finally copies all files from the /book folder to /book/_build/html
# 7. cp: finally copies all files from the /book folder to /book/_build/html
find book/ -type f | grep -v "^book/_.*\|.*\.\(md\|ipynb\)" | cut -c 6- | xargs -i sh -c 'echo "book/_build/html/{}" | grep -o "^.*/" | xargs -d "\n" mkdir -p; cp book/"{}" book/_build/html/"{}"'
# Check whether python has the alias 'python' or 'python3'
if command -v python3 > /dev/null 2>&1
then
if command -v python3 >/dev/null 2>&1; then
python_command="python3"
else
if command -v python > /dev/null 2>&1
then
if command -v python >/dev/null 2>&1; then
python_command="python"
fi
fi
if [ "$python_command" = "" ] ; then
if [ "$python_command" = "" ]; then
echo "Book successfully built. If you want to use interactive elements, start a local HTTP server for the _build/html folder."
exit 0
fi
# Serves the files on port 8000, localhost (127.0.0.1:8000)
if [ "$START_SERVER" = true ] ; then
if [ "$START_SERVER" = true ]; then
echo "Starting server on port 8000"
$python_command -m http.server 8000 --directory book/_build/html
else
......@@ -50,7 +54,7 @@ else
start a server locally using the command:
$python_command -m http.server 8000 --directory book/_build/html.
Or run this script again (book will build again!):
${0} true"
${0} true"
fi
echo "To close a python server run the commeand:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment