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