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;
26 Link.symbolsDir = Link.symbolsDir || '';
27 Link.base = Link.base || '';
28 Link.ext= Link.ext || '';
29 Link.srcDir= Link.srcDir || '';
45 toString : function() {
54 if (typeof(this.builtins[this.alias]) != 'undefined') {
55 this.text = this.alias;
56 return thisLink._makeExternLink(this.builtins[this.alias]);
60 return thisLink._makeSymbolLink(this.alias);
64 linkString = this.alias.replace(/(^|[^a-z$0-9_#.:-])([|a-z$0-9_#.:-]+)($|[^a-z$0-9_#.:-])/i,
65 function(match, prematch, symbolName, postmatch) {
66 var symbolNames = symbolName.split("|");
68 for (var i = 0, l = symbolNames.length; i < l; i++) {
69 thisLink.alias = symbolNames[i];
70 links.push(thisLink._makeSymbolLink(symbolNames[i]));
72 return prematch+links.join("|")+postmatch;
77 else if (this.extern) {
78 linkString = thisLink._makeExternLink(this.extern);
81 linkString = thisLink._makeSrcLink(this.src);
84 linkString = thisLink._makeFileLink(this.file);
91 'Object' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Object',
92 //'Object...' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object',
93 'Array' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array',
94 'Function' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Function',
95 'String' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/String',
96 'Number' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Number',
97 'Boolean' : 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Boolean',
98 'HTMLElement' : 'http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037'
102 toGnome: function(alias)
105 var pr = alias.split('.');
107 var site = 'library.gnome.org';
111 this.extern = 'http://live.gnome.org/GObjectIntrospection';
117 aa = pr.length > 1 ? 'G' + pr[1] : pr[0];
120 aa = pr.length > 1 ? 'Gdk' + pr[1] : pr[0];
123 aa = pr.length > 1 ? pr[0] + pr[1] : 'GtkSourceView';
127 aa = pr.length > 1 ? pr[0] + pr[1] : 'GStreamer';
133 case 'GstController':
139 case 'GstInterfaces':
150 aa = pr.length > 1 ? 'Gst' + pr[1] : pr[0];
154 aa = pr.length > 1 ? pr[1] : pr[0];
157 site = 'webkitgtk.org';
161 aa = alias.replace('.', '');
167 this.extern = 'http://www.google.com/search?hl=en&' +
168 'q=site%3A' + site + '+' + aa + extra +
169 '&btnI=I%27m+Feeling+Lucky&meta=&aq=f&oq=';
176 target : function(targetName) {
177 if (typeof(targetName) != 'undefined') this.targetName = targetName;
180 inner : function(inner) {
181 if (typeof(inner) != 'undefined') this.innerName = inner;
184 withText: function(text) {
185 if (typeof(text) != 'undefined') this.text = text;
188 toSrc :function(filename) {
189 if (typeof(filename) != 'undefined') this.src = filename;
193 toSymbolLong : function(alias)
195 this.show_full = true;
196 return this.toSymbol(alias)
198 toSymbol : function(alias) {
202 case 'boolean' : this.alias = 'Boolean'; return this;
203 case 'int' : this.alias = 'Number'; return this;
204 case 'uint' : this.alias = 'Number'; return this;
206 case 'long' : this.alias = 'Number'; return this;
207 case 'ulong' : this.alias = 'Number'; return this;
210 case 'uint8' : this.alias = 'Number'; return this;
211 case 'int8' : this.alias = 'Number'; return this;
213 case 'uint16' : this.alias = 'Number'; return this;
214 case 'uint16' : this.alias = 'Number'; return this;
216 case 'int32' : this.alias = 'Number'; return this;
217 case 'uint32' : this.alias = 'Number'; return this;
219 case 'uint64' : this.alias = 'Number'; return this;
220 case 'int64' : this.alias = 'Number'; return this;
223 case 'GType' : this.alias = 'Number'; return this;
224 case 'size' : this.alias = 'Number'; return this;
225 case 'ssize' : this.alias = 'Number'; return this;
227 case 'float' : this.alias = 'Number'; return this;
228 case 'double' : this.alias = 'Number'; return this;
229 case 'time_t' : this.alias = 'Number'; return this;
230 // fixme - should find out more details..
231 case 'array' : this.alias = 'Array'; return this;
232 case 'gslist' : this.alias = 'Array'; return this;
233 case 'glist' : this.alias = 'Array'; return this; // homefully.
234 case 'ghash' : this.alias = 'Object'; return this; // homefully.
237 case 'error' : this.alias = 'Object'; return this; // homefully.
238 case 'filename' : this.alias = 'String'; return this; // hopefully..
239 case 'utf8' : this.alias = 'String'; return this;
241 case 'void' : this.none = true; return this;
247 if (typeof(alias) != 'undefined') {
248 this.alias = new String(alias);
252 toClass : function(alias) {
253 this.classLink = true;
254 return this.toSymbol(alias);
256 toFile : function(file) {
257 if (typeof(file) != 'undefined') this.file = file;
264 /** prefixed for hashes */
267 /** Appended to the front of relative link paths. */
270 symbolNameToLinkName : function(symbol) {
272 if (symbol.isStatic) linker = ".";
273 else if (symbol.isInner) linker = "-";
275 return linker+symbol.name;
281 /** Create a link to a snother symbol. */
282 _makeSymbolLink : function(alias)
285 var txt = this.show_full ? alias : alias.split('.').pop();
286 return "<a href=\"./"+alias+".html\""+target+">"+txt+"</a>";
289 // look for '/' in alias..
290 if (/\//.test(alias)) {
291 var bits = alias.split('/');
293 for(var i=0; i < bits.length; i++) {
297 ret += this._makeSymbolLink(bits[i]);
306 var linkBase = Link.base + Link.symbolsDir;
307 //var linkTo = Link.symbolSet.getSymbol(alias);
310 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
312 // is it an internal link?
313 if (alias.charAt(0) == "#") {
315 fullLinkPath = alias;
317 // if there is no symbol by that name just return the name unaltered
318 } else if (!linkTo) {
320 if (typeof(this.builtins[alias]) != 'undefined') {
321 return "<a href=\""+ this.builtins[alias]+"\""+target+">"+alias+"</a>";
324 return this.text || alias;
327 // it's a symbol in another file
330 if (!linkTo.isConstructor && !linkTo.isNamespace) { // it's a method or property
331 linkPath = escape(linkTo.memberOf) || "_global_";
332 linkPath += Link.ext + "#" + this.symbolNameToLinkName(linkTo);
335 linkPath = escape(linkTo.alias);
336 linkPath += Link.ext + (this.classLink? "":"#" + "constructor");
338 //linkPath = linkBase + linkPath;
339 fullLinkPath = linkBase + linkPath;
342 var linkText = this.text || alias;
344 var link = {linkPath: linkPath, linkText: linkText, fullLinkPath: fullLinkPath};
346 //if (typeof PluginManager != "undefined") {
347 // JSDOC.PluginManager.run("onSymbolLink", link);
350 return "<a href=\""+link.fullLinkPath+"\""+target+">"+link.linkText+"</a>";
354 /** Create a link to a source file. */
355 _makeSrcLink : function(srcFilePath) {
356 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
358 // transform filepath into a filename
359 var srcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, "."); // was _
360 var lsrcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, ".");
361 var outFilePath = Link.base + Link.srcDir + srcFile.replace(/.js$/, '') + Link.ext;
363 if (!this.text) this.text = FilePath.fileName(srcFilePath);
364 return "<a href=\""+outFilePath+"\""+target+">"+this.text+"</a>";
367 /** Create a link to a source file. */
368 _makeFileLink : function(filePath) {
369 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
371 var outFilePath = Link.base + filePath;
373 if (!this.text) this.text = filePath;
374 return "<a href=\""+outFilePath+"\""+target+">"+this.text+"</a>";
377 /** Create a link to a source file. */
378 _makeExternLink : function(filePath) {
379 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
381 if (!this.text) this.text = filePath;
382 return "<a href=\""+filePath+"\""+target+">"+this.text+"</a>";