-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
80 lines (68 loc) · 1.97 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
TEMP_DIR:=./_tmp
PANDOC=pandoc
PREPROCESS=python _scripts/preprocess.py
BUILD_DIR=_build
ASSETS_DIR=_assets
MD_OUTPUT=documentation.md
HTML_OUTPUT=index.html
RST_OUTPUT=index.rst
all: init md2html md2rst build
@echo '-- The documentation has been successfully generated.'
init:
@mkdir -p $(BUILD_DIR)
cprsrc:
@echo -n '-- Copying the required assets into the temp folder...'
@mkdir -p $(TEMP_DIR)
@cp 0*.md* $(TEMP_DIR)/
@cp $(ASSETS_DIR)/stylesheet.css $(TEMP_DIR)/
@echo ' Done.'
concat: cprsrc
@echo -n '-- Concatenating the Markdown files...'
@cat $(TEMP_DIR)/0*.md > $(TEMP_DIR)/$(MD_OUTPUT)
@echo ' Done.'
preprocess:
@echo -n '-- Syntax-highlighting code blocks...'
@$(PREPROCESS) $(TEMP_DIR)/$(MD_OUTPUT) $(TEMP_DIR)
@echo ' Done.'
md2html: concat preprocess
@echo -n '-- Converting the Markdown document to HTML...'
@$(PANDOC) --standalone \
--html5 \
--toc \
--section-divs \
--title="The ooc language" \
--css=stylesheet.css \
--template=$(ASSETS_DIR)/template.html \
--include-before-body=_assets/header.html \
-o $(TEMP_DIR)/$(HTML_OUTPUT) \
$(TEMP_DIR)/$(MD_OUTPUT)
@echo ' Done.'
md2rst: concat preprocess
@echo -n '-- Converting the Markdown document to HTML...'
@$(PANDOC) --standalone \
-f markdown -t rst \
--toc \
--section-divs \
--title="The ooc language" \
-o $(TEMP_DIR)/$(RST_OUTPUT) \
$(TEMP_DIR)/$(MD_OUTPUT)
@echo ' Done.'
build:
@echo -n '-- Copying the required assets into the build folder...'
@cat $(TEMP_DIR)/highlight.css >> $(TEMP_DIR)/stylesheet.css
@cp $(TEMP_DIR)/index.html $(BUILD_DIR)/
@cp $(TEMP_DIR)/stylesheet.css $(BUILD_DIR)/
@cp $(TEMP_DIR)/index.rst $(BUILD_DIR)/
@echo ' Done.'
publish:
@git checkout gh-pages
@rm -f stylesheet.css index.html
@cp $(BUILD_DIR)/stylesheet.css ./
@cp $(BUILD_DIR)/index.html ./
@git add .
@git commit -m "Update the documentation."
@git push origin gh-pages
@git checkout master
clean:
@rm -rf $(TEMP_DIR) $(BUILD_DIR)
.PHONY: all