X-Git-Url: http://git.roojs.org/?p=gnome.introspection-doc-generator;a=blobdiff_plain;f=JsTemplate%2FLink.js;h=b404302b29580ae8251cf72fbc58bc2ca956a999;hp=9a3089d3c8c9e003bb84c32a4aa5e8aef10d3703;hb=307c8a2fa14821d13e4c6bd7bd47d0e3cfa45dd5;hpb=cb39a25fd9dcf2f6cd7953a805e1e90d70c5e32b;ds=sidebyside
diff --git a/JsTemplate/Link.js b/JsTemplate/Link.js
index 9a3089d..b404302 100644
--- a/JsTemplate/Link.js
+++ b/JsTemplate/Link.js
@@ -13,52 +13,80 @@ XObject = imports.XObject.XObject;
@constructor
*/
Link = XObject.define(
- function () {
- this.alias = "";
- this.src = "";
- this.file = "";
- this.text = "";
- this.innerName = "";
- this.classLink = false;
- this.targetName = "";
-
- this.target = function(targetName) {
+ /*
+ * constructor
+ */
+ function (opts) {
+ XObject.extend(this,opts);
+
+ },
+ Object,
+ {
+
+ /**
+ * url {String} url for link..
+ */
+ url: "",
+ /**
+ * text {String} text to show on link.
+ */
+
+ text : "",
+
+ /**
+ * alias {String} not sure?
+ */
+ alias : "",
+ /**
+ * src {String} not sure?
+ */
+ src : "",
+ file : "",
+
+ innerName : "",
+ classLink : false,
+ targetName : "",
+
+
+
+ target : function(targetName) {
if (typeof(targetName) != 'undefined') this.targetName = targetName;
return this;
- }
- this.inner = function(inner) {
+ },
+ inner : function(inner) {
if (typeof(inner) != 'undefined') this.innerName = inner;
return this;
- }
- this.withText = function(text) {
+ },
+ withText : function(text) {
if (typeof(text) != 'undefined') this.text = text;
return this;
- }
- this.toSrc = function(filename) {
+ },
+ toSrc : function(filename) {
if (typeof(filename) != 'undefined') this.src = filename;
+
return this;
- }
- this.toSymbol = function(alias) {
+ },
+ toSymbol : function(alias) {
if (typeof(alias) != 'undefined') {
this.alias = new String(alias);
}
return this;
- }
- this.toClass = function(alias) {
+ },
+ toClass : function(alias) {
this.classLink = true;
return this.toSymbol(alias);
- }
- this.toFile = function(file) {
+ },
+ toFile : function(file) {
if (typeof(file) != 'undefined') this.file = file;
return this;
- }
+ },
- this.toString = function() {
- var linkString;
+ toString : function() {
+
var thisLink = this;
if (this.alias) {
- linkString = this.alias.replace(/(^|[^a-z$0-9_#.:-])([|a-z$0-9_#.:-]+)($|[^a-z$0-9_#.:-])/i,
+ return this.alias.replace(/(^|[^a-z$0-9_#.:-])([|a-z$0-9_#.:-]+)($|[^a-z$0-9_#.:-])/i,
function(match, prematch, symbolName, postmatch) {
var symbolNames = symbolName.split("|");
var links = [];
@@ -70,22 +98,28 @@ Link = XObject.define(
}
);
}
- else if (this.src) {
- linkString = thisLink._makeSrcLink(this.src);
+ if (this.url) {
+ return thisLink._makeLink(this.url);
+ }
+ if (this.src) {
+ return thisLink._makeSrcLink(this.src);
}
- else if (this.file) {
- linkString = thisLink._makeFileLink(this.file);
+ if (this.file) {
+ return thisLink._makeFileLink(this.file);
}
- return linkString;
- }
- },
- Object,
- {
+ },
+
+
+
+
+
+
/** Create a link to a snother symbol. */
- _makeSymbolLink : function(alias) {
-
+ _makeSymbolLink : function(alias)
+ {
+ print(JSON.stringify(alias));
// look for '/' in alias..
if (/\//.test(alias)) {
var bits = alias.split('/');
@@ -102,8 +136,9 @@ Link = XObject.define(
- var linkBase = Link.base+JSDOC.publish.conf.symbolsDir;
+ var linkBase = './';
var linkTo = Link.symbolSet.getSymbol(alias);
+
var linkPath;
var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
@@ -127,11 +162,11 @@ Link = XObject.define(
if (!linkTo.is("CONSTRUCTOR") && !linkTo.isNamespace) { // it's a method or property
linkPath = escape(linkTo.memberOf) || "_global_";
- linkPath += JSDOC.publish.conf.ext + "#" + Link.symbolNameToLinkName(linkTo);
+ linkPath += imports.JSDOC.Options.Options.ext + "#" + Link.symbolNameToLinkName(linkTo);
}
else {
linkPath = escape(linkTo.alias);
- linkPath += JSDOC.publish.conf.ext + (this.classLink? "":"#" + Link.hashPrefix + "constructor");
+ linkPath += imports.JSDOC.Options.Options.ext + (this.classLink? "":"#" + Link.hashPrefix + "constructor");
}
//linkPath = linkBase + linkPath;
fullLinkPath = linkBase + linkPath;
@@ -141,9 +176,9 @@ Link = XObject.define(
var link = {linkPath: linkPath, linkText: linkText, fullLinkPath: fullLinkPath};
- if (typeof JSDOC.PluginManager != "undefined") {
- JSDOC.PluginManager.run("onSymbolLink", link);
- }
+ //if (typeof JSDOC.PluginManager != "undefined") {
+ // JSDOC.PluginManager.run("onSymbolLink", link);
+ //}
return ""+link.linkText+"";
},
@@ -156,9 +191,10 @@ Link = XObject.define(
// transform filepath into a filename
var srcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, "."); // was _
var lsrcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, ".");
- var outFilePath = Link.base + JSDOC.publish.conf.srcDir + srcFile.replace(/.js$/, '') + JSDOC.publish.conf.ext;
+ var outFilePath = Link.base + '/symbols/' + srcFile.replace(/.js$/, '') +
+ imports.JSDOC.Options.Options.publishExt;
- if (!this.text) this.text = FilePath.fileName(srcFilePath);
+ if (!this.text) this.text = srcFilePath; //FilePath.fileName(srcFilePath);
return ""+this.text+"";
},
@@ -170,7 +206,16 @@ Link = XObject.define(
if (!this.text) this.text = filePath;
return ""+this.text+"";
+ },
+
+ /** very basic link... */
+ _makeLink : function(url) {
+ var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
+
+ if (!this.text) this.text = url;
+ return ""+this.text+"";
}
+
});