diff options
author | John Resig <jeresig@gmail.com> | 2006-08-14 01:46:05 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2006-08-14 01:46:05 +0000 |
commit | 7448c61ee2199f6f7002e33e533cebc42b000c89 (patch) | |
tree | 71e0d08a590cf2ce29cc49057b7f4a76037f62c2 /build/docs | |
parent | 61aab47bcf4c35d021a88d95b7a17643d1342596 (diff) | |
download | jquery-7448c61ee2199f6f7002e33e533cebc42b000c89.tar.gz jquery-7448c61ee2199f6f7002e33e533cebc42b000c89.zip |
Massive overhauls to the test suite - it is now generated dynamically, along with the documentation.
Diffstat (limited to 'build/docs')
-rw-r--r-- | build/docs/docs.js | 81 | ||||
-rw-r--r-- | build/docs/js/doc.js | 5 | ||||
-rw-r--r-- | build/docs/style/docs.xsl | 10 | ||||
-rw-r--r-- | build/docs/style/style.css | 12 |
4 files changed, 24 insertions, 84 deletions
diff --git a/build/docs/docs.js b/build/docs/docs.js index 8186f9ddd..6e77b9435 100644 --- a/build/docs/docs.js +++ b/build/docs/docs.js @@ -1,83 +1,6 @@ -load("build/js/json.js", "build/js/xml.js", "build/js/writeFile.js"); - -var types = { - jQuery: "A jQuery object.", - Object: "A simple Javascript object. For example, it could be a String or a Number.", - String: "A string of characters.", - Number: "A numeric valid.", - Element: "The Javascript object representation of a DOM Element.", - Hash: "A Javascript object that contains key/value pairs in the form of properties and values.", - "Array<Element>": "An Array of DOM Elements.", - "Array<String>": "An Array of strings.", - Function: "A reference to a Javascript function." -}; - -var f = readFile(arguments[0]); - -var c = [], bm, m; -var blockMatch = /\/\*\*\s*((.|\n)*?)\s*\*\//g; -var paramMatch = /\@(\S+) *((.|\n)*?)(?=\n\@|!!!)/m; - -while ( bm = blockMatch.exec(f) ) { - block = bm[1].replace(/^\s*\* ?/mg,"") + "!!!"; - var ret = { params: [], examples: [] }; - - while ( m = paramMatch.exec( block ) ) { - block = block.replace( paramMatch, "" ); - - var n = m[1]; - var v = m[2] - .replace(/\s*$/g,"") - .replace(/^\s*/g,"") - .replace(/&/g, "&") - .replace(/</g, "<") - .replace(/>/g, ">") - .replace(/\n/g, "<br/>") - /*.replace(/(\s\s+)/g, function(a){ - var ret = ""; - for ( var i = 0; i < a.length; i++ ) - ret += " "; - return ret; - })*/ || 1; - - if ( n == 'param' || n == 'any' ) { - 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"; - } else if ( n == 'example' ) { - v = { code: v }; - n = "examples"; - } - - if ( n == 'desc' || n == 'before' || n == 'after' || n == 'result' ) { - ret.examples[ ret.examples.length - 1 ][ n ] = v; - } else { - if ( ret[ n ] ) { - if ( ret[ n ].constructor == Array ) { - ret[ n ].push( v ); - } else { - ret[ n ] = [ ret[ n ], v ]; - } - } else { - ret[ n ] = v; - } - } - } - - ret.desc = block.replace(/\s*!!!$/,"") - .replace(/</g, "<") - .replace(/>/g, ">"); - //.replace(/\n\n/g, "<br/><br/>") - //.replace(/\n/g, " "); - - var m = /^((.|\n)*?(\.|$))/.exec( ret.desc ); - if ( m ) ret['short'] = m[1]; - - if ( ret.name ) c.push( ret ); -} +load("build/js/json.js", "build/js/xml.js", "build/js/writeFile.js", "build/js/parse.js"); +var c = parse( readFile(arguments[0]) ); var json = Object.toJSON( c ); writeFile( arguments[1] + "/data/jquery-docs-json.js", json ); diff --git a/build/docs/js/doc.js b/build/docs/js/doc.js index 8bd25b1c3..e2260d77b 100644 --- a/build/docs/js/doc.js +++ b/build/docs/js/doc.js @@ -11,7 +11,10 @@ var types = { }; $(document).ready(function(){ - $("span.tooltip").ToolTipDemo('#fff'); + $("span.tooltip").each(function(){ + if ( types[ this.innerHTML ] ) + this.title = types[ this.innerHTML ]; + }).ToolTipDemo('#fff'); $("a.name").click(function(){ $("div.more,div.short",this.parentNode.parentNode).toggle().find("div.desc",function(){ diff --git a/build/docs/style/docs.xsl b/build/docs/style/docs.xsl index 4adac376f..354b5c0a7 100644 --- a/build/docs/style/docs.xsl +++ b/build/docs/style/docs.xsl @@ -6,7 +6,7 @@ <head> <title>jQuery Docs - API</title> <link rel="stylesheet" href="style/style.css"/> - <script src="../dist/jquery-svn.js"></script> + <script src="../dist/jquery.js"></script> <script src="js/tooltip.js"></script> <script src="js/pager.js"></script> <script src="js/doc.js"></script> @@ -18,13 +18,13 @@ <xsl:sort select="@name"/> <xsl:sort select="count(params)"/> <li> - <span class='type'><span title='TYPE' class='tooltip'><xsl:value-of select="@type"/></span></span> + <span class='type'><span class='tooltip'><xsl:value-of select="@type"/></span></span> <span class='fn'> <a href='#{@name}' class='name' title=''><xsl:value-of select="@name"/></a> <xsl:if test="not(@property)">( <xsl:for-each select="params"> - <span class='arg-type tooltip' title='TYPE'><xsl:value-of select="@type"/></span><xsl:text> </xsl:text> - <span class='arg-name tooltip' title='{@desc}'><xsl:value-of select="@name"/></span> + <span class='arg-type tooltip'><xsl:value-of select="@type"/></span><xsl:text> </xsl:text> + <span class='arg-name tooltip' title='{desc}'><xsl:value-of select="@name"/></span> <xsl:if test="position() != last()"> <xsl:if test="@any"> or </xsl:if> <xsl:if test="not(@any)">, </xsl:if> @@ -60,6 +60,8 @@ </li> </xsl:for-each> </ul> + + <p class="raw"><b>Raw Data:</b><xsl:text> </xsl:text><a href="data/jquery-docs-json.js">JSON</a>, <a href="data/jquery-docs-jsonp.js">JSONP</a>, <a href="data/jquery-docs-xml.xml">XML</a></p> </body> </html> </xsl:template> diff --git a/build/docs/style/style.css b/build/docs/style/style.css index 783d942b1..7c5554ece 100644 --- a/build/docs/style/style.css +++ b/build/docs/style/style.css @@ -126,3 +126,15 @@ ul#docs li div.example pre { padding: 5px; overflow: auto; } + +p.raw { + font-size: 11px; + color: #FFF; + margin: 5px auto; + width: 600px; + text-align: right; +} + +p.raw a { + color: #FFF; +} |