Skip to content

Commit

Permalink
add version number getting/building to comments/docs
Browse files Browse the repository at this point in the history
  • Loading branch information
paularmstrong committed Aug 14, 2013
1 parent 16a85c4 commit 15c72c5
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 12 deletions.
57 changes: 49 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
SHA := $(shell git rev-parse HEAD)
THIS_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
VERSION_REGEX = [0-9]*\.[0-9]*\.[0-9]*[^\" ]*
VERSION := $(shell npm ls | grep "swig@" | grep -Eo "${VERSION_REGEX}" -m 1)

TMP = 'tmp_build'
REMOTE = origin
Expand All @@ -12,6 +14,10 @@ all:
@cp scripts/githooks/* .git/hooks/
@chmod -R +x .git/hooks/

browser/comments.js: FORCE
@sed -i.bak 's/v${VERSION_REGEX}/v${VERSION}/' $@
@rm $@.bak

.SECONDARY dist/swig.js: \
browser/comments.js

Expand All @@ -33,7 +39,8 @@ all:
tests/tags/set.test.js \
tests/tags/spaceless.test.js \
tests/basic.test.js
clean:

clean: FORCE
@rm -rf dist
@rm -rf ${TMP}

Expand All @@ -44,13 +51,16 @@ dist:
@mkdir -p $@

dist/swig.js:
@echo "Building $@..."
@cat $^ > $@
@${BIN}/browserify browser/index.js >> $@

dist/swig.min.js:
@echo "Building $@..."
@${BIN}/uglifyjs $^ --comments -c warnings=false -m --source-map dist/swig.js.map > $@

browser/test/tests.js:
@echo "Building $@..."
@cat $^ > tests/browser.js
@perl -pi -e 's/\.\.\/\.\.\/lib/\.\.\/lib/g' tests/browser.js
@${BIN}/browserify tests/browser.js > $@
Expand All @@ -62,7 +72,7 @@ opts =
test:
@${BIN}/mocha --reporter ${reporter} ${opts} ${tests}

test-browser: clean browser/test/tests.js
test-browser: FORCE clean browser/test/tests.js
@${BIN}/mocha-phantomjs browser/test/index.html --reporter ${reporter}

files := $(shell find . -name '*.js' ! -path "./node_modules/*" ! -path "./dist/*" ! -path "./browser*" ! -path "./docs*")
Expand All @@ -84,11 +94,37 @@ else
endif

JSDOCOPTS=-t node_modules/jsdoc/templates/haruki/ -d console
build-docs:
@${BIN}/jsdoc lib/swig.js ${JSDOCOPTS} > docs/docs/api.json
@${BIN}/jsdoc lib/filters.js ${JSDOCOPTS} > docs/docs/filters.json
@${BIN}/jsdoc lib/tags/ ${JSDOCOPTS} > docs/docs/tags.json
@make coverage out=docs/coverage.html
docs/index.json: FORCE
@echo "Building $@..."
@sed -i.bak 's/v${VERSION_REGEX}/v${VERSION}/' $@
@rm $@.bak

docs/coverage.html: FORCE
@echo "Building $@..."
@make coverage out=$@

docs/docs/api.json: FORCE
@echo "Building $@..."
@${BIN}/jsdoc lib/swig.js ${JSDOCOPTS} > $@

docs/docs/filters.json: FORCE
@echo "Building $@..."
@${BIN}/jsdoc lib/filters.js ${JSDOCOPTS} > $@

docs/docs/tags.json: FORCE
@echo "Building $@..."
@${BIN}/jsdoc lib/tags/ ${JSDOCOPTS} > $@

.SECONDARY build-docs: \
docs/index.json

.INTERMDIATE build-docs: \
docs/docs/api.json \
docs/docs/filters.json \
docs/docs/tags.json

build-docs: FORCE
@echo "Documentation built."

docs: clean build build-docs
@mkdir -p ${TMP}/js
Expand All @@ -113,4 +149,9 @@ port = 3000
test-docs: build build-docs
@${BIN}/still-server docs/ -p ${port} -o

.PHONY: all build build-docs test test-browser browser/test/tests.js lint coverage docs test-docs
FORCE:

.PHONY: all \
build build-docs \
test test-browser lint coverage \
docs/index.json docs test-docs
2 changes: 1 addition & 1 deletion browser/comments.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/*! Swig https://paularmstrong.github.com/swig | https://github.com/paularmstrong/swig/blob/master/LICENSE */
/*! Swig v1.0.0-pre1 | https://paularmstrong.github.com/swig | https://github.com/paularmstrong/swig/blob/master/LICENSE */
/*! DateZ (c) 2011 Tomo Universalis | https://github.com/TomoUniversalis/DateZ/blob/master/LISENCE */
6 changes: 4 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<h1>Swig</h1>
<p>A Node.js and Browser-based JavaScript Template Engine</p>

<p>Current Version: {{ version }}</p>

<hr class="small">

<div class="row guttered">
Expand All @@ -21,7 +23,7 @@ <h1>Swig</h1>
<h2>Get Started</h2>

<h3>Install Swig</h3>
<pre><code>npm install swig</code></pre>
<pre><code>npm install swig --save</code></pre>

<h3>Create Your Template</h3>
<pre><code data-language="swig">{% raw %}&lt;h1&gt;{{ pagename|title }}&lt;/h1&gt;
Expand Down Expand Up @@ -70,7 +72,7 @@ <h2>Features</h2>
<h2>Download For the Browser</h2>
<p>Swig also works in all major browsers. Just download the following file and follow the <a href="{{ baseurl }}/docs/#browser">Documentation</a>.</p>
<p class="download">
<a href="{{ baseurl }}/js/swig.min.js" class="btn">Download</a><br><br>
<a href="{{ baseurl }}/js/swig.min.js" class="btn">Download {{ version }}</a><br><br>
<a href="{{ baseurl }}/js/swig.js">Development</a> | <a href="{{ baseurl }}/js/swig.min.js">Production</a>
</p>
</section>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"section": "home"
"version": "v1.0.0-pre1"
}

0 comments on commit 15c72c5

Please sign in to comment.