X-Git-Url: http://git.roojs.org/?p=gnome.introspection-doc-generator;a=blobdiff_plain;f=JSDOC%2FDocTag.js;h=e5449ab1f2e77a56b988fc1ae6f06de6f219f841;hp=092a9ee5c7bfce4dc4b2bb49bd51793a9f9fda15;hb=f97b7efe182b819e8f6143b7aeb9fd45c7ab75f0;hpb=7d00310a076975bf46a6c818dbe6e568b776c0f6 diff --git a/JSDOC/DocTag.js b/JSDOC/DocTag.js index 092a9ee..e5449ab 100644 --- a/JSDOC/DocTag.js +++ b/JSDOC/DocTag.js @@ -3,7 +3,9 @@ XObject = imports.XObject.XObject; -DocTag = imports.DocTag.DocTag; +Options = imports.Options.Options; + + /** * DocTag - represents a single A=b tag. * @class DocTag @@ -11,6 +13,12 @@ DocTag = imports.DocTag.DocTag; DocTag = XObject.define( + +/** + * @constructor + * @arg {String} src + */ + function(src) { this.title = ""; this.type = ""; @@ -31,12 +39,12 @@ DocTag = XObject.define( isOptional : false, defaultValue : '', desc : '', - + /* qdump needed for cahcing? toQDump :function(t) { return JSDOC.toQDump(t, 'JSDOC.DocTag.fromDump({', '})', new JSDOC.DocTag()); } , - + */ /** @@ -48,9 +56,9 @@ DocTag = XObject.define( try { src = this.nibbleTitle(src); - if (JSDOC.PluginManager) { - JSDOC.PluginManager.run("onDocTagSynonym", this); - } + //if (JSDOC.PluginManager) { + // JSDOC.PluginManager.run("onDocTagSynonym", this); + // } src = this.nibbleType(src); @@ -60,7 +68,7 @@ DocTag = XObject.define( } } catch(e) { - if (JSDOC.opt.LOG) JSDOC.opt.LOG.warn(e); + if (Options.LOG) Options.LOG.warn(e); else throw e; } this.desc = src; // whatever is left @@ -68,9 +76,9 @@ DocTag = XObject.define( // example tags need to have whitespace preserved if (this.title != "example") this.desc = this.desc.trim(); - if (JSDOC.PluginManager) { - JSDOC.PluginManager.run("onDocTag", this); - } + //if (JSDOC.PluginManager) { + // JSDOC.PluginManager.run("onDocTag", this); + //} }, /** @@ -104,11 +112,12 @@ DocTag = XObject.define( @param {string} src @return src */ - nibbleType : function(src) { + nibbleType : function(src) + { if (typeof src != "string") throw "src must be a string not "+(typeof src); if (src.match(/^\s*\{/)) { - var typeRange = src.balance("{", "}"); + var typeRange = this.balance(src,"{", "}"); if (typeRange[1] == -1) { throw "Malformed comment tag ignored. Tag type requires an opening { and a closing }: "+src; } @@ -134,7 +143,7 @@ DocTag = XObject.define( // is optional? if (src.charAt(0) == "[") { - var nameRange = src.balance("[", "]"); + var nameRange = this.balance(src,"[", "]"); if (nameRange[1] == -1) { throw "Malformed comment tag ignored. Tag optional name requires an opening [ and a closing ]: "+src; } @@ -160,13 +169,36 @@ DocTag = XObject.define( } return src; - } -}); + }, + + balance : function(str, open, close) { + var i = 0; + while (str.charAt(i) != open) { + if (i == str.length) return [-1, -1]; + i++; + } + + var j = i+1; + var balance = 1; + while (j < str.length) { + if (str.charAt(j) == open) balance++; + if (str.charAt(j) == close) balance--; + if (balance == 0) break; + j++; + if (j == str.length) return [-1, -1]; + } + + return [i, j]; +} + + +}); -JSDOC.DocTag.fromDump = function(t) +// cached support? +DocTag.fromDump = function(t) { - var ns = new JSDOC.DocTag(); + var ns = new DocTag(); for (var i in t) { if (typeof(ns[i]) == "undefined") { println("ERR:no default for DocTag:"+ i);