Add more documentation and generate documentation from the Makefile.

This commit is contained in:
Jos van den Oever
2010-11-02 22:22:31 +01:00
parent 5758b2f143
commit ff752e56fb
4 changed files with 55 additions and 16 deletions
+28 -6
View File
@@ -1,13 +1,35 @@
# This makefile performs a number of tasks:
# * run unit tests in
# - node.js
# - rhino
# * compile javascript into a single file with only whitespace cleaned up and
# run unit tests in node.js and rhino with that file simplecompiled.js
# * compile javascript into a single file while optimizing. This resulting file,
# compiled.js is not used anywhere but the compilation step will perform nice
# checks on the source code.
# * instrument the unit tests for determining unit test coverage.
# * generated documentation with jsdoc
COMPILERJAR=/tmp/compiler.jar
RHINOJAR=/usr/share/java/rhino.jar
NODE=/tmp/node-v0.2.4/node
JSFILES := $(wildcard lib/*.js lib/*/*.js lib/*/*/*.js tests/*/*.js tests/*/*/*.js tests/*.js)
CMD := $(foreach JSFILE,$(JSFILES), --js $(JSFILE))
JSCOVERAGE=/tmp/jscoverage-0.5.1/jscoverage
JSDOCDIR=/tmp/jsdoc_toolkit-2.3.2/jsdoc-toolkit
all: test
LIBJSFILES := $(wildcard lib/*.js lib/*/*.js lib/*/*/*.js)
TESTJSFILES := $(wildcard tests/*/*.js tests/*/*/*.js tests/*.js)
JSFILES := $(LIBJSFILES) $(TESTJSFILES)
test: nodetest rhinotest simplecompiled.js compilednodetest compiledrhinotest
#test: nodetest rhinotest compiled.js
all: test compiled.js doc instrumented
doc: $(LIBJSFILES)
java -jar $(JSDOCDIR)/jsrun.jar $(JSDOCDIR)/app/run.js -d=docs \
-t=$(JSDOCDIR)/templates/jsdoc $(LIBJSFILES)
instrumented: $(JSFILES)
$(JSCOVERAGE) . --exclude=extjs ../instrumented/
test: nodetest rhinotest compilednodetest compiledrhinotest
nodetest: $(JSFILES)
$(NODE) lib/runtime.js tests/tests.js
@@ -30,7 +52,7 @@ compiled.js: $(JSFILES) externs.js
java -jar $(COMPILERJAR) --define='IS_COMPILED_CODE=true' --warning_level VERBOSE --compilation_level ADVANCED_OPTIMIZATIONS --formatting PRETTY_PRINT --externs externs.js --use_only_custom_externs true $(foreach JSFILE,$(JSFILES), --js $(JSFILE)) > compiled.js
clean:
$(RM) compiled.js simplecompiled.js
$(RM) -rf compiled.js simplecompiled.js docs instrumented
# make sure targets are deleted if a build exits with a non-zero status code
.DELETE_ON_ERROR:
+16 -5
View File
@@ -1,5 +1,6 @@
/*global core*/
/**
* @class
* A cursor is a dom node that visually represents a cursor in a DOM tree.
* It should stay synchronized with the selection in the document. When
* there is only one collapsed selection range, a cursor should be shown at
@@ -18,9 +19,10 @@
*
* Even when the selection allows for a cursor, it might be desireable to hide
* the cursor by not letting it be part of the DOM.
**/
/**
*
* @constructor
* @param {Selection} selection The selection to which the cursor corresponds
* @param {Document} document The document in which the cursor is placed
*/
core.Cursor = function Cursor(selection, document) {
"use strict";
@@ -148,24 +150,33 @@ core.Cursor = function Cursor(selection, document) {
putCursorIntoContainer(container, offset);
}
}
/**
* Obtain the node representing the cursor.
* @return {Element}
*/
this.getNode = function () {
return cursorNode;
};
/**
* Synchronize the cursor with the current selection.
**/
* If there is a single collapsed selection range, the cursor will be placed
* there. If not, the cursor will be removed from the document tree.
* @return {undefined}
*/
this.updateToSelection = function () {
var range;
removeCursor();
runtime.log("HMM " + selection.rangeCount);
if (selection.rangeCount === 1) {
runtime.log("HMM ");
range = selection.getRangeAt(0);
if (range.collapsed) {
putCursor(range.startContainer, range.startOffset);
}
}
};
/**
* Remove the cursor from the document tree.
* @return {undefined}
*/
this.remove = function () {
removeCursor();
};
+5 -5
View File
@@ -3,7 +3,7 @@
/**
* @interface
*/
core.UnitTest = function () {};
core.UnitTest = function UnitTest() {};
/**
* @return {undefined}
*/
@@ -100,8 +100,8 @@ core.UnitTestRunner = function UnitTestRunner() {
}
}
/**
* @param {Object} t
* @param {string} a
* @param {Object} t context in which values to be tested are placed
* @param {string} a the value to be checked
* @return {undefined}
*/
function shouldBeNonNull(t, a) {
@@ -121,8 +121,8 @@ core.UnitTestRunner = function UnitTestRunner() {
}
}
/**
* @param {Object} t
* @param {string} a
* @param {Object} t context in which values to be tested are placed
* @param {string} a the value to be checked
* @return {undefined}
*/
function shouldBeNull(t, a) {
+6
View File
@@ -1,2 +1,8 @@
/**
* The core package.
*/
var core = {};
/**
* The gui package.
*/
var gui = {};