Skip to content
Permalink
Browse files
Added all the new documentation files.
  • Loading branch information
jeresig committed Aug 9, 2006
1 parent 49747af commit f2d4bffcc760eb03dae13a9d9e7f0bbd8ec33c1e
Showing with 4,614 additions and 0 deletions.
  1. +58 −0 docs/doc.js
  2. +92 −0 docs/gen.pl
  3. +18 −0 docs/index.html
  4. +4,094 −0 docs/jquery-docs-json.js
  5. +1 −0 docs/jquery-docs-jsonp.js
  6. +58 −0 docs/jsont.js
  7. +93 −0 docs/pager.js
  8. +128 −0 docs/style.css
  9. +72 −0 docs/tooltip.js
@@ -0,0 +1,58 @@
var rules = {
self: "{$}",
type: function(a){ /*console.log( a, types[a] );*/ return types[a]; },
"self[*]": "<li><span class='type'><span title='{@type($.type)}'>{$.type}</span></span> <span class='fn'>" +
"<a href='#{$.name}' class='name' title='{$.name}: {$.short}'>{$.name}</a>({$.params})</span>" +
"<div class='short'>{$.short}</div><div class='more'><div class='desc'>{$.desc}</div>{$.examples}</div></li>",
"self[*].params[*]": " <span class='arg-type' title='{@type($.type)}'>{$.type}</span> <span class='arg-name' title='{$.desc}'>{$.name}</span> ",
"self[*].examples[*]": "<div class='example'><h5>Example:</h5><p>{$.desc}</p><pre>{$.code}</pre><b>HTML:</b><pre>{$.before}</pre><b>Result:</b><pre>{$.result}</pre></div>"
};

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&lt;Element&gt;": "An Array of DOM Elements.",
"Array&lt;String&gt;": "An Array of strings.",
Function: "A reference to a Javascript function."
};

function docsLoaded(docs) {
// Make sure that there are no private functions
docs = jQuery.grep( docs, "!a.private" )
// Sort by function name
.sort(function(a,b){
if ( a.name < b.name ) return -1;
else if ( a.name == b.name ) {
// Sort by number of parameters
if ( a.params.length < b.params.length ) return -1;
else if ( a.params.length == b.params.length ) return 0;
else return 1;
} else return 1;
});

// Put in the DOM, when it's ready
$(document).ready(function(){
$("#docs").html( jsonT( docs, rules ) );
setTimeout(function(){
$("#docs").pager( function(){return this.firstChild.nextSibling.nextSibling.firstChild.innerHTML;}, function(s,e){
$(this).html( jsonT( docs.slice( s, e ), rules ) );
/*$(this).slideUp("slow",function(){
this.style.opacity = 1;
this.style.width = "";
this.style.height = "";
$(this).html( jsonT( docs.slice( s, e ), rules ) );
$(this).slideDown("slow");
});*/
$("span",this).filter("[@title]").addClass("tooltip").ToolTipDemo('#fff');
$("a.name",this).click(function(){
$("div.more,div.short",this.parentNode.parentNode).toggle();
return false;
});
});
}, 13);
});
}
@@ -0,0 +1,92 @@
#!/usr/bin/perl

use Data::Dumper;

$Data::Dumper::Pair = ": ";
$Data::Dumper::Sortkeys = 1;
$Data::Dumper::Terse = 1;

open( F, $ARGV[0] || "../jquery-svn.js" );
my $f = join('', <F>);
close( F );

my @c;

while ( $f =~ /\/\*\*\s*(.*?)\s*\*\//gs ) {
my $c = $1;
$c =~ s/^\s*\* ?//mg;
$c .= "!!!";
my %ret;

$ret{ 'params' } = [];
$ret{ 'examples' } = [];

#while ( $c =~ s/^\@(\S+)\s*<pre>(.*?)<\/pre>\n//ms ) {
#print "PARAM '$1' '$2'\n";
#}
while ( $c =~ s/^\@(\S+) *(.*?)(?=\n\@|!!!)//ms ) {
my $n = $1;
my $v = $2;
$v =~ s/\s*$//g;
$v =~ s/^\s*//g;
$v =~ s/&/&amp;/g;
$v =~ s/(\s\s+)/"&nbsp;" x length($1)/eg;
$v =~ s/</&lt;/g;
$v =~ s/>/&gt;/g;
$v =~ s/\n/<br>/g;
$v = 1 if ( $v eq '' );

if ( $n eq 'param' ) {
my ( $type, $name, @v ) = split( /\s+/, $v );
$v = { "type" => $type, "name" => $name, "desc" => join(' ', @v) };
$n = "params";
} elsif ( $n eq 'example' ) {
$v = { "code" => $v };
$n = "examples";
}

if ( $n eq 'desc' || $n eq 'before' || $n eq 'after' || $n eq 'result' ) {
my @e = @{$ret{'examples'}};
$e[ $#e ]{ $n } = $v;
} else {

if ( exists $ret{ $n } ) {
if ( ref $ret{ $n } eq 'ARRAY' ) {
push( @{$ret{ $n }}, $v );
} else {
$ret{ $n } = [ $ret{ $n }, $v ];
}
} else {
$ret{ $n } = $v;
}

}
}

$c =~ s/\s*!!!$//;
$c =~ s/\n\n/<br><br>/g;
$c =~ s/\n/ /g;

$ret{ 'desc' } = $c;

if ( $c =~ /^(.*?(\.|$))/s ) {
$ret{ 'short' } = $1;
#$ret{ 'short' } =~ s/<br>/ /g;
}

#print "###\n" . $c . "\n###\n";

if ( exists $ret{ 'name' } ) {
push( @c, \%ret );
}
}

open( F, ">" . ($ARGV[1] || "jquery-docs-json.js") );
print F Dumper( \@c );
close( F );

$Data::Dumper::Indent = 0;

open( F, ">" . ($ARGV[2] || "jquery-docs-jsonp.js") );
print F "docsLoaded(" . Dumper( \@c ) . ")";
close( F );
@@ -0,0 +1,18 @@
<html>
<head>
<title>jQuery Documentation</title>
<link rel="stylesheet" href="style.css"/>
<script src="../jquery-svn.js"></script>
<script src="tooltip.js"></script>
<script src="pager.js"></script>
<script src="jsont.js"></script>
<script src="doc.js"></script>
<script src="jquery-docs-jsonp.js"></script>
</head>
<body>
<h1>jQuery Docs &raquo; API</h1>
<ul id="docs">
<li>Loading...</li>
</ul>
</body>
</html>

0 comments on commit f2d4bff

Please sign in to comment.