-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
71 lines (54 loc) · 2.75 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
ALL: deploy
all: deploy
.PHONY: deploy deploy-quick deploy-pdf preview check ALWAYS_REBUILD fetch
HUGO_FLAGS := --buildDrafts --buildFuture
DEST_DIR := /tmp/cs344-build/
DEPLOY_TARGET := csweb:/webroot/courses/cs/344/23sp/
slide_html_from_rmd := $(patsubst %.Rmd,%.html,$(shell find static/slides -iname '*.Rmd' -and -not -iname "*slides-common*"))
slide_html_from_qmd := $(patsubst %.qmd,%.html,$(shell find static/slides -iname '*.qmd' -and -not -iname "*slides-common*"))
slide_htmls := ${slide_html_from_rmd} ${slide_html_from_qmd}
slide_pdfs := $(patsubst %.html,%.pdf,$(slide_htmls))
fundamentals_soln := $(wildcard static/fundamentals/*_soln.ipynb)
fundamentals := $(subst _soln,,$(fundamentals_soln))
fundamentals_html := $(patsubst %.ipynb,%.html,$(sort $(fundamentals) $(fundamentals_soln) $(wildcard static/fundamentals/*.ipynb)))
handouts := $(patsubst %.md,%.pdf,$(shell find content -name '*-handout.md'))
extra_notebooks := content/units/04models/homework/example-homework-2.html content/units/05learning/hw3_example.html
# Build slides
%.html: %.Rmd
Rscript -e "rmarkdown::render('"$<"')"
%.html: %.qmd
quarto render "$<"
$(handouts) : %.pdf: %.md
pandoc "$<" -o "$@"
# Build PDFs of slides. Needs decktape: `pnpm install decktape`.
%.pdf: %.html
node_modules/.bin/decktape --pause 250 --chrome-arg=--allow-file-access-from-files "$<" "$@"
# Build source files from RMarkdown (blogdown). Not currently using this.
%.markdown: %.Rmarkdown
Rscript -e "rmarkdown::render_site('"$<"', encoding = 'UTF-8')"
# Generate distributed notebooks from Solutions notebooks.
$(fundamentals) : %.ipynb : %_soln.ipynb nb_strip.py
python nb_strip.py "$<" "$@"
# Generate HTML previews of notebooks.
%.html : %.ipynb
jupyter nbconvert --to=html "$<"
content/all_fundamentals.md: $(fundamentals) ALWAYS_REBUILD
python gen_fundamentals_index.py --output="$@"
# Deploy to cs-prod, first pass (before building slide PDFs)
deploy-quick: $(slide_htmls) $(fundamentals) $(fundamentals_html) content/all_fundamentals.md $(handouts) $(extra_notebooks)
hugo $(HUGO_FLAGS) --destination ${DEST_DIR} --cleanDestinationDir
rsync -rxi --delete-after ${DEST_DIR}/ ${DEPLOY_TARGET}
# --times --delete-after --delete-excluded
# Deploy again after building slide PDFs (which are slow).
deploy-pdf: deploy-quick $(slide_pdfs)
rsync -rxi --delete-after ${DEST_DIR}/ ${DEPLOY_TARGET}
deploy: deploy-quick deploy-pdf
preview:
hugo server --disableFastRender $(HUGO_FLAGS)
# Check links.
# Based on https://github.com/gjtorikian/html-proofer
# installed on my machine using `brew gem install html-proofer`.
check:
htmlproofer --check-html --check-img-http --disable-external --report-invalid-tags --report-mismatched-tags --report-missing-names ${DEST_DIR}
fetch:
python src/portfolio_repo_management.py fetch-all