File indexing completed on 2025-11-03 10:11:46
0001 
0002 
0003 
0004 
0005 MAKEFILES=Makefile $(wildcard *.mk)
0006 JEKYLL=bundle config set --local path .vendor/bundle && bundle install && bundle update && bundle exec jekyll
0007 PARSER=bin/markdown_ast.rb
0008 DST=_site
0009 
0010 
0011 DOCKER := $(shell which docker 2>/dev/null)
0012 
0013 
0014 
0015 PYTHON3_EXE := $(shell which python3 2>/dev/null)
0016 ifneq (, $(PYTHON3_EXE))
0017   ifeq (,$(findstring Microsoft/WindowsApps/python3,$(subst \,/,$(PYTHON3_EXE))))
0018     PYTHON := $(PYTHON3_EXE)
0019   endif
0020 endif
0021 
0022 ifeq (,$(PYTHON))
0023   PYTHON_EXE := $(shell which python 2>/dev/null)
0024   ifneq (, $(PYTHON_EXE))
0025     PYTHON_VERSION_FULL := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1)))
0026     PYTHON_VERSION_MAJOR := $(word 1,${PYTHON_VERSION_FULL})
0027     ifeq (3, ${PYTHON_VERSION_MAJOR})
0028       PYTHON := $(PYTHON_EXE)
0029     else
0030       PYTHON_NOTE = "Your system does not appear to have Python 3 installed."
0031     endif
0032   else
0033       PYTHON_NOTE = "Your system does not appear to have any Python installed."
0034   endif
0035 endif
0036 
0037 
0038 
0039 .DEFAULT_GOAL := commands
0040 
0041 
0042 
0043 
0044 .PHONY: site docker-serve repo-check clean clean-rmd
0045 
0046 
0047 serve : lesson-md index.md
0048         ${JEKYLL} serve
0049 
0050 
0051 site : lesson-md index.md
0052         ${JEKYLL} build
0053 
0054 
0055 docker-serve :
0056 ifeq (, $(DOCKER))
0057         $(error Your system does not appear to have Docker installed)
0058 else
0059         @$(DOCKER) pull carpentries/lesson-docker:latest
0060         @$(DOCKER) run --rm -it \
0061                 -v $${PWD}:/home/rstudio \
0062                 -p 4000:4000 \
0063                 -p 8787:8787 \
0064                 -e USERID=$$(id -u) \
0065                 -e GROUPID=$$(id -g) \
0066                 carpentries/lesson-docker:latest
0067 endif
0068 
0069 
0070 repo-check : python
0071         @${PYTHON} bin/repo_check.py -s .
0072 
0073 
0074 clean :
0075         @rm -rf ${DST}
0076         @rm -rf .sass-cache
0077         @rm -rf bin/__pycache__
0078         @rm -rf .vendor
0079         @rm -rf .bundle
0080         @rm -f Gemfile.lock
0081         @find . -name .DS_Store -exec rm {} \;
0082         @find . -name '*~' -exec rm {} \;
0083         @find . -name '*.pyc' -exec rm {} \;
0084 
0085 
0086 clean-rmd :
0087         @rm -rf ${RMD_DST}
0088         @rm -rf fig/rmd-*
0089 
0090 
0091 
0092 
0093 
0094 
0095 .PHONY : workshop-check
0096 
0097 
0098 workshop-check : python
0099         @${PYTHON} bin/workshop_check.py .
0100 
0101 
0102 
0103 
0104 
0105 
0106 .PHONY : lesson-check lesson-md lesson-files lesson-fixme install-rmd-deps
0107 
0108 
0109 RMD_SRC = $(wildcard _episodes_rmd/*.Rmd)
0110 RMD_DST = $(patsubst _episodes_rmd/%.Rmd,_episodes/%.md,$(RMD_SRC))
0111 
0112 
0113 MARKDOWN_SRC = \
0114   index.md \
0115   CODE_OF_CONDUCT.md \
0116   setup.md \
0117   $(sort $(wildcard _episodes/*.md)) \
0118   reference.md \
0119   $(sort $(wildcard _extras/*.md)) \
0120   LICENSE.md
0121 
0122 
0123 HTML_DST = \
0124   ${DST}/index.html \
0125   ${DST}/conduct/index.html \
0126   ${DST}/setup/index.html \
0127   $(patsubst _episodes/%.md,${DST}/%/index.html,$(sort $(wildcard _episodes/*.md))) \
0128   ${DST}/reference.html \
0129   $(patsubst _extras/%.md,${DST}/%/index.html,$(sort $(wildcard _extras/*.md))) \
0130   ${DST}/license/index.html
0131 
0132 
0133 install-rmd-deps:
0134         @${SHELL} bin/install_r_deps.sh
0135 
0136 
0137 lesson-md : ${RMD_DST}
0138 
0139 _episodes/%.md: _episodes_rmd/%.Rmd install-rmd-deps
0140         @mkdir -p _episodes
0141         @$(SHELL) bin/knit_lessons.sh $< $@
0142 
0143 
0144 lesson-check : python lesson-fixme
0145         @${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md
0146 
0147 
0148 lesson-check-all : python
0149         @${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md -l -w --permissive
0150 
0151 
0152 unittest : python
0153         @${PYTHON} bin/test_lesson_check.py
0154 
0155 
0156 lesson-files :
0157         @echo 'RMD_SRC:' ${RMD_SRC}
0158         @echo 'RMD_DST:' ${RMD_DST}
0159         @echo 'MARKDOWN_SRC:' ${MARKDOWN_SRC}
0160         @echo 'HTML_DST:' ${HTML_DST}
0161 
0162 
0163 lesson-fixme :
0164         @grep --fixed-strings --word-regexp --line-number --no-messages FIXME ${MARKDOWN_SRC} || true
0165 
0166 
0167 
0168 
0169 
0170 .PHONY : commands python
0171 
0172 
0173 commands :
0174         @sed -n -e '/^##/s|^##[[:space:]]*||p' $(MAKEFILE_LIST)
0175 
0176 python :
0177 ifeq (, $(PYTHON))
0178         $(error $(PYTHON_NOTE))
0179 else
0180         @:
0181 endif
0182 
0183 index.md :
0184 ifeq (, $(wildcard index.md))
0185         $(error index.md not found)
0186 else
0187         @:
0188 endif