- symbol.ignoreNamespace = this.ignoreNamespace;
+ //symbol.ignoreNamespace = this.ignoreNamespace;
var ns = File.dirname(symbol.srcFile).replace(/\//g,'.');
if (symbol.alias.substring(0, ns.length) == ns) {
// this stuff works...
- var name = this.srcFileFlatName(sourceFile);
+ var name = this.srcFileFlatName(this.srcFileRelName(sourceFile)) ;
this.LOG.inform("Write Source file : " + this.target+"/symbols/src/" + name + " FROM: " + sourceFile);
/**
* DocTag - represents a single A=b tag.
* @class DocTag
- * @namespace JSDOC
*/
// only some tags are allowed to have names.
if (this.title == "param" ||
this.title == "property" ||
- this.title == "cfg" ||
- this.title == "namespace") {
+ this.title == "cfg") {
// @config is deprecated
src = this.nibbleName(src);
// <script type="text/javascript">
-/**
- * @namespace JSDOC.PrettyPrint
- */
+
TokenReader = imports.TokenReader.TokenReader;
ScopeParser= imports.ScopeParser.ScopeParser;
Collapse = imports.Collapse.Collapse;
TextStream = imports.TextStream.TextStream;
-
+/**
+ * @namespace
+ * @scope PrettyPrint
+ * @function
+ * escape HTML, very basically
+ */
function escapeHTML(str) {
return str.replace(/&/g,'&').
replace(/>/g,'>').
replace(/</g,'<').
replace(/"/g,'"');
};
-
+/**
+ * @scope PrettyPrint
+ * @function
+ * make a pretty HTML file out of a JS file, using the tokenizer.
+ */
function toPretty(str)
{
* @namespace JSDOC
* The point of this class is to iterate through the Collapsed tree
* and add the property 'scopedName' to the tokens.
- *
- *
- * First task is to work out how to handle the recusive nature of the tree.
- * - tokenstream has tok() tokNext() etc...
*
- * parsing basically should work like this..
- * -- walk the tree, with each iteration
- * -- increment the scope name ('|' seperated..)
- * -- pass any args that might be irrelivant to the next layer..
- * -----
- *
- * Currently bugs out as our statements are parsed on different scopes...
- *
- *
- * -- next step register doc comments..
- *
- * Standard doc-comment - should be attached to the NAME token..
- * --- let's start there...
- *
- *
+ * @param {Array} tokens array of tokens (from collapse)
+ * @param {String} srcFile the original file
+ * @param {String} pscope Parent scope for all tokens (default $global$)
+ * @param {Array} args Local variables which do not need to be added to scope.
*/
ScopeNamer = XObject.define(
}
var r = ret.join(isStatic ? '.' : '#');
+ if (r.split('#').length > 1 ) {
+ return false;
+ }
+
print("ADD:" + scope + ' => ' + r);
//print("CANON:" + r);
},
+ pscope : '$global$',
+ /**
+ * When parser comes across a change in scope,
+ * it get's added to the current scope name here
+ *
+ *
+ *
+ *
+ *
+ * @param {String} n the name
+ */
+ addScopeName: function (n)
+ {
+ var ar = this.pscope.split('|');
+ if (ar[0] == '$global$') {
+ ar.shift();
+ }
+ ar.push(n);
+ this.pscope = ar.join('|');
+ return this.pscope;
+
+
+ },
+
/**
* same as symbol ctr...
*/
if (token.comment) {
token.jsdoc = new imports.DocComment.DocComment(token.comment);
- if (!token.depth && token.jsdoc.getTag('ignore').length) {
+ // ignore can ingore a whole stream of statements..
+ if (token.jsdoc.getTag('ignore').length) {
this.ignore = true;
return;
}
// allows @scope to force scope change.
if (token.jsdoc.getTag('scope').length) {
- pscope = this.pscope = token.jsdoc.getTag('scope')[0].desc;
+ pscope = this.addScopeName(token.jsdoc.getTag('scope')[0].desc);
}
}
//print("check =");
if (this.lookTok(1).data == '=') {
- print("GOT =");
+ //print("GOT =");
if (this.lookTok(2).data.match(/^imports\./)) {
if (token.data.indexOf('.') < 0) {
skip.push(token.data);
- this.pscope = this.bscope + '|' + token.data;
+ this.pscope = this.bscope
+ this.addScopeName( token.data );
print("new pscope?" + this.pscope);
token.scopeName = this.canonize(this.pscope);
continue;
}
if (this.lookTok(-1).name == 'FUNCTION') {
- this.pscope = this.bscope + '|' + token.data;
+ this.pscope = this.bscope
+ this.addScopeName( token.data );
+
token.scopeName = this.canonize(this.pscope);;
//print(this.pscope);
continue;
(this.lookTok(-2).name == 'FUNCTION') ||
(this.lookTok(-3).name == 'FUNCTION')
)) {
- pscope +='|FUNCTION(';
+ //pscope +='|FUNCTION(';
}
if (token.items) {
}
// allows @scope to force scope change.
if (t.key.jsdoc.getTag('scope').length) {
- pscope = this.pscope = t.key.jsdoc.getTag('scope')[0].desc;
+ this.pscope = this.addScopeName( t.key.jsdoc.getTag('scope')[0].desc );
+ }
+ if (t.key.jsdoc.getTag('ignore').length) {
+ break;
}
}
token.args = [];
}
+ // argument list...
if (token.items) {
// a function call?? could be a apply or extend...
//
- pscope += '|'+ (addargs ? 'FUNCTION' : '') + token.data;
+ // pscope += '|'+ (addargs ? 'FUNCTION' : '') + token.data;
+
token.items.forEach(function(tar) {
if (addargs && tar[0].data != ')') {
});
}
+
+ // ctors..
+ // ( function() { .... } , )
+
+ if ( token.data == '(' &&
+ (this.lookTok(-1).name == 'FUNCTION') &&
+ this.lookTok(-1).comment.length &&
+ (this.cursor == 2) ) {
+ token.jsdoc = new imports.DocComment.DocComment(this.lookTok(-1).comment);
+ var symbol = new Symbol( this.pscope, token.args || [] , "FUNCTION",
+ token.jsdoc || false);
+ symbol._token = token;
+ ScopeNamer.addSymbol(symbol, token.jsdoc);
+
+ }
+
+
+
+
+
+
+
if (addargs) {
//print(JSON.stringify(args));
}
}
// list in function call or argument..
+ // function is the first argument
+
+
// each argument shold not inherit sope like this does...
isConstant : false,
isIgnored : false,
isInner : false,
- isNamespace : false, // depreciated.
+ isNamespace : false,
isPrivate : false,
isStatic : false,
memberOf : "",
// @namespace
var namespaces = this.comment.getTag("namespace");
if (namespaces.length) {
- this.namespace = namespaces[0].name;
// scope for this file...
- Symbol.namespace = namespaces[0].name + '.';
- //this.classDesc = namespaces[0].desc+"\n"+this.desc; // desc can't apply to the constructor as there is none.
- //this.isNamespace = true;
+ this.classDesc = namespaces[0].desc+"\n"+this.desc; // desc can't apply to the constructor as there is none.
+ this.isNamespace = true;
}
/*~t
this._name = this.name
this.alias = this.name;
- //if (this.isa == "CONSTRUCTOR") {
- // this.isNamespace = true;
- //}
+ if (this.isa == "CONSTRUCTOR") {
+ this.isNamespace = true;
+ }
}
// @static
if (this.comment.getTag("singleton").length) {
this.isStatic = true;
- //if (this.isa == "CONSTRUCTOR") {
- // this.isNamespace = true;
- //}
+ if (this.isa == "CONSTRUCTOR") {
+ this.isNamespace = true;
+ }
}
//Parser = imports.Parser.Parser;
//Symbol = imports.Symbol.Symbol;
-
+/**
+ * @class ScopeSet
+ * The point of this class is to store and manage all the symbols
+ *
+ */
SymbolSet = XObject.define(
- function(opts) {
+
+ function() {
this.init();
},
Object,
{
-
+ /**
+ * @type {Object}
+ * Key:value map of alias=>sybmol.
+ */
_index : false,
SymbolSet.isBuiltin = function(name) {
return (SymbolSet.isBuiltin.coreObjects.indexOf(name) > -1);
}
+// private
SymbolSet.isBuiltin.coreObjects = [
+
// '_global_',
'Array', 'Boolean', 'Date', 'Function',
'Math', 'Number', 'Object', 'RegExp', 'String'
this.outData = false; // used by packer/scopeparser
this.identifier = false; // used by scope
this.id = Token.id++;
+ this.comment = '',
+ this.jsdoc = false
},
Object,
{
file preview is using full path?
-
-
-
-
-
+
+--------------------------------------------------
+
+Scope namer issue still:
+ - basically it's trying to guess the scope name.
+ - it's doing a so-so job of it..
+ ** It's not pretty though...
+
+ Classic example:
+ Date.monthNames = {
+ Jan : ....
+ }
+
+This could be an object.. so it get's put in the tree as available to document.
+ We could solve this in a number of ways
+ a) a tag on the code to indicate that it's not to be documented..
+ b) ?? how else ?? - we can not determine it simply..
dirname => [ array of classes..]
*/
+
+
var dircls = { '' : [] };
+
data.forEach(function(cls) {
+ output += cls.alias + "\n";
+ if (!cls.is("CONSTRUCTOR") && !cls.is("OBJECT")) {
+ return;
+ }
var dir = imports.File.File.dirname(cls.srcFile).replace(/\//,'.');
- if (dir == cls.alias.substring(0,dir.length)) {
- // add it to the top level..
+
+ var cdir = cls.alias.substring(0,dir.length);
+ if (dir != cdir || cls.alias == cdir) {
dircls[''].push(cls);
return;
}
dirs.shift();
dirs.push('');
}
-
- !}
-
-
+ dirs.forEach(function(dir) {
- <for each="dir" in="dirs">
-
+ if (dir.length) {
- {!
-
- if (dir.length) {
-
- !}<li>
- <div roo:isc="no" roo:isns="yes">{+dir+}</div>
- </li>{!
-
- }
- var classes = dircls[dir].sort(makeSortby('name'));
-
- classes.forEach(function(cls) {
- !}
- <li>
- <div roo:isc="yes" roo:isns="no">{+
- (dir.length ? (dir + '.') : '') + cls.alias +}</div>
- </li>
- {!
- });
-
+ !}<li>
+ <div roo:isc="yes" roo:isns="yes">{+dir+}</div>
+ </li>{!
+
+ }
+ var classes = dircls[dir].sort(makeSortby('name'));
+
+ classes.forEach(function(cls) {
+
+ !}<li>
+ <div roo:isc="yes" roo:isns="no">{+
+ (dir.length ? (dir + '.') : '') +
+ cls.alias.substring(dir.length ? dir.length + 1 : 0)
+ +}</div>
+ </li> {!
+ });
+ });
!}
-
- </for>
+
</ul>
</div>