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: [], options: [] };
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 == 'option' ) {
29 var args = v.split(/\s+/);
30 v = args.slice( 2, args.length );
31 v = { type: args[0], name: args[1], desc: v.join(' ') };
33 } else if ( n == 'example' ) {
36 } else if ( n == 'test' ) {
40 if ( n == 'desc' || n == 'before' || n == 'after' || n == 'result' ) {
41 ret.examples[ ret.examples.length - 1 ][ n ] = v;
44 if ( ret[ n ].constructor == Array ) {
47 ret[ n ] = [ ret[ n ], v ];
55 ret.desc = block.replace(/\s*!!!$/,"")
56 .replace(/</g, "<")
57 .replace(/>/g, ">");
58 //.replace(/\n\n/g, "<br/><br/>")
59 //.replace(/\n/g, " ");
61 var m = /^((.|\n)*?(\.|$))/.exec( ret.desc );
62 if ( m ) ret['short'] = m[1];
64 if ( ret.name ) c.push( ret );
70 function categorize( json ) {
71 var obj = { cat: [], method: [] };
73 for ( var i = 0; i < json.length; i++ ) {
74 if ( !json[i].cat ) json[i].cat = "";
76 var cat = json[i].cat.split("/");
79 for ( var j = 0; j < cat.length; j++ ) {
83 // Locate current category
84 for ( var n = 0; n < pos.cat.length; n++ )
85 if ( pos.cat[n].value == c )
88 // Create current category
90 curCat = { value: c, cat: [], method: [] };
91 pos.cat.push( curCat )
94 // If we're at the end, add the method
95 if ( j == cat.length - 1 )
96 curCat.method.push( json[i] );
98 // Otherwise, traverse deeper