3 var blockMatch = /\/\*\*\s*((.|\n)*?)\s*\*\//g;
4 var paramMatch = /\@(\S+) *((.|\n)*?)(?=\n\@|!!!)/m;
6 while ( bm = blockMatch.exec(f) ) {
7 block = bm[1].replace(/^\s*\* ?/mg,"") + "!!!";
8 var ret = { params: [], examples: [], tests: [] };
10 while ( m = paramMatch.exec( block ) ) {
11 block = block.replace( paramMatch, "" );
17 .replace(/&/g, "&")
18 .replace(/</g, "<")
19 .replace(/>/g, ">")
20 //.replace(/\n/g, "<br/>")
21 /*.replace(/(\s\s+)/g, function(a){
23 for ( var i = 0; i < a.length; i++ )
28 if ( n == 'param' || n == 'any' ) {
29 var args = v.split(/\s+/);
30 v = args.slice( 2, args.length );
31 v = { type: args[0], name: args[1], desc: v.join(' ') };
32 if ( n == 'any' ) v.any = 1;
34 } else if ( n == 'example' ) {
37 } else if ( n == 'test' ) {
41 if ( n == 'desc' || n == 'before' || n == 'after' || n == 'result' ) {
42 ret.examples[ ret.examples.length - 1 ][ n ] = v;
45 if ( ret[ n ].constructor == Array ) {
48 ret[ n ] = [ ret[ n ], v ];
56 ret.desc = block.replace(/\s*!!!$/,"")
57 .replace(/</g, "<")
58 .replace(/>/g, ">");
59 //.replace(/\n\n/g, "<br/><br/>")
60 //.replace(/\n/g, " ");
62 var m = /^((.|\n)*?(\.|$))/.exec( ret.desc );
63 if ( m ) ret['short'] = m[1];
65 if ( ret.name ) c.push( ret );
71 function categorize( json ) {
72 var obj = { cat: [], method: [] };
74 for ( var i = 0; i < json.length; i++ ) {
75 if ( !json[i].cat ) json[i].cat = "";
77 var cat = json[i].cat.split("/");
80 for ( var j = 0; j < cat.length; j++ ) {
84 // Locate current category
85 for ( var n = 0; n < pos.cat.length; n++ )
86 if ( pos.cat[n].value == c )
89 // Create current category
91 curCat = { value: c, cat: [], method: [] };
92 pos.cat.push( curCat )
95 // If we're at the end, add the method
96 if ( j == cat.length - 1 )
97 curCat.method.push( json[i] );
99 // Otherwise, traverse deeper