-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathMakefile
77 lines (59 loc) · 2.1 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
# Makefile to use knitr for package vignettes
# put all PDF targets here, separated by spaces
# ---------------------------------------------
# Settings, targets, and source files
# Source files for the macros
SRC = $(sort $(wildcard src/*.sas))
# Html documentation files generated by DocItOut
HTML_DIR = ./doc/html
HTML_SRC_DIR = $(HTML_DIR)/src
HTML_DOC := $(sort $(wildcard $(HTML_SRC_DIR)/*.html))
# Outputting markdown files, to be cleaned up after processing
MD_DOC := $(HTML_DOC:.html=.md)
# PDF documentions of the SAS macros
PDF_DIR = ./doc/pdf
PDF_OPTIONS = $(PDF_DIR)/opt/metadata.yaml
PDF_DOC := $(PDF_DIR)/sasToolkit_manual.pdf
# ---------------------------------------------
# If make is run without a specified target (ie. `make`), a list of
# commands will be presented.
all: commands
# ---------------------------------------------
# Commands to create the pdf documentation
$(HTML_SRC_DIR)/%.md : $(HTML_SRC_DIR)/%.html
@pandoc $< -p --highlight-style=tango \
--indented-code-classes=Java \
--to=markdown | \
tail -n+22 | \
head -n-27 | \
sed -e '/ \-/,/Macro Detail/d' \
-e '/^\\/d' \
-e '/^\*\*Examples/a\ \n\`\`\`' \
-e '/^\*\*Parameters/i\`\`\`\n' | \
sed -e 's/^: /\n\*/' | \
sed -e 's/^ \%macro/\`\%macro/' | \
sed -e "/\`\%macro/ s/$$/\`/" | \
sed -e "/^root/d" -e '/^\-\-/d' | \
fold -s -w 80 | cat > $@
@find $(HTML_SRC_DIR) -type f -iname "docitout*.md" \
-iname "macros.md" -delete
$(PDF_DOC) : $(PDF_OPTIONS) $(MD_DOC)
@pandoc $? -o $@
@find $(HTML_DIR) -type f -iname '*.md' -delete
## ---------------------------------------------
## commands : Show all commands in Makefile
commands :
@grep -E '^##' Makefile | sed -e 's/##//g'
## ---------------------------------------------
## pdf_doc : Generate the pdf documentations from the html files
pdf_doc : $(PDF_DOC)
## readme : Generate the README pdf file.
readme :
@sed -i 's/-+-/-|-/g' README.md
@pandoc .metadata.yaml README.md \
--highlight-style=tango \
-o README.pdf
## clean : Remove extraneous files (html docs)
clean :
@find $(HTML_DIR) -type f -delete
.PHONY: commands readme pdf_doc clean