Revision: 3855
Author: [email protected]
Date: Thu Nov 19 09:46:29 2009
Log: fix handling of NaN in Jsdoc and make Jsdoc usable publically.
http://code.google.com/p/google-caja/source/detail?r=3855
Modified:
/trunk/src/com/google/caja/ancillary/jsdoc/HtmlRenderer.java
/trunk/src/com/google/caja/ancillary/jsdoc/Jsdoc.java
/trunk/src/com/google/caja/ancillary/jsdoc/jsdoc.js
=======================================
--- /trunk/src/com/google/caja/ancillary/jsdoc/HtmlRenderer.java Fri Oct 23
12:20:15 2009
+++ /trunk/src/com/google/caja/ancillary/jsdoc/HtmlRenderer.java Thu Nov 19
09:46:29 2009
@@ -47,8 +47,8 @@
*
* @author [email protected]
*/
-class HtmlRenderer {
- static void buildHtml(
+public class HtmlRenderer {
+ public static void buildHtml(
String json, FileSystem fs, File htmlDir,
Iterable<CharProducer> sources, MessageContext mc)
throws IOException, JsdocException {
@@ -186,7 +186,7 @@
private void buildSourceFile(
String relUri, String rootDirPath, CharProducer src, Writer out)
throws IOException {
- String sourceCode = String.valueOf(src.getBuffer(), 0, src.getLimit());
+ String sourceCode = src.toString();
int startLineNo = src.filePositionForOffsets(0, 0).startLineNo();
String extension = fileExtension(relUri);
String lang = "";
=======================================
--- /trunk/src/com/google/caja/ancillary/jsdoc/Jsdoc.java Fri Oct 23
12:20:15 2009
+++ /trunk/src/com/google/caja/ancillary/jsdoc/Jsdoc.java Thu Nov 19
09:46:29 2009
@@ -62,17 +62,21 @@
private final List<Pair<String, String>> initFiles
= new ArrayList<Pair<String, String>>();
+ public Jsdoc(MessageContext mc, MessageQueue mq) {
+ this(new AnnotationHandlers(mc), mc, mq);
+ }
+
Jsdoc(AnnotationHandlers handlers, MessageContext mc, MessageQueue mq) {
this.mc = mc;
this.mq = mq;
this.handlers = handlers;
}
- void addInitFile(String path, String content) {
+ public void addInitFile(String path, String content) {
this.initFiles.add(Pair.pair(path, content));
}
- void addSource(ParseTreeNode source) { this.sources.add(source); }
- void addPackage(InputSource pkg, Comment docs) {
+ public void addSource(ParseTreeNode source) { this.sources.add(source); }
+ public void addPackage(InputSource pkg, Comment docs) {
packageDocs.add(Pair.pair(pkg, docs));
}
@@ -80,7 +84,7 @@
* Produces documentation JSON from the {...@link #addSource sources} and
* {...@link #addPackage packages} added prior.
*/
- ObjectConstructor extract() throws JsdocException {
+ public ObjectConstructor extract() throws JsdocException {
Executor.Input[] rewritten = sourceCodeWithDocHooks();
try {
Map<String, Object> bindings = new LinkedHashMap<String, Object>();
@@ -106,7 +110,8 @@
}
}
/**
- * Allows jsdoc running code to issue messages and such.
+ * Allows "jsdoc.js" to report errors, etc..
+ * Public to allow for reflection.
*/
public final class JsdocPowerBoxSandBoxSafe {
public void addMessage(
=======================================
--- /trunk/src/com/google/caja/ancillary/jsdoc/jsdoc.js Fri Oct 23 12:20:15
2009
+++ /trunk/src/com/google/caja/ancillary/jsdoc/jsdoc.js Thu Nov 19 09:46:29
2009
@@ -17,9 +17,8 @@
* defines the operators added by the rewriter.
*
* @author [email protected]
+ * @namespace
*/
-
-/** @namespace */
var jsdoc___ = (function () {
var hasOwnProperty = ({}).hasOwnProperty;
var lookupGetter = ({}).__lookupGetter__;
@@ -390,7 +389,11 @@
* @return null if skipped.
*/
function subtractIntersection(a, b) {
- if ('object' !== typeof a) { return a !== b ? a : null; }
+ if ('object' !== typeof a) {
+ if (a === b) { return null; }
+ if (a !== a && b !== b) { return null; } // Treat NaN as equal to
itself
+ return a;
+ }
if ('object' !== typeof b) { return a; }
if (a === null || b === null) { return a; }
var diff = a instanceof Array ? [] : {};