|
| 1 | +.PHONY: clean 1e 2e redirects live publish-draft publish-production sync-atlas asciidoc hugo lab appendix |
| 2 | +.SUFFIXES: |
| 3 | + |
| 4 | +.ONESHELL: |
| 5 | +SHELL = /usr/bin/env bash -o pipefail |
| 6 | +.SHELLFLAGS = -e |
| 7 | + |
| 8 | +clean: |
| 9 | + rm -f book/2e/book.md |
| 10 | + |
| 11 | +live: |
| 12 | + cd www && hugo server --disableFastRender |
| 13 | + |
| 14 | +2e: book/2e/*.Rmd |
| 15 | + cd book/2e && rm -f book.md && Rscript --vanilla -e 'bookdown::render_book("index.Rmd", encoding = "UTF-8", clean = FALSE)' |
| 16 | + |
| 17 | +1e: www/static/1e/index.html |
| 18 | + |
| 19 | +redirects: www/static/_redirects |
| 20 | + |
| 21 | +www/static/1e/index.html: book/1e/* |
| 22 | + cd book/1e && Rscript --vanilla -e 'bookdown::render_book("index.Rmd", encoding = "UTF-8")' |
| 23 | + |
| 24 | +www/static/_redirects: |
| 25 | + curl -sL datascienceatthecommandline.com/1e | \ |
| 26 | + grep -Eo 'href="(.*)\.html"' | \ |
| 27 | + grep -v 'index' | \ |
| 28 | + cut -d\" -f 2 | \ |
| 29 | + sort -n | \ |
| 30 | + uniq | \ |
| 31 | + sed -E "s|(.*)|/\1 /1e/\1|" > $@ |
| 32 | + |
| 33 | +hugo: |
| 34 | + (cd www && hugo) && \ |
| 35 | + (cd book/2e/data && zip data */*) && \ |
| 36 | + mv book/2e/data/data.zip www/static/2e/ |
| 37 | + |
| 38 | +publish-draft: hugo |
| 39 | + netlify deploy --dir www/public |
| 40 | + |
| 41 | +publish-production: hugo |
| 42 | + netlify deploy --prod --dir www/public |
| 43 | + |
| 44 | +book/2e/%.utf8.md: book/2e/%.Rmd |
| 45 | + cd book/2e && Rscript --vanilla -e 'bookdown::render_book("$*.Rmd", encoding = "UTF-8", preview = TRUE, clean = FALSE)' |
| 46 | + |
| 47 | + |
| 48 | +foreword: book/2e/foreword.utf8.md |
| 49 | +preface: book/2e/preface.utf8.md |
| 50 | +ch01: book/2e/01.utf8.md |
| 51 | +ch02: book/2e/02.utf8.md |
| 52 | +ch03: book/2e/03.utf8.md |
| 53 | +ch04: book/2e/04.utf8.md |
| 54 | +ch05: book/2e/05.utf8.md |
| 55 | +ch06: book/2e/06.utf8.md |
| 56 | +ch07: book/2e/07.utf8.md |
| 57 | +ch08: book/2e/08.utf8.md |
| 58 | +ch09: book/2e/09.utf8.md |
| 59 | +ch10: book/2e/10.utf8.md |
| 60 | +ch11: book/2e/11.utf8.md |
| 61 | +tools: book/2e/tools.utf8.md |
| 62 | + |
| 63 | +ch%: book/2e/%.utf8.md |
| 64 | + |
| 65 | +book/2e/atlas/ch%.asciidoc: book/2e/%.utf8.md |
| 66 | + < $< book/2e/bin/atlas.sh > $@ |
| 67 | + |
| 68 | +book/2e/atlas/foreword.asciidoc: book/2e/foreword.utf8.md |
| 69 | + < $< book/2e/bin/atlas.sh > $@ |
| 70 | + |
| 71 | +book/2e/atlas/preface.asciidoc: book/2e/preface.utf8.md |
| 72 | + < $< book/2e/bin/atlas.sh > $@ |
| 73 | + |
| 74 | +book/2e/atlas/tools.asciidoc: book/2e/tools.utf8.md |
| 75 | + < $< book/2e/bin/atlas.sh > $@ |
| 76 | + |
| 77 | +asciidoc: book/2e/bin/pygments-filter.py book/2e/atlas/foreword.asciidoc book/2e/atlas/preface.asciidoc book/2e/atlas/ch01.asciidoc book/2e/atlas/ch02.asciidoc book/2e/atlas/ch03.asciidoc book/2e/atlas/ch04.asciidoc book/2e/atlas/ch05.asciidoc book/2e/atlas/ch06.asciidoc book/2e/atlas/ch07.asciidoc book/2e/atlas/ch08.asciidoc book/2e/atlas/ch09.asciidoc book/2e/atlas/ch10.asciidoc book/2e/atlas/ch11.asciidoc book/2e/atlas/tools.asciidoc |
| 78 | + |
| 79 | +sync-atlas: asciidoc |
| 80 | + @cp -v book/2e/atlas/*.asciidoc ../../atlas/data-science-at-the-command-line-2e/ |
| 81 | + @cp -v book/2e/images/* ../../atlas/data-science-at-the-command-line-2e/images |
| 82 | + @echo "Syncing Asciidoc files to Atlas" |
| 83 | + |
| 84 | +docker-run: |
| 85 | + docker run -it --rm -v $$(pwd)/book/2e/data:/data -p 8000:8000 datasciencetoolbox/dsatcl2e:latest |
| 86 | + |
| 87 | +update-cache: |
| 88 | + cd book/2e/data/cache && \ |
| 89 | + curl -sL 'https://github.com/r-dbi/RSQLite/raw/master/inst/db/datasets.sqlite' -O && \ |
| 90 | + ls -lAshF |
| 91 | + |
| 92 | +attach: |
| 93 | + tmux set-option window-size manual &&\ |
| 94 | + tmux attach -t knitractive_console |
| 95 | + |
| 96 | +ref-bib-names: |
| 97 | + cat book/2e/tools.bib | grep -E '^@' | tr '{' , | cut -d , -f 2 |
| 98 | + |
| 99 | +ref-bib-titles: |
| 100 | + cat book/2e/tools.bib | grep -E '^@' | tr '{' , | cut -d , -f 2 |
| 101 | + |
| 102 | +ref-text-all: |
| 103 | + grep -noE '\[@([^]]+)\]' book/2e/*.Rmd | column -s ':' -t |
| 104 | + |
| 105 | +ref-text-num-per-chapter: |
| 106 | + @grep -oE '\[@([^]]+)\]' book/2e/*.Rmd | sort | uniq -c |
| 107 | + |
| 108 | +ref-text-duplicate-per-chapter: |
| 109 | + @make ref-text-num-per-chapter | grep -v '1 ' |
| 110 | + |
| 111 | +ref-tools-per-chapter: |
| 112 | + @ggrep -oE ' `[A-Za-z]+`' book/2e/*.Rmd | sort | uniq | tr -d '` ' | tr ':' '\t' | sort -k 2 |
| 113 | + |
| 114 | +ref-check: ref-text-duplicate-per-chapter |
| 115 | + |
| 116 | +lab: |
| 117 | + docker run --rm -it -p 8888:8888 -p 4040:4040 -v "$$(pwd)":/opt/notebooks jupyter/pyspark-notebook:42f4c82a07ff /bin/bash -c "/opt/conda/bin/jupyter lab --notebook-dir=/opt/notebooks --ip='0.0.0.0' --port=8888 --no-browser --allow-root" |
| 118 | + |
| 119 | +appendix: |
| 120 | + cd book/2e/bin && ./appendix.py > ../tools.Rmd |
| 121 | + |
| 122 | +figure-log: |
| 123 | + cd book/2e && cat {01..11}.utf8.md | /usr/local/bin/pandoc --to muse --filter bin/pygments-filter.py > /dev/null |
| 124 | + |
| 125 | +test-color: |
| 126 | + cd book/2e && cat 02.utf8.md | /usr/local/bin/pandoc --to asciidoc --filter bin/pygments-filter.py |
0 commit comments