X-Git-Url: http://git.roojs.org/?p=gnome.introspection-doc-generator;a=blobdiff_plain;f=JSDOC%2FDocTag.js;h=e5449ab1f2e77a56b988fc1ae6f06de6f219f841;hp=0a6dbee817de4788d0c411e5151e9e6a9063a2a8;hb=f97b7efe182b819e8f6143b7aeb9fd45c7ab75f0;hpb=8fc705fb88d6a6c169a054bb7a25e3deacdfbe54 diff --git a/JSDOC/DocTag.js b/JSDOC/DocTag.js index 0a6dbee..e5449ab 100644 --- a/JSDOC/DocTag.js +++ b/JSDOC/DocTag.js @@ -13,6 +13,12 @@ Options = imports.Options.Options; DocTag = XObject.define( + +/** + * @constructor + * @arg {String} src + */ + function(src) { this.title = ""; this.type = ""; @@ -62,7 +68,7 @@ DocTag = XObject.define( } } catch(e) { - if (Options.LOG) Options.warn(e); + if (Options.LOG) Options.LOG.warn(e); else throw e; } this.desc = src; // whatever is left @@ -111,7 +117,7 @@ DocTag = XObject.define( 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; } @@ -137,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; } @@ -163,7 +169,30 @@ 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]; +} + + + }); // cached support?