forked from kcarnold/cs344
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
61 lines (46 loc) · 2.25 KB
/
Makefile
File metadata and controls
61 lines (46 loc) · 2.25 KB
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
ALL: deploy
all: deploy
HUGO_FLAGS := --buildDrafts --buildFuture
DEST_DIR := /tmp/cs344-build/
slide_htmls := $(patsubst %.Rmd,%.html,$(shell find static/slides -iname '*.Rmd' -and -not -iname "*slides-common*"))
post_markdowns := $(patsubst %.Rmarkdown,%.markdown,$(shell find content -name '*.Rmarkdown'))
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)))
# Build slides
%.html: %.Rmd
Rscript -e "rmarkdown::render('"$<"')"
# I don't think we need this rule anymore.
%.html: %.md
Rscript -e "rmarkdown::render('"$<"')"
# Build PDFs of slides
%.pdf: %.html
decktape --pause 500 --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
python nb_strip.py "$<" "$@"
# Generate HTML previews of notebooks.
$(fundamentals_html) : %.html : %.ipynb
jupyter nbconvert --to=html "$<"
content/all_fundamentals.md: $(fundamentals)
python gen_fundamentals_index.py > "$@"
# Deploy to cs-prod, first pass (before building slide PDFs)
deploy-quick: $(slide_htmls) $(post_markdowns) $(fundamentals) $(fundamentals_html) content/all_fundamentals.md
hugo $(HUGO_FLAGS) --destination ${DEST_DIR} --cleanDestinationDir
rsync -rxi --delete-after ${DEST_DIR}/ cs-prod:/webroot/courses/cs/344/22sp/
# --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}/ cs-prod:/webroot/courses/cs/344/22sp/
deploy: deploy-quick deploy-pdf
serve:
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}