Skip to content

Commit

Permalink
Final tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed May 15, 2024
1 parent 3a732b2 commit 9cf7d19
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ repos:
- repo: local
hooks:
- id: generate-rst-placeholders
name: RST placeholders for the tutorials (local run only)
name: Tutorials .rst placeholders (local run only)
# Local file living in the project.
# only runs when the GITHUB_ACTION envir var is undefined.
entry: ./.pre-commit-rst-placeholder.sh
# Language and type are irrelevant here, but need to
# be defined
language: script
files: 'model/docs/.*\.rst'
files: 'model/docs/.*\.qmd'
- repo: https://github.com/psf/black
rev: 23.10.0
hooks:
Expand Down
12 changes: 11 additions & 1 deletion .pre-commit-rst-placeholder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ TUTORIALS_DIR=docs/source/tutorials

# For each *qmd file in model/docs, create a corresponding rst file
# under docs/source/tutorial
COUNTER=0
for qmd in model/docs/*.qmd; do
# Capture the basename
bname=$(basename $qmd .qmd)

# Check if the corresponding rst file already exists
if [ -f ${TUTORIALS_DIR}${bname}.rst ]; then
if [ -f ${TUTORIALS_DIR}/${bname}.rst ]; then
echo "RST file already exists: ${TUTORIALS_DIR}${bname}.rst"
continue
fi

# Increment counter
COUNTER=$((COUNTER+1))

# Create the rst file
rst=${TUTORIALS_DIR}/${bname}.rst
echo "Creating $rst"
Expand All @@ -26,3 +30,9 @@ for qmd in model/docs/*.qmd; do
echo ".. <https://github.com/CDCgov/multisignal-epi-inference/tree/main/model/docs/${bname}.qmd>" >> $rst

done

# Exit with 1 if COUNTER != 0
if [ $COUNTER -ne 0 ]; then
echo "Tutorials' RST placeholders were generated."
exit 1
fi

0 comments on commit 9cf7d19

Please sign in to comment.