Add project docs.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Thu, 18 Sep 2014 01:51:07 +0300
changeset 77 c2bad6178c65
parent 76 804bd331bedc
child 78 1a6eb0ea9d6e
Add project docs.
.hgignore
2048.html
AUTHORS.rst
HACKING.rst
Makefile
README.rst
header.rst
rst.css
--- a/.hgignore	Thu Sep 18 01:24:29 2014 +0300
+++ b/.hgignore	Thu Sep 18 01:51:07 2014 +0300
@@ -1,4 +1,7 @@
 syntax: glob
 
 jsdoc/
-VERSION
+VERSION*
+AUTHORS.html
+CHANGES.html
+README.html
--- a/2048.html	Thu Sep 18 01:24:29 2014 +0300
+++ b/2048.html	Thu Sep 18 01:51:07 2014 +0300
@@ -113,6 +113,8 @@
 </head>
 <body>
 
+  <div class="area">[ <a href="http://js-2048-ai.sourceforge.net/2048.html">Game</a> | <a href="CHANGES.html">Changes</a> | <a href="README.html">About</a> | <a href="AUTHORS.html">Authors</a> ]</div>
+
   <h1>2048</h1>
 
   <div id="score-area" class="area">
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AUTHORS.rst	Thu Sep 18 01:51:07 2014 +0300
@@ -0,0 +1,17 @@
+.. include:: header.rst
+
+===============
+ AUTHORS list.
+===============
+.. contents::
+
+Document version.
+=================
+
+.. include:: VERSION.rst
+
+Original authors.
+=================
+
+ * Oleksandr Gavenko <gavenkoa@gmail.com>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HACKING.rst	Thu Sep 18 01:51:07 2014 +0300
@@ -0,0 +1,49 @@
+.. include:: header.rst
+
+==================
+ 2048 game JS AI.
+==================
+.. contents::
+
+Document version.
+=================
+
+.. include:: VERSION.rst
+
+Build docs.
+===========
+
+Install reStructuredText text processor - docutils. On Debian:
+
+.. code:: console
+
+  $ sudo apt-get install python-docutils
+
+Build docs:
+
+.. code:: console
+
+  $ make docs
+
+Build jsdoc.
+============
+
+.. code:: console
+
+  $ make jsdoc
+
+Refer for JSDoc syntax to:
+
+ * http://usejsdoc.org/
+ * https://developers.google.com/closure/compiler/docs/js-for-compiler
+ * https://code.google.com/p/jsdoc-toolkit/w/list
+
+Deploy to SourceForge.
+======================
+
+Be sure you at Mercurial tagged revision and run:
+
+.. code:: console
+
+  $ make deploy2sf
+
--- a/Makefile	Thu Sep 18 01:24:29 2014 +0300
+++ b/Makefile	Thu Sep 18 01:51:07 2014 +0300
@@ -80,6 +80,19 @@
 endif
 
 ################################################################
+# Build tools definition/switches.
+
+RST_WARNING_FLAGS := --halt warning
+RST_FLAGS := --strip-comments
+RST_FLAGS += $(RST_WARNING_FLAGS)
+
+RST2HTML := rst2html
+ifeq '$(host_os)' 'cygwin'
+  RST2HTML := rst2html.py
+endif
+RST2HTML_FLAGS := $(RST_FLAGS)
+
+################################################################
 # Project dirs/files.
 
 pkgname = 2048-js-ai
@@ -88,9 +101,14 @@
 
 DIST_DIR = $(fullpkgname)
 
+RST_GEN_FILES := VERSION.rst
+RST_COMMON_FILES := VERSION.rst header.rst
+RST_FILES := $(filter-out $(RST_COMMON_FILES),$(sort $(wildcard *.rst) $(RST_GEN_FILES)))
+RST_HTML_FILES := $(RST_FILES:.rst=.html)
+
 JS_FILES := $(wildcard *.js)
-HTML_FILES := $(wildcard *.html)
-WWW_FILES := $(JS_FILES) $(HTML_FILES)
+HTML_FILES := 2048.html
+WWW_FILES := $(JS_FILES) $(RST_HTML_FILES)
 
 DIST_FILES = $(WWW_FILES) README.rst VERSION
 
@@ -182,6 +200,37 @@
 	cp $(DIST_FILES) $@
 
 ################################################################
+# Documentation targets.
+
+.PHONY: docs
+docs: rst2html
+
+.PHONY: rst2html
+rst2html: $(RST_HTML_FILES)
+
+$(RST_HTML_FILES): $(RST_COMMON_FILES)
+
+$(RST_HTML_FILES): %.html: %.rst rst.css header.rst VERSION.rst $(BUILD_SCRIPTS)
+	$(RST2HTML) $(RST2HTML_FLAGS) --stylesheet=rst.css $*.rst $@
+
+VERSION.rst: VERSION $(BUILD_SCRIPTS)
+	{ \
+	echo 'For ``$(pkgname)`` version: ``$(vmajor).$(vminor)``.'; \
+	echo; \
+	case ${visclean} in \
+		yes) echo 'Source files are at revision: ``$(vrev)``.';; \
+		no) echo 'Some source files was modified from revision: ``$(vrev)``.';; \
+	esac; \
+	echo; \
+	case ${vatrelease} in \
+		yes) echo 'Package is at release state.';; \
+		no) echo 'Package is far from release state by $(vtagdist) changes.';; \
+	esac; \
+	echo; \
+	echo 'Build date: ``'$$(date +%F)'``.'; \
+	} >$@
+
+################################################################
 # Helpers targets.
 
 .PHONY: help
@@ -216,5 +265,5 @@
 
 .PHONY: clean
 clean:
-	rm -rf $(JSDOC_DIR) $(DIST_DIR) $(DIST_TARBALLS)
+	rm -rf $(JSDOC_DIR) $(RST_GEN_FILES) $(RST_HTML_FILES) $(DIST_DIR) $(DIST_TARBALLS)
 
--- a/README.rst	Thu Sep 18 01:24:29 2014 +0300
+++ b/README.rst	Thu Sep 18 01:51:07 2014 +0300
@@ -1,18 +1,30 @@
+.. include:: header.rst
 
 ==================
  2048 game JS AI.
 ==================
+.. contents::
 
-Build jsdoc.
-============
+Document version.
+=================
+
+.. include:: VERSION.rst
 
-.. code:: console
+Game rules.
+===========
+
+TODO
 
-  $ make jsdoc
+AI discussion.
+==============
 
-Refer for JSDoc syntax to:
+ * http://math.stackexchange.com/questions/727076/probability-that-random-moves-in-the-game-2048-will-win
+ * http://stackoverflow.com/questions/22342854/what-is-the-optimal-algorithm-for-the-game-2048
+ * http://codegolf.stackexchange.com/questions/25226/2048-king-on-the-hill
 
- * http://usejsdoc.org/
- * https://developers.google.com/closure/compiler/docs/js-for-compiler
- * https://code.google.com/p/jsdoc-toolkit/w/list
+Alternatives.
+=============
 
+ * http://ov3y.github.io/2048-AI/ - online JS AI.
+ * http://sztupy.github.io/2048-Hard/ - online JS AI with difficulty level.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/header.rst	Thu Sep 18 01:51:07 2014 +0300
@@ -0,0 +1,12 @@
+
+.. _Home: http://js-2048-ai.sourceforge.net/
+.. _Game: http://js-2048-ai.sourceforge.net/2048.html
+.. _About: README.html
+.. _README: README.html
+.. _CHANGES: CHANGES.html
+.. _Changes: CHANGES.html
+.. _Hacking: HACKING.html
+.. _Authors: AUTHORS.html
+
+[ Game_ | About_ | Changes_ | Hacking_ | Authors_ ]
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rst.css	Thu Sep 18 01:51:07 2014 +0300
@@ -0,0 +1,47 @@
+body, frameset { background-color: ivory; }
+body { padding: 0 10% 0 10%; }
+a { text-decoration:none; }
+a:link { color: brown; }
+a:visited { color: IndianRed; }
+a:hover { background: bisque; border-radius: 10px; padding: 1px; }
+p { text-indent: 2em; }
+p:first-letter { font-weight: bold; }
+.formula, .literal-block {
+    margin: 0 0 0 4em;
+    padding: 5px;
+    border: 1px;
+    border-style: solid;
+    border-color: brown;
+    background-color: LightYellow;
+    overflow: auto;
+}
+table {
+    border-collapse:collapse;
+    margin-left:auto;
+    margin-right:auto;
+}
+table, tr, td {
+    border: 1px dotted maroon;
+    background-color: cornsilk;
+}
+table tr td {
+    margin: 3px;
+    padding: 3px;
+}
+
+.cr { color: red; }
+.cg { color: green; }
+
+colgroup { display: none; }
+
+pre span.keyword {
+    color: blue;
+}
+pre span.function {
+    color: brown;
+}
+pre span.literal {
+    color: green;
+}
+
+