Starting on tool to check repository settings.
[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 # repo-check        : check repository settings.
31 repo-check :
32         @bin/repo_check.py -s .
33
34
35 ## clean            : clean up junk files.
36 clean :
37         @rm -rf ${DST}
38         @rm -rf .sass-cache
39         @rm -rf bin/__pycache__
40         @find . -name .DS_Store -exec rm {} \;
41         @find . -name '*~' -exec rm {} \;
42         @find . -name '*.pyc' -exec rm {} \;
43
44 ## clean-rmd        : clean intermediate R files (that need to be committed to the repo).
45 clear-rmd :
46         @rm -rf ${RMD_DST}
47         @rm -rf fig/rmd-*
48
49 ## ----------------------------------------
50 ## Commands specific to workshop websites.
51
52 .PHONY : workshop-check
53
54 ## workshop-check   : check workshop homepage.
55 workshop-check :
56         @bin/workshop_check.py .
57
58 ## ----------------------------------------
59 ## Commands specific to lesson websites.
60
61 .PHONY : lesson-check lesson-rmd lesson-files lesson-fixme
62
63 # RMarkdown files
64 RMD_SRC = $(wildcard _episodes_rmd/??-*.Rmd)
65 RMD_DST = $(patsubst _episodes_rmd/%.Rmd,_episodes/%.md,$(RMD_SRC))
66
67 # Lesson source files in the order they appear in the navigation menu.
68 MARKDOWN_SRC = \
69   index.md \
70   CONDUCT.md \
71   setup.md \
72   $(wildcard _episodes/*.md) \
73   reference.md \
74   $(wildcard _extras/*.md) \
75   LICENSE.md
76
77 # Generated lesson files in the order they appear in the navigation menu.
78 HTML_DST = \
79   ${DST}/index.html \
80   ${DST}/conduct/index.html \
81   ${DST}/setup/index.html \
82   $(patsubst _episodes/%.md,${DST}/%/index.html,$(wildcard _episodes/*.md)) \
83   ${DST}/reference/index.html \
84   $(patsubst _extras/%.md,${DST}/%/index.html,$(wildcard _extras/*.md)) \
85   ${DST}/license/index.html
86
87 ## lesson-rmd       : convert Rmarkdown files to markdown
88 lesson-rmd: $(RMD_SRC)
89         @bin/knit_lessons.sh $(RMD_SRC)
90
91 ## lesson-check     : validate lesson Markdown.
92 lesson-check :
93         @bin/lesson_check.py -s . -p ${PARSER}
94
95 ## lesson-check-all : validate lesson Markdown, checking line lengths and trailing whitespace.
96 lesson-check-all :
97         @bin/lesson_check.py -s . -p ${PARSER} -l -w
98
99 ## unittest         : run unit tests on checking tools.
100 unittest :
101         python bin/test_lesson_check.py
102
103 ## lesson-files     : show expected names of generated files for debugging.
104 lesson-files :
105         @echo 'RMD_SRC:' ${RMD_SRC}
106         @echo 'RMD_DST:' ${RMD_DST}
107         @echo 'MARKDOWN_SRC:' ${MARKDOWN_SRC}
108         @echo 'HTML_DST:' ${HTML_DST}
109
110 ## lesson-fixme     : show FIXME markers embedded in source files.
111 lesson-fixme :
112         @fgrep -i -n FIXME ${MARKDOWN_SRC} || true
113
114 #-------------------------------------------------------------------------------
115 # Include extra commands if available.
116 #-------------------------------------------------------------------------------
117
118 -include commands.mk