3 load("js/writeFile.js");
6 jQuery: "A jQuery object.",
7 Object: "A simple Javascript object. For example, it could be a String or a Number.",
8 String: "A string of characters.",
9 Number: "A numeric valid.",
10 Element: "The Javascript object representation of a DOM Element.",
11 Hash: "A Javascript object that contains key/value pairs in the form of properties and values.",
12 "Array<Element>": "An Array of DOM Elements.",
13 "Array<String>": "An Array of strings.",
14 Function: "A reference to a Javascript function."
17 var f = readFile(arguments[0]);
20 var blockMatch = /\/\*\*\s*((.|\n)*?)\s*\*\//g;
21 var paramMatch = /\@(\S+) *((.|\n)*?)(?=\n\@|!!!)/m;
23 while ( bm = blockMatch.exec(f) ) {
24 block = bm[1].replace(/^\s*\* ?/mg,"") + "!!!";
25 var ret = { params: [], examples: [] };
27 while ( m = paramMatch.exec( block ) ) {
28 block = block.replace( paramMatch, "" );
34 .replace(/&/g, "&")
35 .replace(/</g, "<")
36 .replace(/>/g, ">")
37 .replace(/\n/g, "<br/>")
38 /*.replace(/(\s\s+)/g, function(a){
40 for ( var i = 0; i < a.length; i++ )
45 if ( n == 'param' || n == 'any' ) {
46 var args = v.split(/\s+/);
47 v = args.slice( 2, args.length );
48 v = { type: args[0], name: args[1], desc: v.join(' ') };
49 if ( n == 'any' ) v.any = 1;
51 } else if ( n == 'example' ) {
56 if ( n == 'desc' || n == 'before' || n == 'after' || n == 'result' ) {
57 ret.examples[ ret.examples.length - 1 ][ n ] = v;
60 if ( ret[ n ].constructor == Array ) {
63 ret[ n ] = [ ret[ n ], v ];
71 ret.desc = block.replace(/\s*!!!$/,"")
72 .replace(/</g, "<")
73 .replace(/>/g, ">");
74 //.replace(/\n\n/g, "<br/><br/>")
75 //.replace(/\n/g, " ");
77 var m = /^((.|\n)*?(\.|$))/.exec( ret.desc );
78 if ( m ) ret['short'] = m[1];
80 if ( ret.name ) c.push( ret );
83 var json = Object.toJSON( c );
85 writeFile( arguments[1] + "/data/jquery-docs-json.js", json );
86 writeFile( arguments[1] + "/data/jquery-docs-jsonp.js", "docsLoaded(" + json + ")" );
88 Object.toXML.force = { desc: 1, code: 1, before: 1, result: 1 };
90 var xml = Object.toXML( { method: c }, "docs" );
92 writeFile( arguments[1] + "/data/jquery-docs-xml.xml",
93 "<?xml version='1.0' encoding='ISO-8859-1'?>\n" + xml );
95 writeFile( arguments[1] + "/index.xml",
96 "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
97 "<?xml-stylesheet type='text/xsl' href='style/docs.xsl'?>\n" + xml