while ( bm = blockMatch.exec(f) ) {
block = bm[1].replace(/^\s*\* ?/mg,"") + "!!!";
- var ret = { params: [], examples: [], tests: [] };
+ var ret = { params: [], examples: [], tests: [], options: [] };
while ( m = paramMatch.exec( block ) ) {
block = block.replace( paramMatch, "" );
return ret;
})*/ || 1;
- if ( n == 'param' || n == 'any' ) {
+ if ( n == 'param' || n == 'option' ) {
var args = v.split(/\s+/);
v = args.slice( 2, args.length );
v = { type: args[0], name: args[1], desc: v.join(' ') };
- if ( n == 'any' ) v.any = 1;
- n = "params";
+ n = n + "s";
} else if ( n == 'example' ) {
v = { code: v };
n = "examples";
return c;
}
+
+function categorize( json ) {
+ var obj = { cat: [], method: [] };
+
+ for ( var i = 0; i < json.length; i++ ) {
+ if ( !json[i].cat ) json[i].cat = "";
+
+ var cat = json[i].cat.split("/");
+
+ var pos = obj;
+ for ( var j = 0; j < cat.length; j++ ) {
+ var c = cat[j];
+ var curCat = null;
+
+ // Locate current category
+ for ( var n = 0; n < pos.cat.length; n++ )
+ if ( pos.cat[n].value == c )
+ curCat = pos.cat[n];
+
+ // Create current category
+ if ( !curCat ) {
+ curCat = { value: c, cat: [], method: [] };
+ pos.cat.push( curCat )
+ }
+
+ // If we're at the end, add the method
+ if ( j == cat.length - 1 )
+ curCat.method.push( json[i] );
+
+ // Otherwise, traverse deeper
+ else
+ pos = curCat;
+ }
+ }
+
+ return obj;
+}