-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
172 lines (139 loc) · 5.03 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
ROOT := $(shell pwd)
PATH := ${ROOT}/node_modules/.bin:${PATH}
NPM_PACKAGE := $(shell node -e 'process.stdout.write(require("./package.json").name)')
NPM_VERSION := $(shell node -e 'process.stdout.write(require("./package.json").version)')
HOMEPAGE := $(shell node -e 'process.stdout.write(require("./package.json").homepage)')
TMP_PATH := /tmp/${NPM_PACKAGE}-$(shell date +%s)
REMOTE_NAME ?= origin
REMOTE_REPO ?= $(shell git config --get remote.${REMOTE_NAME}.url)
CURR_HEAD := $(firstword $(shell git show-ref --hash HEAD | cut -b -6) master)
GITHUB_PROJ := nodeca/${NPM_PACKAGE}
JS_PGEN ?= pegjs
help:
echo "make help - Print this help"
echo "make lint - Lint sources with JSHint"
echo "make test - Lint sources and run all tests"
echo "make doc - Build API docs"
echo "make gh-pages - Build and push API docs into gh-pages branch"
echo "make publish - Set new version tag and publish npm package"
echo "make todo - Find and list all TODOs"
lint:
./node_modules/.bin/eslint .
publish:
@if test 0 -ne `git status --porcelain | wc -l` ; then \
echo "Unclean working tree. Commit or stash changes first." >&2 ; \
exit 128 ; \
fi
@if test 0 -ne `git fetch ; git status | grep '^# Your branch' | wc -l` ; then \
echo "Local/Remote history differs. Please push/pull changes." >&2 ; \
exit 128 ; \
fi
@if test 0 -ne `git tag -l ${NPM_VERSION} | wc -l` ; then \
echo "Tag ${NPM_VERSION} exists. Update package.json" >&2 ; \
exit 128 ; \
fi
git tag ${NPM_VERSION} && git push origin ${NPM_VERSION}
npm publish https://github.com/${GITHUB_PROJ}/tarball/${NPM_VERSION}
lib: lib/ndoc/plugins/parsers/javascript/parser.js
ifeq ($(JS_PGEN),jison)
lib/ndoc/plugins/parsers/javascript/parser.js: src/js-parser.y
@if test ! `which jison` ; then \
echo "You need 'jison' installed in order to compile parsers." >&2 ; \
echo " $ make dev-deps" >&2 ; \
exit 128 ; \
fi
jison < $< > $@
endif
ifeq ($(JS_PGEN),pegjs)
lib/ndoc/plugins/parsers/javascript/parser.js: src/js-parser.peg
@if test ! `which pegjs` ; then \
echo "You need 'pegjs' installed in order to compile parsers." >&2 ; \
echo " $ make dev-deps" >&2 ; \
exit 128 ; \
fi
pegjs --track-line-and-column $< $@
endif
recompile-parsers:
rm -f lib/ndoc/plugins/parsers/javascript/parser.js
$(MAKE) lib
todo:
grep 'TODO' -n -r ./lib 2>/dev/null || test true
.PHONY: publish lint test doc dev-deps gh-pages todo playground redo $(DOCS)
.SILENT: help lint test doc todo
DIRS = $(addprefix playground/,$(shell ls playground 2>/dev/null | sed '/index.html/d'))
LIBS = $(addsuffix /lib,$(DIRS))
DOCS = $(addsuffix /doc,$(DIRS))
playground: $(DOCS)
echo Indexing
echo $(DOCS) | sed -r 's~playground/(\S+)/doc~<li><a href="\1/doc/index.html">\1</a></li>~g' | sed 'i<html><body><ul>' | sed 'a</ul></body></html>' >$@/index.html
echo Open playground/index.html
doc: lib
rm -fr doc
$(ROOT)/bin/ndoc.js --link-format "{package.homepage}/blob/${CURR_HEAD}/{file}#L{line}"
test-prototype:
rm -fr ./tests/prototype-doc
$(ROOT)/bin/ndoc.js --noenv -o ./tests/prototype-doc --broken-links show \
--index ./tests/prototype/README.markdown \
--link-format 'https://github.com/sstephenson/prototype/blob/master/{file}#L{line}' \
--title "Prototype v1.7" \
./tests/prototype/src
test-features:
rm -fr ./tests/features-doc
$(ROOT)/bin/ndoc.js --noenv -o ./tests/features-doc --broken-links show -t "NDoc new features" \
--gh-ribbon '{package.homepage}' ./tests/features
test: lint test-prototype test-features
$(DOCS): $(LIBS)
echo Compiling documentation for $(@D)
#rm -f lib/parser.js
rm -rf $@
cd $(@D) && $(ROOT)/bin/ndoc.js -o doc -i README.md --package ./package.json lib
proto-pages:
@if test -z ${REMOTE_REPO} ; then \
echo 'Remote repo URL not found' >&2 ; \
exit 128 ; \
fi
mkdir ${TMP_DIR}
touch ${TMP_DIR}/.nojekyll
mkdir -p ${TMP_DIR}/tests/doc \
&& cp -r tests/prototype-doc/* ${TMP_DIR}/tests/doc
cd ${TMP_DIR} && \
git init && \
git add . && \
git commit -q -m 'Recreated docs'
cd ${TMP_DIR} && \
git remote add remote ${REMOTE_REPO} && \
git push --force remote +master:gh-pages
rm -rf ${TMP_DIR}
@echo
@echo 'URL: http://nodeca.github.com/ndoc/tests/doc/'
gh-pages:
@if test -z ${REMOTE_REPO} ; then \
echo 'Remote repo URL not found' >&2 ; \
exit 128 ; \
fi
$(MAKE) doc && \
cp -r ./doc ${TMP_PATH} && \
touch ${TMP_PATH}/.nojekyll
#
# Building test docs
#
$(MAKE) test-prototype test-features
mkdir ${TMP_PATH}/tests
cp -r tests/prototype-doc ${TMP_PATH}/tests/prototype
cp -r tests/features-doc ${TMP_PATH}/tests/features
#
# Push changes
#
cd ${TMP_PATH} && \
git init && \
git add . && \
git commit -q -m 'Recreated docs'
cd ${TMP_PATH} && \
git remote add remote ${REMOTE_REPO} && \
git push --force remote +master:gh-pages
rm -rf ${TMP_PATH}
@echo
@echo 'gh-pages updated...'
@echo 'Main URL: http://nodeca.github.com/ndoc'
@echo 'Prototype URL: http://nodeca.github.com/ndoc/tests/prototype'
@echo 'Features URL: http://nodeca.github.com/ndoc/tests/features'