forked from NikJoj/plotly.py-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (43 loc) · 2.02 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
export PLOTLY_RENDERER=notebook_connected
MD_DIR ?= python
UNCONV_DIR ?= unconverted/python
IPYNB_DIR ?= build/ipynb
HTML_DIR ?= build/html
FAIL_DIR ?= build/failures
REDIR_DIR ?= build/html/redir
MD_FILES := $(shell ls $(MD_DIR)/*.md)
UNCONV_FILES := $(shell ls $(UNCONV_DIR)/*.md)
IPYNB_FILES := $(patsubst $(MD_DIR)/%.md,$(IPYNB_DIR)/%.ipynb,$(MD_FILES))
HTML_FILES := $(patsubst $(MD_DIR)/%.md,$(HTML_DIR)/2019-07-03-%.html,$(MD_FILES))
NEXT_REDIR_FILES := $(patsubst $(MD_DIR)/%.md,$(REDIR_DIR)/2019-07-03-redirect-next-%.html,$(MD_FILES))
V3_REDIR_FILES := $(patsubst $(UNCONV_DIR)/%.md,$(REDIR_DIR)/2019-07-03-redirect-v3-%.html,$(UNCONV_FILES))
all: $(HTML_FILES) $(V3_REDIR_FILES) $(NEXT_REDIR_FILES)
.PRECIOUS: $(IPYNB_FILES)
$(IPYNB_DIR)/.mapbox_token: $(MD_DIR)/.mapbox_token
@mkdir -p $(IPYNB_DIR)
cd $(IPYNB_DIR) && ln -s ../../$<
$(IPYNB_FILES): $(IPYNB_DIR)/.mapbox_token
$(IPYNB_DIR)/%.ipynb: $(MD_DIR)/%.md
@mkdir -p $(IPYNB_DIR)
@echo "[jupytext] $<"
@jupytext $< --to notebook --quiet --output $@
$(HTML_DIR)/2019-07-03-%.html: $(IPYNB_DIR)/%.ipynb
@mkdir -p $(HTML_DIR)
@mkdir -p $(FAIL_DIR)
@echo "[nbconvert] $<"
@jupyter nbconvert $< --to html --template nb.tpl \
--output-dir $(HTML_DIR) --output 2019-07-03-$*.html \
--execute > $(FAIL_DIR)/$* 2>&1 && rm -f $(FAIL_DIR)/$*
$(REDIR_DIR)/2019-07-03-redirect-next-%.html: $(IPYNB_DIR)/%.ipynb
@mkdir -p $(REDIR_DIR)
@echo "[next-redir] $<"
@jupyter nbconvert $< --to html --template next_redirect.tpl \
--output-dir $(REDIR_DIR) --output 2019-07-03-redirect-next-$*.html
$(REDIR_DIR)/2019-07-03-redirect-v3-%.html: $(UNCONV_DIR)/%.md
@mkdir -p $(REDIR_DIR)
@echo "[v3-redir] $<"
@echo "---" > $(REDIR_DIR)/2019-07-03-redirect-v3-$*.html
@echo "permalink: python/$*/" >> $(REDIR_DIR)/2019-07-03-redirect-v3-$*.html
@echo "redirect_to: https://plot.ly/python/v3/$*/" >> $(REDIR_DIR)/2019-07-03-redirect-v3-$*.html
@echo "sitemap: true" >> $(REDIR_DIR)/2019-07-03-redirect-v3-$*.html
@echo "---" >> $(REDIR_DIR)/2019-07-03-redirect-v3-$*.html