Merge pull request #12 from carpentries/update-styles-v9.5.2
[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 JEKYLL_VERSION=3.7.3
8 PARSER=bin/markdown_ast.rb
9 DST=_site
10
11 # Controls
12 .PHONY : commands clean files
13 .NOTPARALLEL:
14 all : commands
15
16 ## commands         : show all commands.
17 commands :
18         @grep -h -E '^##' ${MAKEFILES} | sed -e 's/## //g'
19
20 ## docker-serve     : use docker to build the site
21 docker-serve :
22         docker run --rm -it -v ${PWD}:/srv/jekyll -p 127.0.0.1:4000:4000 jekyll/jekyll:${JEKYLL_VERSION} make serve
23
24 ## serve            : run a local server.
25 serve : lesson-md
26         ${JEKYLL} serve
27
28 ## site             : build files but do not run a server.
29 site : lesson-md
30         ${JEKYLL} build
31
32 # repo-check        : check repository settings.
33 repo-check :
34         @bin/repo_check.py -s .
35
36 ## clean            : clean up junk files.
37 clean :
38         @rm -rf ${DST}
39         @rm -rf .sass-cache
40         @rm -rf bin/__pycache__
41         @find . -name .DS_Store -exec rm {} \;
42         @find . -name '*~' -exec rm {} \;
43         @find . -name '*.pyc' -exec rm {} \;
44
45 ## clean-rmd        : clean intermediate R files (that need to be committed to the repo).
46 clear-rmd :
47         @rm -rf ${RMD_DST}
48         @rm -rf fig/rmd-*
49
50 ## ----------------------------------------
51 ## Commands specific to workshop websites.
52
53 .PHONY : workshop-check
54
55 ## workshop-check   : check workshop homepage.
56 workshop-check :
57         @bin/workshop_check.py .
58
59 ## ----------------------------------------
60 ## Commands specific to lesson websites.
61
62 .PHONY : lesson-check lesson-md lesson-files lesson-fixme
63
64 # RMarkdown files
65 RMD_SRC = $(wildcard _episodes_rmd/??-*.Rmd)
66 RMD_DST = $(patsubst _episodes_rmd/%.Rmd,_episodes/%.md,$(RMD_SRC))
67
68 # Lesson source files in the order they appear in the navigation menu.
69 MARKDOWN_SRC = \
70   index.md \
71   CODE_OF_CONDUCT.md \
72   setup.md \
73   $(sort $(wildcard _episodes/*.md)) \
74   reference.md \
75   $(sort $(wildcard _extras/*.md)) \
76   LICENSE.md
77
78 # Generated lesson files in the order they appear in the navigation menu.
79 HTML_DST = \
80   ${DST}/index.html \
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
87
88 ## lesson-md        : convert Rmarkdown files to markdown
89 lesson-md : ${RMD_DST}
90
91 # Use of .NOTPARALLEL makes rule execute only once
92 ${RMD_DST} : ${RMD_SRC}
93         @bin/knit_lessons.sh ${RMD_SRC}
94
95 ## lesson-check     : validate lesson Markdown.
96 lesson-check : lesson-fixme
97         @bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md
98
99 ## lesson-check-all : validate lesson Markdown, checking line lengths and trailing whitespace.
100 lesson-check-all :
101         @bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md -l -w --permissive
102
103 ## unittest         : run unit tests on checking tools.
104 unittest :
105         @bin/test_lesson_check.py
106
107 ## lesson-files     : show expected names of generated files for debugging.
108 lesson-files :
109         @echo 'RMD_SRC:' ${RMD_SRC}
110         @echo 'RMD_DST:' ${RMD_DST}
111         @echo 'MARKDOWN_SRC:' ${MARKDOWN_SRC}
112         @echo 'HTML_DST:' ${HTML_DST}
113
114 ## lesson-fixme     : show FIXME markers embedded in source files.
115 lesson-fixme :
116         @fgrep -i -n FIXME ${MARKDOWN_SRC} || true
117
118 #-------------------------------------------------------------------------------
119 # Include extra commands if available.
120 #-------------------------------------------------------------------------------
121
122 -include commands.mk