A Tree object which contains symbols.

Constructor

Defined tree.js Source
function (){
   this.symbols = {global:[]};
       
}
            

_addSymbol Function Private


Defined tree.js

Adds a symbol to this tree.

Arguments Returns Source
function (name){
   var ret = this.symbols[name];
   if (!ret) {
       ret = this.symbols[name] = [];
   }
   return ret;
       
}
    

addSymbol Function Public


Defined tree.js

Entry point to add the symbol

Arguments Source
function (symbol){
   var nameParts = utils.splitName(symbol.fullName);
   var path = nameParts.memberof, name = nameParts.name;
   if (path === "global") {
       path = name;
   }
   var sym = this.getSymbol(path);
   sym.push(symbol);
       
}
    

getClasses Function Public


Defined tree.js

Returns all classes in the tree. The following properties are added to each class symbol.

Returns Source
function (){
   var symbols = this.symbols,
       objects = [],
       keys = Object.keys(this.symbols);
   keys.forEach(function (k) {
       objects = objects.concat(symbols[k].filter(function (s) {
           return s.isConstructor;
       }));
   });
   return objects.map(function (s) {
       var name = s.fullName;
       var statics = symbols[name] || [];
       var instance = symbols[name + ".prototype"] || [];
       var borrowedMethods = [], borrowedProperties = [], staticBorrowedMethods = [], staticBorrowedProperties = [];
       s.borrows.map(function (b) {
           var borrows = b.borrows;
           var symbol = symbols[borrows.memberof || "global"].filter(function (s) {
               return s.name === borrows.name;
           });
           if (symbol.length) {
               symbol = symbol[0];
               var memberof = b.isStatic ? name : name + ".prototype";
               var newSymb = new Symbol(utils.merge({}, symbol, {name:b.as, isStatic:b.isStatic, fullName:memberof + "." + b.as, memberof:memberof}));
               if (b.isStatic) {
                   if (s.isFunction) {
                       staticBorrowedMethods.push(newSymb);
                   } else {
                       staticBorrowedProperties.push(newSymb);
                   }
               } else {
                   if (s.isFunction) {
                       borrowedMethods.push(newSymb);
                   } else {
                       borrowedProperties.push(newSymb);
                   }
               }
           }
       });
       s.name = name;
       s.staticMethods = statics.filter(
           function (s) {
               return s.isFunction && !s.isConstructor;
           }).concat(staticBorrowedMethods);
       s.staticProperties = statics.filter(
           function (s) {
               return !s.isFunction && !s.isNamespace;
           }).concat(staticBorrowedProperties);
       s.instanceMethods = instance.filter(
           function (s) {
               return s.isFunction && !s.isConstructor;
           }).concat(borrowedMethods);
       s.instanceProperties = instance.filter(
           function (s) {
               return !s.isFunction && !s.isNamespace;
           }).concat(s.properties || []).concat(borrowedProperties);
       return s;
   });
       
}
    

getMembers Function Public


Defined tree.js

Gets all members( coddoc.Symbol) for a particular path.

Arguments Returns Source
function (path){
   var symbols = this.symbols,
       namespaces = [],
       keys = Object.keys(this.symbols);
   keys.forEach(function (k) {
       namespaces = namespaces.concat(symbols[k].filter(function (s) {
           return !s.isNamespace && !s.isConstructor && s.memberof === path;
       }));
   });
   return namespaces;
       
}
    

getNamespaces Function Public


Defined tree.js

Returns all namespaces in this tree. This method also adds the following values to the namespace.

Returns Source
function (){
   var symbols = this.symbols,
       namespaces = [],
       keys = Object.keys(this.symbols);
   keys.forEach(function (k) {
       namespaces = namespaces.concat(symbols[k].filter(function (s) {
           return s.isNamespace;
       }));
   });
   return namespaces.map(function (s) {
       var realName = s.memberof && s.memberof !== "global" ? [s.memberof, s.name].join(".") : s.name;
       var members = this.getMembers(realName);
       s.name = realName;
       s.properties = s.properties.concat(members.filter(function (m) {
           return !m.isFunction;
       }));
       s.methods = members.filter(function (m) {
           return m.isFunction;
       });
       return s;
   }, this);
       
}
    

getSymbol Function Public


Defined tree.js

Returns a symbol from this tree. The Tree will create the symbol if it does not exist.

Arguments Returns Source
function (name){
   return this._addSymbol(name);
       
}
    

hasSymbol Function Public


Defined tree.js

Returns true if this tree contains a symbol.

Arguments Returns Source
function (name){
   var parts = name.split(".");
   return !!this.symbols[name];
       
}
    

License

MIT LICENSE

Meta


Code: git clone git://github.com/pollenware/coddoc.git