1 ## ========================================
2 ## Commands for both workshop and lesson websites.
5 MAKEFILES=Makefile $(wildcard *.mk)
8 PARSER=bin/markdown_ast.rb
12 .PHONY : commands clean files
16 ## commands : show all commands.
18 @grep -h -E '^##' ${MAKEFILES} | sed -e 's/## //g'
20 ## docker-serve : use docker to build the site
22 docker run --rm -it -v ${PWD}:/srv/jekyll -p 127.0.0.1:4000:4000 jekyll/jekyll:${JEKYLL_VERSION} make serve
24 ## serve : run a local server.
28 ## site : build files but do not run a server.
32 # repo-check : check repository settings.
34 @bin/repo_check.py -s .
36 ## clean : clean up junk files.
40 @rm -rf bin/__pycache__
41 @find . -name .DS_Store -exec rm {} \;
42 @find . -name '*~' -exec rm {} \;
43 @find . -name '*.pyc' -exec rm {} \;
45 ## clean-rmd : clean intermediate R files (that need to be committed to the repo).
50 ## ----------------------------------------
51 ## Commands specific to workshop websites.
53 .PHONY : workshop-check
55 ## workshop-check : check workshop homepage.
57 @bin/workshop_check.py .
59 ## ----------------------------------------
60 ## Commands specific to lesson websites.
62 .PHONY : lesson-check lesson-md lesson-files lesson-fixme
65 RMD_SRC = $(wildcard _episodes_rmd/??-*.Rmd)
66 RMD_DST = $(patsubst _episodes_rmd/%.Rmd,_episodes/%.md,$(RMD_SRC))
68 # Lesson source files in the order they appear in the navigation menu.
73 $(sort $(wildcard _episodes/*.md)) \
75 $(sort $(wildcard _extras/*.md)) \
78 # Generated lesson files in the order they appear in the navigation menu.
81 ${DST}/conduct/index.html \
82 ${DST}/setup/index.html \
83 $(patsubst _episodes/%.md,${DST}/%/index.html,$(sort $(wildcard _episodes/*.md))) \
84 ${DST}/reference/index.html \
85 $(patsubst _extras/%.md,${DST}/%/index.html,$(sort $(wildcard _extras/*.md))) \
86 ${DST}/license/index.html
88 ## lesson-md : convert Rmarkdown files to markdown
89 lesson-md : ${RMD_DST}
91 _episodes/%.md: _episodes_rmd/%.Rmd
92 @bin/knit_lessons.sh $< $@
94 ## lesson-check : validate lesson Markdown.
95 lesson-check : lesson-fixme
96 @bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md
98 ## lesson-check-all : validate lesson Markdown, checking line lengths and trailing whitespace.
100 @bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md -l -w --permissive
102 ## unittest : run unit tests on checking tools.
104 @bin/test_lesson_check.py
106 ## lesson-files : show expected names of generated files for debugging.
108 @echo 'RMD_SRC:' ${RMD_SRC}
109 @echo 'RMD_DST:' ${RMD_DST}
110 @echo 'MARKDOWN_SRC:' ${MARKDOWN_SRC}
111 @echo 'HTML_DST:' ${HTML_DST}
113 ## lesson-fixme : show FIXME markers embedded in source files.
115 @fgrep -i -n FIXME ${MARKDOWN_SRC} || true
117 #-------------------------------------------------------------------------------
118 # Include extra commands if available.
119 #-------------------------------------------------------------------------------