diff --git a/.hooks/render-readme.sh b/.hooks/render-readme.sh new file mode 100755 index 0000000..52021ab --- /dev/null +++ b/.hooks/render-readme.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Check if README.qmd has been modified +if git diff --cached --name-only | grep -q "^README\.qmd$"; then + echo "README.qmd has been modified. Rendering README.md..." + if quarto render README.qmd --to markdown; then + # Stage the updated README.md + git add README.md + else + echo "Failed to render README.qmd. Commit aborted." + exit 1 + fi +else + echo "README.qmd has not been modified. Skipping rendering." +fi \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ba4a070..58b77e8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,4 +10,12 @@ repos: - repo: https://github.com/kynan/nbstripout rev: 0.7.1 hooks: - - id: nbstripout \ No newline at end of file + - id: nbstripout + + - repo: local + hooks: + - id: render-readme + name: render README + entry: .hooks/render-readme.sh + language: system + files: ^README\.qmd$ \ No newline at end of file diff --git a/README.md b/README.md index 927d900..fb91500 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ -# Earth Observation Datascience - +--- +title: Earth Observation Datascience +toc-title: Table of contents +--- This is a book on Earth Observation Datascience, consisting of common workflows in Python at the Department of Geodesy and Geoinformation at @@ -36,7 +38,7 @@ following steps: `_quarto.yml` file 4) Add references to `chapter/references.bib` -Don’t worry if your original file is an Jupyter Notebook. Jupyter +Don't worry if your original file is an Jupyter Notebook. Jupyter notebooks can be easily converted to quarto files by using: ``` {bash} @@ -53,6 +55,16 @@ pip install pre-commit pre-commit install ``` +The pre configured hooks check for: + +- trailing whitspaces +- large files +- private keys +- and renders the README file + +The file `.pre-commin-config.yaml` hereby specifies what hooks should be +run. + The `git workflow` essentialy converts the quarto files in `chapters` into jupyter notebooks, generates a file for the table of contents and pushes these files together with the **Makefile** and the diff --git a/README.qmd b/README.qmd index a4b767e..2500cc1 100644 --- a/README.qmd +++ b/README.qmd @@ -34,5 +34,13 @@ The pre-commit hooks can be used to check whether outputs are empty. This can be pip install pre-commit pre-commit install ``` +The pre configured hooks check for: + +* trailing whitspaces +* large files +* private keys +* and renders the README file + +The file `.pre-commin-config.yaml` hereby specifies what hooks should be run. The `git workflow` essentialy converts the quarto files in ``chapters`` into jupyter notebooks, generates a file for the table of contents and pushes these files together with the **Makefile** and the **references.bib** files to the cookbook repository. \ No newline at end of file