1 //<script type="text/javascript">
3 console = imports.console.console;
5 XObject = imports.XObject.XObject
8 /** Handle the creation of HTML links to documented symbols.
16 Link = XObject.define(
23 this.classLink = false;
27 Link.symbolsDir = Link.symbolsDir || '';
28 Link.base = Link.base || '';
29 Link.ext= Link.ext || '';
30 Link.srcDir= Link.srcDir || '';
46 toString : function() {
55 if (typeof(this.builtins[this.alias]) != 'undefined') {
56 this.text = this.alias;
57 return thisLink._makeExternLink(this.builtins[this.alias]);
61 return thisLink._makeSymbolLink(this.alias);
65 linkString = this.alias.replace(/(^|[^a-z$0-9_#.:-])([|a-z$0-9_#.:-]+)($|[^a-z$0-9_#.:-])/i,
66 function(match, prematch, symbolName, postmatch) {
67 var symbolNames = symbolName.split("|");
69 for (var i = 0, l = symbolNames.length; i < l; i++) {
70 thisLink.alias = symbolNames[i];
71 links.push(thisLink._makeSymbolLink(symbolNames[i]));
73 return prematch+links.join("|")+postmatch;
78 else if (this.extern) {
79 linkString = thisLink._makeExternLink(this.extern);
82 linkString = thisLink._makeSrcLink(this.src);
85 linkString = thisLink._makeFileLink(this.file);
92 'Object' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Object',
93 //'Object...' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object',
94 'Array' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array',
95 'Function' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Function',
96 'String' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/String',
97 'Number' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Number',
98 'Boolean' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Boolean',
99 'HTMLElement' : 'http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037'
103 toGnome: function(alias)
106 var pr = alias.split('.');
108 var site = 'library.gnome.org';
112 this.extern = 'http://live.gnome.org/GObjectIntrospection';
118 aa = pr.length > 1 ? 'G' + pr[1] : pr[0];
121 aa = pr.length > 1 ? 'Gdk' + pr[1] : pr[0];
124 aa = pr.length > 1 ? pr[0] + pr[1] : 'GtkSourceView';
128 aa = pr.length > 1 ? pr[0] + pr[1] : 'GStreamer';
134 case 'GstController':
140 case 'GstInterfaces':
151 aa = pr.length > 1 ? 'Gst' + pr[1] : pr[0];
155 aa = pr.length > 1 ? pr[1] : pr[0];
158 site = 'webkitgtk.org';
162 aa = alias.replace('.', '');
168 this.extern = 'http://www.google.com/search?hl=en&' +
169 'q=site%3A' + site + '+' + aa + extra +
170 '&btnI=I%27m+Feeling+Lucky&meta=&aq=f&oq=';
177 target : function(targetName) {
178 if (typeof(targetName) != 'undefined') this.targetName = targetName;
181 inner : function(inner) {
182 if (typeof(inner) != 'undefined') this.innerName = inner;
185 withText: function(text) {
186 if (typeof(text) != 'undefined') this.text = text;
189 toSrc :function(filename) {
190 if (typeof(filename) != 'undefined') this.src = filename;
194 toSymbolLong : function(alias)
196 this.show_full = true;
197 return this.toSymbol(alias)
199 toSymbol : function(alias) {
203 case 'boolean' : this.alias = 'Boolean'; return this;
204 case 'int' : this.alias = 'Number'; return this;
205 case 'uint' : this.alias = 'Number'; return this;
207 case 'long' : this.alias = 'Number'; return this;
208 case 'ulong' : this.alias = 'Number'; return this;
211 case 'uint8' : this.alias = 'Number'; return this;
212 case 'int8' : this.alias = 'Number'; return this;
214 case 'uint16' : this.alias = 'Number'; return this;
215 case 'uint16' : this.alias = 'Number'; return this;
217 case 'int32' : this.alias = 'Number'; return this;
218 case 'uint32' : this.alias = 'Number'; return this;
220 case 'uint64' : this.alias = 'Number'; return this;
221 case 'int64' : this.alias = 'Number'; return this;
224 case 'GType' : this.alias = 'Number'; return this;
225 case 'size' : this.alias = 'Number'; return this;
226 case 'ssize' : this.alias = 'Number'; return this;
228 case 'float' : this.alias = 'Number'; return this;
229 case 'double' : this.alias = 'Number'; return this;
230 case 'time_t' : this.alias = 'Number'; return this;
231 // fixme - should find out more details..
232 case 'array' : this.alias = 'Array'; return this;
233 case 'gslist' : this.alias = 'Array'; return this;
234 case 'glist' : this.alias = 'Array'; return this; // homefully.
235 case 'ghash' : this.alias = 'Object'; return this; // homefully.
238 case 'error' : this.alias = 'Object'; return this; // homefully.
239 case 'filename' : this.alias = 'String'; return this; // hopefully..
240 case 'utf8' : this.alias = 'String'; return this;
242 case 'void' : this.none = true; return this;
248 if (typeof(alias) != 'undefined') {
249 this.alias = new String(alias);
253 toClass : function(alias) {
254 this.classLink = true;
255 return this.toSymbol(alias);
257 toFile : function(file) {
258 if (typeof(file) != 'undefined') this.file = file;
265 /** prefixed for hashes */
268 /** Appended to the front of relative link paths. */
271 symbolNameToLinkName : function(symbol) {
273 if (symbol.isStatic) linker = ".";
274 else if (symbol.isInner) linker = "-";
276 return linker+symbol.name;
282 /** Create a link to a snother symbol. */
283 _makeSymbolLink : function(alias)
286 var txt = this.show_full ? alias : alias.split('.').pop();
287 return "<a href=\"./"+alias+".html\""+target+">"+txt+"</a>";
290 // look for '/' in alias..
291 if (/\//.test(alias)) {
292 var bits = alias.split('/');
294 for(var i=0; i < bits.length; i++) {
298 ret += this._makeSymbolLink(bits[i]);
307 var linkBase = Link.base + Link.symbolsDir;
308 //var linkTo = Link.symbolSet.getSymbol(alias);
311 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
313 // is it an internal link?
314 if (alias.charAt(0) == "#") {
316 fullLinkPath = alias;
318 // if there is no symbol by that name just return the name unaltered
319 } else if (!linkTo) {
321 if (typeof(this.builtins[alias]) != 'undefined') {
322 return "<a href=\""+ this.builtins[alias]+"\""+target+">"+alias+"</a>";
325 return this.text || alias;
328 // it's a symbol in another file
331 if (!linkTo.isConstructor && !linkTo.isNamespace) { // it's a method or property
332 linkPath = escape(linkTo.memberOf) || "_global_";
333 linkPath += Link.ext + "#" + this.symbolNameToLinkName(linkTo);
336 linkPath = escape(linkTo.alias);
337 linkPath += Link.ext + (this.classLink? "":"#" + "constructor");
339 //linkPath = linkBase + linkPath;
340 fullLinkPath = linkBase + linkPath;
343 var linkText = this.text || alias;
345 var link = {linkPath: linkPath, linkText: linkText, fullLinkPath: fullLinkPath};
347 //if (typeof PluginManager != "undefined") {
348 // JSDOC.PluginManager.run("onSymbolLink", link);
351 return "<a href=\""+link.fullLinkPath+"\""+target+">"+link.linkText+"</a>";
355 /** Create a link to a source file. */
356 _makeSrcLink : function(srcFilePath) {
357 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
359 // transform filepath into a filename
360 var srcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, "."); // was _
361 var lsrcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, ".");
362 var outFilePath = Link.base + Link.srcDir + srcFile.replace(/.js$/, '') + Link.ext;
364 if (!this.text) this.text = FilePath.fileName(srcFilePath);
365 return "<a href=\""+outFilePath+"\""+target+">"+this.text+"</a>";
368 /** Create a link to a source file. */
369 _makeFileLink : function(filePath) {
370 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
372 var outFilePath = Link.base + filePath;
374 if (!this.text) this.text = filePath;
375 return "<a href=\""+outFilePath+"\""+target+">"+this.text+"</a>";
378 /** Create a link to a source file. */
379 _makeExternLink : function(filePath) {
380 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
382 if (!this.text) this.text = filePath;
383 return "<a href=\""+filePath+"\""+target+">"+this.text+"</a>";