1 //<script type="text/javascript">
2 JSDOC = imports['JSDOC.js'].JSDOC;
4 console = imports['console.js'].console;
6 imports['Object.js'].load(Object);
8 Template = imports['JSDOC/Template.js'];
10 /** Handle the creation of HTML links to documented symbols.
13 * // JSDOC.Template.Link.base = "";
14 * JSDOC.Template.Link.symbolsDir
25 this.classLink = false;
28 Link.symbolsDir = Link.symbolsDir || '';
29 Link.base = Link.base || '';
30 Link.ext= Link.ext || '';
31 Link.srcDir= Link.srcDir || '';
38 Object.extend(Link.prototype, {
50 toString : function() {
59 if (typeof(this.builtins[this.alias]) != 'undefined') {
60 this.text = this.alias;
61 return thisLink._makeExternLink(this.builtins[this.alias]);
65 return thisLink._makeSymbolLink(this.alias);
69 linkString = this.alias.replace(/(^|[^a-z$0-9_#.:-])([|a-z$0-9_#.:-]+)($|[^a-z$0-9_#.:-])/i,
70 function(match, prematch, symbolName, postmatch) {
71 var symbolNames = symbolName.split("|");
73 for (var i = 0, l = symbolNames.length; i < l; i++) {
74 thisLink.alias = symbolNames[i];
75 links.push(thisLink._makeSymbolLink(symbolNames[i]));
77 return prematch+links.join("|")+postmatch;
82 else if (this.extern) {
83 linkString = thisLink._makeExternLink(this.extern);
86 linkString = thisLink._makeSrcLink(this.src);
89 linkString = thisLink._makeFileLink(this.file);
96 'Object' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Object',
97 //'Object...' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object',
98 'Array' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array',
99 'Function' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Function',
100 'String' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/String',
101 'Number' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Number',
102 'Boolean' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Boolean',
103 'HTMLElement' : 'http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037'
107 toGnome: function(alias)
110 var pr = alias.split('.');
112 var site = 'library.gnome.org';
116 this.extern = 'http://live.gnome.org/GObjectIntrospection';
122 aa = pr.length > 1 ? 'G' + pr[1] : pr[0];
125 aa = pr.length > 1 ? 'Gdk' + pr[1] : pr[0];
128 aa = pr.length > 1 ? pr[0] + pr[1] : 'GtkSourceView';
132 aa = pr.length > 1 ? pr[0] + pr[1] : 'GStreamer';
138 case 'GstController':
144 case 'GstInterfaces':
155 aa = pr.length > 1 ? 'Gst' + pr[1] : pr[0];
159 aa = pr.length > 1 ? pr[1] : pr[0];
162 site = 'webkitgtk.org';
166 aa = alias.replace('.', '');
172 this.extern = 'http://www.google.com/search?hl=en&' +
173 'q=site%3A' + site + '+' + aa + extra +
174 '&btnI=I%27m+Feeling+Lucky&meta=&aq=f&oq=';
181 target : function(targetName) {
182 if (typeof(targetName) != 'undefined') this.targetName = targetName;
185 inner : function(inner) {
186 if (typeof(inner) != 'undefined') this.innerName = inner;
189 withText: function(text) {
190 if (typeof(text) != 'undefined') this.text = text;
193 toSrc :function(filename) {
194 if (typeof(filename) != 'undefined') this.src = filename;
198 toSymbolLong : function(alias)
200 this.show_full = true;
201 return this.toSymbol(alias)
203 toSymbol : function(alias) {
207 case 'boolean' : this.alias = 'Boolean'; return this;
208 case 'int' : this.alias = 'Number'; return this;
209 case 'uint' : this.alias = 'Number'; return this;
211 case 'long' : this.alias = 'Number'; return this;
212 case 'ulong' : this.alias = 'Number'; return this;
215 case 'uint8' : this.alias = 'Number'; return this;
216 case 'int8' : this.alias = 'Number'; return this;
218 case 'uint16' : this.alias = 'Number'; return this;
219 case 'uint16' : this.alias = 'Number'; return this;
221 case 'int32' : this.alias = 'Number'; return this;
222 case 'uint32' : this.alias = 'Number'; return this;
224 case 'uint64' : this.alias = 'Number'; return this;
225 case 'int64' : this.alias = 'Number'; return this;
228 case 'GType' : this.alias = 'Number'; return this;
229 case 'size' : this.alias = 'Number'; return this;
230 case 'ssize' : this.alias = 'Number'; return this;
232 case 'float' : this.alias = 'Number'; return this;
233 case 'double' : this.alias = 'Number'; return this;
234 case 'time_t' : this.alias = 'Number'; return this;
235 // fixme - should find out more details..
236 case 'array' : this.alias = 'Array'; return this;
237 case 'gslist' : this.alias = 'Array'; return this;
238 case 'glist' : this.alias = 'Array'; return this; // homefully.
239 case 'ghash' : this.alias = 'Object'; return this; // homefully.
242 case 'error' : this.alias = 'Object'; return this; // homefully.
243 case 'filename' : this.alias = 'String'; return this; // hopefully..
244 case 'utf8' : this.alias = 'String'; return this;
246 case 'void' : this.none = true; return this;
252 if (typeof(alias) != 'undefined') {
253 this.alias = new String(alias);
257 toClass : function(alias) {
258 this.classLink = true;
259 return this.toSymbol(alias);
261 toFile : function(file) {
262 if (typeof(file) != 'undefined') this.file = file;
269 /** prefixed for hashes */
272 /** Appended to the front of relative link paths. */
275 symbolNameToLinkName : function(symbol) {
277 if (symbol.isStatic) linker = ".";
278 else if (symbol.isInner) linker = "-";
280 return linker+symbol.name;
286 /** Create a link to a snother symbol. */
287 _makeSymbolLink : function(alias)
290 var txt = this.show_full ? alias : alias.split('.').pop();
291 return "<a href=\"./"+alias+".html\""+target+">"+txt+"</a>";
294 // look for '/' in alias..
295 if (/\//.test(alias)) {
296 var bits = alias.split('/');
298 for(var i=0; i < bits.length; i++) {
302 ret += this._makeSymbolLink(bits[i]);
311 var linkBase = Link.base + Link.symbolsDir;
312 //var linkTo = Link.symbolSet.getSymbol(alias);
315 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
317 // is it an internal link?
318 if (alias.charAt(0) == "#") {
320 fullLinkPath = alias;
322 // if there is no symbol by that name just return the name unaltered
323 } else if (!linkTo) {
325 if (typeof(this.builtins[alias]) != 'undefined') {
326 return "<a href=\""+ this.builtins[alias]+"\""+target+">"+alias+"</a>";
329 return this.text || alias;
332 // it's a symbol in another file
335 if (!linkTo.isConstructor && !linkTo.isNamespace) { // it's a method or property
336 linkPath = escape(linkTo.memberOf) || "_global_";
337 linkPath += Link.ext + "#" + this.symbolNameToLinkName(linkTo);
340 linkPath = escape(linkTo.alias);
341 linkPath += Link.ext + (this.classLink? "":"#" + "constructor");
343 //linkPath = linkBase + linkPath;
344 fullLinkPath = linkBase + linkPath;
347 var linkText = this.text || alias;
349 var link = {linkPath: linkPath, linkText: linkText, fullLinkPath: fullLinkPath};
351 if (typeof PluginManager != "undefined") {
352 JSDOC.PluginManager.run("onSymbolLink", link);
355 return "<a href=\""+link.fullLinkPath+"\""+target+">"+link.linkText+"</a>";
359 /** Create a link to a source file. */
360 _makeSrcLink : function(srcFilePath) {
361 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
363 // transform filepath into a filename
364 var srcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, "."); // was _
365 var lsrcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, ".");
366 var outFilePath = Link.base + Link.srcDir + srcFile.replace(/.js$/, '') + Link.ext;
368 if (!this.text) this.text = FilePath.fileName(srcFilePath);
369 return "<a href=\""+outFilePath+"\""+target+">"+this.text+"</a>";
372 /** Create a link to a source file. */
373 _makeFileLink : function(filePath) {
374 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
376 var outFilePath = Link.base + filePath;
378 if (!this.text) this.text = filePath;
379 return "<a href=\""+outFilePath+"\""+target+">"+this.text+"</a>";
382 /** Create a link to a source file. */
383 _makeExternLink : function(filePath) {
384 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
386 if (!this.text) this.text = filePath;
387 return "<a href=\""+filePath+"\""+target+">"+this.text+"</a>";