add tools to deal with episodes written in Rmd
[rnaseq-cwl-training.git] / Makefile
1 ## ========================================
2 ## Commands for both workshop and lesson websites.
3
4 # Settings
5 MAKEFILES=Makefile $(wildcard *.mk)
6 JEKYLL=jekyll
7 PARSER=bin/markdown_ast.rb
8 DST=_site
9
10 # Controls
11 .PHONY : commands clean files
12 all : commands
13
14 ## commands       : show all commands.
15 commands :
16         @grep -h -E '^##' ${MAKEFILES} | sed -e 's/## //g'
17
18 ## serve          : run a local server.
19 serve : lesson-rmd
20         ${JEKYLL} serve --config _config.yml,_config_dev.yml
21
22 ## site           : build files but do not run a server.
23 site : lesson-rmd
24         ${JEKYLL} build --config _config.yml,_config_dev.yml
25
26 ## figures        : re-generate inclusion displaying all figures.
27 figures :
28         @bin/extract_figures.py -s _episodes -p ${PARSER} > _includes/all_figures.html
29
30 ## clean          : clean up junk files.
31 clean :
32         @rm -rf ${DST}
33         @rm -rf .sass-cache
34         @rm -rf bin/__pycache__
35         @find . -name .DS_Store -exec rm {} \;
36         @find . -name '*~' -exec rm {} \;
37         @find . -name '*.pyc' -exec rm {} \;
38         @rm -rf ${RMD_DST}
39         @rm -rf fig/swc-rmd-*
40
41 ## ----------------------------------------
42 ## Commands specific to workshop websites.
43
44 .PHONY : workshop-check
45
46 ## workshop-check : check workshop homepage.
47 workshop-check :
48         @bin/workshop_check.py .
49
50 ## ----------------------------------------
51 ## Commands specific to lesson websites.
52
53 .PHONY : lesson-check lesson-rmd lesson-files lesson-fixme lesson-single
54
55 # RMarkdown files
56 RMD_SRC = $(wildcard _episodes_rmd/??-*.Rmd)
57 RMD_DST = $(patsubst _episodes_rmd/%.Rmd,_episodes/%.md,$(RMD_SRC))
58
59 # Lesson source files in the order they appear in the navigation menu.
60 SRC_FILES = \
61   index.md \
62   CONDUCT.md \
63   setup.md \
64   $(wildcard _episodes/*.md) \
65   reference.md \
66   $(wildcard _extras/*.md) \
67   LICENSE.md
68
69 # Generated lesson files in the order they appear in the navigation menu.
70 HTML_FILES = \
71   ${DST}/index.html \
72   ${DST}/conduct/index.html \
73   ${DST}/setup/index.html \
74   $(patsubst _episodes/%.md,${DST}/%/index.html,$(wildcard _episodes/*.md)) \
75   ${DST}/reference/index.html \
76   $(patsubst _extras/%.md,${DST}/%/index.html,$(wildcard _extras/*.md)) \
77   ${DST}/license/index.html
78
79 ## lesson-rmd:    : convert Rmarkdown files to markdown
80 lesson-rmd: $(RMD_SRC)
81         @bin/knit_lessons.sh
82
83 ## lesson-check   : validate lesson Markdown.
84 lesson-check :
85         @bin/lesson_check.py -s . -p ${PARSER}
86
87 unittest :
88         python bin/test_lesson_check.py
89
90 ## lesson-files   : show expected names of generated files for debugging.
91 lesson-files :
92         @echo 'RMarkdown:' ${RMD_SRC}
93         @echo 'source:' ${SRC_FILES}
94         @echo 'generated:' ${HTML_FILES}
95
96 ## lesson-fixme   : show FIXME markers embedded in source files.
97 lesson-fixme :
98         @fgrep -i -n FIXME ${SRC_FILES} || true
99
100 #-------------------------------------------------------------------------------
101 # Include extra commands if available.
102 #-------------------------------------------------------------------------------
103
104 -include commands.mk