1 //<script type="text/javascript">
4 XObject = imports.XObject.XObject;
6 Options = imports.BuildDocs.Options;
10 * DocTag - represents a single A=b tag.
15 DocTag = XObject.define(
20 this.isOptional = false;
21 this.defaultValue = "";
23 if (typeof src != "undefined") {
36 /* qdump needed for cahcing?
39 return JSDOC.toQDump(t, 'JSDOC.DocTag.fromDump({', '})', new JSDOC.DocTag());
45 Populate the properties of this from the given tag src.
48 parse : function(src) {
49 if (typeof src != "string") throw "src must be a string not "+(typeof src);
52 src = this.nibbleTitle(src);
53 //if (JSDOC.PluginManager) {
54 // JSDOC.PluginManager.run("onDocTagSynonym", this);
57 src = this.nibbleType(src);
59 // only some tags are allowed to have names.
60 if (this.title == "param" || this.title == "property" || this.title == "cfg") { // @config is deprecated
61 src = this.nibbleName(src);
65 if (Options.LOG) Options.warn(e);
68 this.desc = src; // whatever is left
70 // example tags need to have whitespace preserved
71 if (this.title != "example") this.desc = this.desc.trim();
73 //if (JSDOC.PluginManager) {
74 // JSDOC.PluginManager.run("onDocTag", this);
79 Automatically called when this is stringified.
81 toString : function() {
87 Find and shift off the title of a tag.
91 nibbleTitle : function(src) {
92 if (typeof src != "string") throw "src must be a string not "+(typeof src);
94 var parts = src.match(/^\s*(\S+)(?:\s([\s\S]*))?$/);
96 if (parts && parts[1]) this.title = parts[1];
97 if (parts && parts[2]) src = parts[2];
104 Find and shift off the type of a tag.
105 @requires frame/String.js
109 nibbleType : function(src)
111 if (typeof src != "string") throw "src must be a string not "+(typeof src);
113 if (src.match(/^\s*\{/)) {
114 var typeRange = src.balance("{", "}");
115 if (typeRange[1] == -1) {
116 throw "Malformed comment tag ignored. Tag type requires an opening { and a closing }: "+src;
118 this.type = src.substring(typeRange[0]+1, typeRange[1]).trim();
119 this.type = this.type.replace(/\s*,\s*/g, "|"); // multiples can be separated by , or |
120 src = src.substring(typeRange[1]+1);
128 Find and shift off the name of a tag.
129 @requires frame/String.js
133 nibbleName : function(src) {
134 if (typeof src != "string") throw "src must be a string not "+(typeof src);
139 if (src.charAt(0) == "[") {
140 var nameRange = src.balance("[", "]");
141 if (nameRange[1] == -1) {
142 throw "Malformed comment tag ignored. Tag optional name requires an opening [ and a closing ]: "+src;
144 this.name = src.substring(nameRange[0]+1, nameRange[1]).trim();
145 this.isOptional = true;
147 src = src.substring(nameRange[1]+1);
149 // has default value?
150 var nameAndValue = this.name.split("=");
151 if (nameAndValue.length) {
152 this.name = nameAndValue.shift().trim();
153 this.defaultValue = nameAndValue.join("=");
157 var parts = src.match(/^(\S+)(?:\s([\s\S]*))?$/);
159 if (parts[1]) this.name = parts[1];
160 if (parts[2]) src = parts[2].trim();
170 DocTag.fromDump = function(t)
172 var ns = new DocTag();
174 if (typeof(ns[i]) == "undefined") {
175 println("ERR:no default for DocTag:"+ i);