1 //<script type="text/javascript">
3 console = imports['console.js'].console;
5 imports['Object.js'].load(Object);
7 Template = imports['JSDOC/Template.js'];
9 /** Handle the creation of HTML links to documented symbols.
12 * // JSDOC.Template.Link.base = "";
13 * JSDOC.Template.Link.symbolsDir
24 this.classLink = false;
27 Link.symbolsDir = Link.symbolsDir || '';
28 Link.base = Link.base || '';
29 Link.ext= Link.ext || '';
30 Link.srcDir= Link.srcDir || '';
37 Object.extend(Link.prototype, {
49 toString : function() {
58 if (typeof(this.builtins[this.alias]) != 'undefined') {
59 this.text = this.alias;
60 return thisLink._makeExternLink(this.builtins[this.alias]);
64 return thisLink._makeSymbolLink(this.alias);
68 linkString = this.alias.replace(/(^|[^a-z$0-9_#.:-])([|a-z$0-9_#.:-]+)($|[^a-z$0-9_#.:-])/i,
69 function(match, prematch, symbolName, postmatch) {
70 var symbolNames = symbolName.split("|");
72 for (var i = 0, l = symbolNames.length; i < l; i++) {
73 thisLink.alias = symbolNames[i];
74 links.push(thisLink._makeSymbolLink(symbolNames[i]));
76 return prematch+links.join("|")+postmatch;
81 else if (this.extern) {
82 linkString = thisLink._makeExternLink(this.extern);
85 linkString = thisLink._makeSrcLink(this.src);
88 linkString = thisLink._makeFileLink(this.file);
95 'Object' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Object',
96 //'Object...' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object',
97 'Array' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array',
98 'Function' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Function',
99 'String' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/String',
100 'Number' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Number',
101 'Boolean' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Boolean',
102 'HTMLElement' : 'http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037'
106 toGnome: function(alias)
109 var pr = alias.split('.');
111 var site = 'library.gnome.org';
115 this.extern = 'http://live.gnome.org/GObjectIntrospection';
121 aa = pr.length > 1 ? 'G' + pr[1] : pr[0];
124 aa = pr.length > 1 ? 'Gdk' + pr[1] : pr[0];
127 aa = pr.length > 1 ? pr[0] + pr[1] : 'GtkSourceView';
131 aa = pr.length > 1 ? pr[0] + pr[1] : 'GStreamer';
137 case 'GstController':
143 case 'GstInterfaces':
154 aa = pr.length > 1 ? 'Gst' + pr[1] : pr[0];
158 aa = pr.length > 1 ? pr[1] : pr[0];
161 site = 'webkitgtk.org';
165 aa = alias.replace('.', '');
171 this.extern = 'http://www.google.com/search?hl=en&' +
172 'q=site%3A' + site + '+' + aa + extra +
173 '&btnI=I%27m+Feeling+Lucky&meta=&aq=f&oq=';
180 target : function(targetName) {
181 if (typeof(targetName) != 'undefined') this.targetName = targetName;
184 inner : function(inner) {
185 if (typeof(inner) != 'undefined') this.innerName = inner;
188 withText: function(text) {
189 if (typeof(text) != 'undefined') this.text = text;
192 toSrc :function(filename) {
193 if (typeof(filename) != 'undefined') this.src = filename;
197 toSymbolLong : function(alias)
199 this.show_full = true;
200 return this.toSymbol(alias)
202 toSymbol : function(alias) {
206 case 'boolean' : this.alias = 'Boolean'; return this;
207 case 'int' : this.alias = 'Number'; return this;
208 case 'uint' : this.alias = 'Number'; return this;
210 case 'long' : this.alias = 'Number'; return this;
211 case 'ulong' : this.alias = 'Number'; return this;
214 case 'uint8' : this.alias = 'Number'; return this;
215 case 'int8' : this.alias = 'Number'; return this;
217 case 'uint16' : this.alias = 'Number'; return this;
218 case 'uint16' : this.alias = 'Number'; return this;
220 case 'int32' : this.alias = 'Number'; return this;
221 case 'uint32' : this.alias = 'Number'; return this;
223 case 'uint64' : this.alias = 'Number'; return this;
224 case 'int64' : this.alias = 'Number'; return this;
227 case 'GType' : this.alias = 'Number'; return this;
228 case 'size' : this.alias = 'Number'; return this;
229 case 'ssize' : this.alias = 'Number'; return this;
231 case 'float' : this.alias = 'Number'; return this;
232 case 'double' : this.alias = 'Number'; return this;
233 case 'time_t' : this.alias = 'Number'; return this;
234 // fixme - should find out more details..
235 case 'array' : this.alias = 'Array'; return this;
236 case 'gslist' : this.alias = 'Array'; return this;
237 case 'glist' : this.alias = 'Array'; return this; // homefully.
238 case 'ghash' : this.alias = 'Object'; return this; // homefully.
241 case 'error' : this.alias = 'Object'; return this; // homefully.
242 case 'filename' : this.alias = 'String'; return this; // hopefully..
243 case 'utf8' : this.alias = 'String'; return this;
245 case 'void' : this.none = true; return this;
251 if (typeof(alias) != 'undefined') {
252 this.alias = new String(alias);
256 toClass : function(alias) {
257 this.classLink = true;
258 return this.toSymbol(alias);
260 toFile : function(file) {
261 if (typeof(file) != 'undefined') this.file = file;
268 /** prefixed for hashes */
271 /** Appended to the front of relative link paths. */
274 symbolNameToLinkName : function(symbol) {
276 if (symbol.isStatic) linker = ".";
277 else if (symbol.isInner) linker = "-";
279 return linker+symbol.name;
285 /** Create a link to a snother symbol. */
286 _makeSymbolLink : function(alias)
289 var txt = this.show_full ? alias : alias.split('.').pop();
290 return "<a href=\"./"+alias+".html\""+target+">"+txt+"</a>";
293 // look for '/' in alias..
294 if (/\//.test(alias)) {
295 var bits = alias.split('/');
297 for(var i=0; i < bits.length; i++) {
301 ret += this._makeSymbolLink(bits[i]);
310 var linkBase = Link.base + Link.symbolsDir;
311 //var linkTo = Link.symbolSet.getSymbol(alias);
314 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
316 // is it an internal link?
317 if (alias.charAt(0) == "#") {
319 fullLinkPath = alias;
321 // if there is no symbol by that name just return the name unaltered
322 } else if (!linkTo) {
324 if (typeof(this.builtins[alias]) != 'undefined') {
325 return "<a href=\""+ this.builtins[alias]+"\""+target+">"+alias+"</a>";
328 return this.text || alias;
331 // it's a symbol in another file
334 if (!linkTo.isConstructor && !linkTo.isNamespace) { // it's a method or property
335 linkPath = escape(linkTo.memberOf) || "_global_";
336 linkPath += Link.ext + "#" + this.symbolNameToLinkName(linkTo);
339 linkPath = escape(linkTo.alias);
340 linkPath += Link.ext + (this.classLink? "":"#" + "constructor");
342 //linkPath = linkBase + linkPath;
343 fullLinkPath = linkBase + linkPath;
346 var linkText = this.text || alias;
348 var link = {linkPath: linkPath, linkText: linkText, fullLinkPath: fullLinkPath};
350 //if (typeof PluginManager != "undefined") {
351 // JSDOC.PluginManager.run("onSymbolLink", link);
354 return "<a href=\""+link.fullLinkPath+"\""+target+">"+link.linkText+"</a>";
358 /** Create a link to a source file. */
359 _makeSrcLink : function(srcFilePath) {
360 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
362 // transform filepath into a filename
363 var srcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, "."); // was _
364 var lsrcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, ".");
365 var outFilePath = Link.base + Link.srcDir + srcFile.replace(/.js$/, '') + Link.ext;
367 if (!this.text) this.text = FilePath.fileName(srcFilePath);
368 return "<a href=\""+outFilePath+"\""+target+">"+this.text+"</a>";
371 /** Create a link to a source file. */
372 _makeFileLink : function(filePath) {
373 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
375 var outFilePath = Link.base + filePath;
377 if (!this.text) this.text = filePath;
378 return "<a href=\""+outFilePath+"\""+target+">"+this.text+"</a>";
381 /** Create a link to a source file. */
382 _makeExternLink : function(filePath) {
383 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
385 if (!this.text) this.text = filePath;
386 return "<a href=\""+filePath+"\""+target+">"+this.text+"</a>";