1 //<script type="text/javascript">
2 JSDOC = imports['JSDOC.js'].JSDOC;
3 Roo = imports['Roo.js'].Roo;
4 console = imports['console.js'].console;
6 Template = imports['JSDOC/Template.js'];
8 /** Handle the creation of HTML links to documented symbols.
11 * // JSDOC.Template.Link.base = "";
12 * JSDOC.Template.Link.symbolsDir
23 this.classLink = false;
26 Link.symbolsDir = Link.symbolsDir || '';
27 Link.base = Link.base || '';
28 Link.ext= Link.ext || '';
29 Link.srcDir= Link.srcDir || '';
36 Roo.apply(Link.prototype, {
48 toString : function() {
57 if (typeof(this.builtins[this.alias]) != 'undefined') {
58 this.text = this.alias;
59 return thisLink._makeExternLink(this.builtins[this.alias]);
63 return thisLink._makeSymbolLink(this.alias);
67 linkString = this.alias.replace(/(^|[^a-z$0-9_#.:-])([|a-z$0-9_#.:-]+)($|[^a-z$0-9_#.:-])/i,
68 function(match, prematch, symbolName, postmatch) {
69 var symbolNames = symbolName.split("|");
71 for (var i = 0, l = symbolNames.length; i < l; i++) {
72 thisLink.alias = symbolNames[i];
73 links.push(thisLink._makeSymbolLink(symbolNames[i]));
75 return prematch+links.join("|")+postmatch;
80 else if (this.extern) {
81 linkString = thisLink._makeExternLink(this.extern);
84 linkString = thisLink._makeSrcLink(this.src);
87 linkString = thisLink._makeFileLink(this.file);
94 'Object' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Object',
95 //'Object...' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object',
96 'Array' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array',
97 'Function' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Function',
98 'String' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/String',
99 'Number' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Number',
100 'Boolean' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Boolean',
101 'HTMLElement' : 'http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037'
105 toGnome: function(alias)
108 var pr = alias.split('.');
110 var site = 'library.gnome.org';
114 this.extern = 'http://live.gnome.org/GObjectIntrospection';
120 aa = pr.length > 1 ? 'G' + pr[1] : pr[0];
123 aa = pr.length > 1 ? 'Gdk' + pr[1] : pr[0];
126 aa = pr.length > 1 ? pr[0] + pr[1] : 'GtkSourceView';
130 aa = pr.length > 1 ? pr[0] + pr[1] : 'GStreamer';
136 case 'GstController':
142 case 'GstInterfaces':
153 aa = pr.length > 1 ? 'Gst' + pr[1] : pr[0];
157 aa = pr.length > 1 ? pr[1] : pr[0];
160 site = 'webkitgtk.org';
164 aa = alias.replace('.', '');
170 this.extern = 'http://www.google.com/search?hl=en&' +
171 'q=site%3A' + site + '+' + aa + extra +
172 '&btnI=I%27m+Feeling+Lucky&meta=&aq=f&oq=';
179 target : function(targetName) {
180 if (typeof(targetName) != 'undefined') this.targetName = targetName;
183 inner : function(inner) {
184 if (typeof(inner) != 'undefined') this.innerName = inner;
187 withText: function(text) {
188 if (typeof(text) != 'undefined') this.text = text;
191 toSrc :function(filename) {
192 if (typeof(filename) != 'undefined') this.src = filename;
196 toSymbolLong : function(alias)
198 this.show_full = true;
199 return this.toSymbol(alias)
201 toSymbol : function(alias) {
205 case 'boolean' : this.alias = 'Boolean'; return this;
206 case 'int' : this.alias = 'Number'; return this;
207 case 'uint' : this.alias = 'Number'; return this;
209 case 'long' : this.alias = 'Number'; return this;
210 case 'ulong' : this.alias = 'Number'; return this;
213 case 'uint8' : this.alias = 'Number'; return this;
214 case 'int8' : this.alias = 'Number'; return this;
216 case 'uint16' : this.alias = 'Number'; return this;
217 case 'uint16' : this.alias = 'Number'; return this;
219 case 'int32' : this.alias = 'Number'; return this;
220 case 'uint32' : this.alias = 'Number'; return this;
222 case 'uint64' : this.alias = 'Number'; return this;
223 case 'int64' : this.alias = 'Number'; return this;
226 case 'GType' : this.alias = 'Number'; return this;
227 case 'size' : this.alias = 'Number'; return this;
228 case 'ssize' : this.alias = 'Number'; return this;
230 case 'float' : this.alias = 'Number'; return this;
231 case 'double' : this.alias = 'Number'; return this;
232 case 'time_t' : this.alias = 'Number'; return this;
233 // fixme - should find out more details..
234 case 'array' : this.alias = 'Array'; return this;
235 case 'gslist' : this.alias = 'Array'; return this;
236 case 'glist' : this.alias = 'Array'; return this; // homefully.
237 case 'ghash' : this.alias = 'Object'; return this; // homefully.
240 case 'error' : this.alias = 'Object'; return this; // homefully.
241 case 'filename' : this.alias = 'String'; return this; // hopefully..
242 case 'utf8' : this.alias = 'String'; return this;
244 case 'void' : this.none = true; return this;
250 if (typeof(alias) != 'undefined') {
251 this.alias = new String(alias);
255 toClass : function(alias) {
256 this.classLink = true;
257 return this.toSymbol(alias);
259 toFile : function(file) {
260 if (typeof(file) != 'undefined') this.file = file;
267 /** prefixed for hashes */
270 /** Appended to the front of relative link paths. */
273 symbolNameToLinkName : function(symbol) {
275 if (symbol.isStatic) linker = ".";
276 else if (symbol.isInner) linker = "-";
278 return linker+symbol.name;
284 /** Create a link to a snother symbol. */
285 _makeSymbolLink : function(alias)
288 var txt = this.show_full ? alias : alias.split('.').pop();
289 return "<a href=\"./"+alias+".shtml\""+target+" roo:cls=\""+alias+"\">"+txt+"</a>";
292 // look for '/' in alias..
293 if (/\//.test(alias)) {
294 var bits = alias.split('/');
296 for(var i=0; i < bits.length; i++) {
300 ret += this._makeSymbolLink(bits[i]);
309 var linkBase = Link.base + Link.symbolsDir;
310 //var linkTo = Link.symbolSet.getSymbol(alias);
313 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
315 // is it an internal link?
316 if (alias.charAt(0) == "#") {
318 fullLinkPath = alias;
320 // if there is no symbol by that name just return the name unaltered
321 } else if (!linkTo) {
323 if (typeof(this.builtins[alias]) != 'undefined') {
324 return "<a href=\""+ this.builtins[alias]+"\""+target+">"+alias+"</a>";
327 return this.text || alias;
330 // it's a symbol in another file
333 if (!linkTo.isConstructor && !linkTo.isNamespace) { // it's a method or property
334 linkPath = escape(linkTo.memberOf) || "_global_";
335 linkPath += Link.ext + "#" + this.symbolNameToLinkName(linkTo);
338 linkPath = escape(linkTo.alias);
339 linkPath += Link.ext + (this.classLink? "":"#" + "constructor");
341 //linkPath = linkBase + linkPath;
342 fullLinkPath = linkBase + linkPath;
345 var linkText = this.text || alias;
347 var link = {linkPath: linkPath, linkText: linkText, fullLinkPath: fullLinkPath};
349 if (typeof PluginManager != "undefined") {
350 JSDOC.PluginManager.run("onSymbolLink", link);
353 return "<a href=\""+link.fullLinkPath+"\""+target+" roo:cls=\""+link.linkPath+"\">"+link.linkText+"</a>";
357 /** Create a link to a source file. */
358 _makeSrcLink : function(srcFilePath) {
359 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
361 // transform filepath into a filename
362 var srcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, "."); // was _
363 var lsrcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, ".");
364 var outFilePath = Link.base + Link.srcDir + srcFile.replace(/.js$/, '') + Link.ext;
366 if (!this.text) this.text = FilePath.fileName(srcFilePath);
367 return "<a href=\""+outFilePath+"\""+target+" roo:cls=\"src/"+lsrcFile+"\">"+this.text+"</a>";
370 /** Create a link to a source file. */
371 _makeFileLink : function(filePath) {
372 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
374 var outFilePath = Link.base + filePath;
376 if (!this.text) this.text = filePath;
377 return "<a href=\""+outFilePath+"\""+target+">"+this.text+"</a>";
380 /** Create a link to a source file. */
381 _makeExternLink : function(filePath) {
382 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
384 if (!this.text) this.text = filePath;
385 return "<a href=\""+filePath+"\""+target+">"+this.text+"</a>";