Browse Source

Makefile rules for gh-pages

Viktor Söderqvist 10 years ago
parent
commit
a638874736
2 changed files with 50 additions and 2 deletions
  1. 48 0
      Makefile
  2. 2 2
      README.md

+ 48 - 0
Makefile

@@ -0,0 +1,48 @@
+# This Makefile is used to build documentation in the gh-pages branch.
+
+.PHONY: all gh-pages eunit edoc
+
+all:
+	@echo "Do 'make gh-pages' to commit in the gh-pages branch containing"
+	@echo "the generated EDoc and the EUnit coverage report."
+
+edoc:
+	rebar doc
+
+eunit:
+	rebar eunit | tee .eunit/output
+
+# Build eunit.html containing the coverage report and the eunit output.
+doc/eunit.html: eunit
+	(echo '<!DOCTYPE html>' ; \
+	 cat .eunit/index.html | sed 's!</body></html>!!' ; \
+	 echo '<h3>Output</h3><pre>' ; \
+	 sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g;' .eunit/output ; \
+	 echo '</pre>' ; \
+	 echo '<p><em>Generated using EUnit,' ; \
+	 date -u '+%d %h %Y %H:%M:%S UTC.' ; \
+	 echo '</em></p>' ; \
+	 echo '</body></html>') > doc/eunit.html
+
+# Update the local 'gh-pages' branch with pregenerated output files
+# (trick from https://groups.google.com/forum/#!topic/github/XYxkdzxpgCo)
+gh-pages: doc/eunit.html edoc
+	@if [ $$(git name-rev --name-only HEAD) != master ] ; then \
+	  echo "Not on master. Aborting." ; \
+	  false ; \
+	fi
+	cp .eunit/*.COVER.html doc/
+	git update-ref refs/heads/gh-pages origin/gh-pages '' 2>/dev/null || true
+	GIT_INDEX_FILE=gitindex.tmp; export GIT_INDEX_FILE; \
+	rm -f $${GIT_INDEX_FILE} && \
+	git add -f doc/*.html doc/stylesheet.css doc/erlang.png && \
+	git update-ref refs/heads/gh-pages \
+	    $$(echo "Autogenerated html pages for $$(git describe)" \
+	        | git commit-tree $$(git write-tree --prefix=doc) \
+	                    -p refs/heads/gh-pages)
+	rm gitindex.tmp
+	@echo "=== Done ==="
+
+# Credits:
+#
+

+ 2 - 2
README.md

@@ -17,8 +17,8 @@ Features:
 
 See also:
 
-* [API documenation](//mysql-otp.github.io/mysql-otp/doc/index.html) (Edoc)
-* [Test coverage](//mysql-otp.github.io/mysql-otp/.eunit/index.html) (EUnit)
+* [API documenation](//mysql-otp.github.io/mysql-otp/index.html) (Edoc)
+* [Test coverage](//mysql-otp.github.io/mysql-otp/eunit.html) (EUnit)
 * [Why another MySQL driver?](https://github.com/mysql-otp/mysql-otp/wiki#why-another-mysql-driver) in the wiki
 
 This is a work in progress. The API and the value representation may still