From b299b4b7a1599083c89c1311710cb68efd71e7ba Mon Sep 17 00:00:00 2001 From: mape Date: Sat, 24 Apr 2010 00:46:31 +0200 Subject: [PATCH] Update API doc --- doc/api_footer.html | 6 + doc/api_header.html | 424 ++++++++++++++++++++++++++++++++++++---------------- doc/doc.js | 241 +++++++++++++++++++++-------- 3 files changed, 479 insertions(+), 192 deletions(-) diff --git a/doc/api_footer.html b/doc/api_footer.html index 691287b..9b5777d 100644 --- a/doc/api_footer.html +++ b/doc/api_footer.html @@ -1,2 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/doc/api_header.html b/doc/api_header.html index 7340bdb..ba147a3 100644 --- a/doc/api_header.html +++ b/doc/api_header.html @@ -1,144 +1,310 @@ - + - - - node(1) -- evented I/O for V8 JavaScript - - - - + position:relative; + min-width: 690px; + } + a + { + color:#CD5; + } + a:focus + { + outline: none; + -moz-outline: none; + } + pre + { + overflow: hidden; + } + li + { + list-style: inside; + } + #man,#man code,#man pre,#man tt,#man kbd,#man samp + { + line-height:1.6; + color:#eee; + background:#22252a; + } + + #man + { + margin: 0; + position: absolute; + top:0; + bottom:0; + left: 225px; + right: 0; + overflow: auto; + } + #man-content + { + padding: 0 20px; + max-width: 650px; + } + #man h1,#man h2,#man h3 + { + color:#DCDDDE; + clear:left; + } + + #man h1 + { + background:url("http://nodejs.org/logo.png") no-repeat scroll center 0 transparent; + height:111px; + margin:15px 0 20px; + text-align:center; + text-indent:-2000px; + } + + #man h2 + { + font-size:18px; + background:#000; + color:#CD5; + margin:10px 0; + padding:5px 10px; + } + + #man h3 + { + font-size:16px; + margin:0 0 0 0ex; + } + + #man p,#man ul,#man ol,#man dl,#man pre + { + margin:0 0 18px; + } + + #man pre + { + color:#CCCDCE; + background:#121314; + border-left:2ex solid #222; + margin:0 0 20px; + padding:5px 7px; + } + + #man pre + h2,#man pre + h3 + { + margin-top:22px; + } + + #man h2 + pre,#man h3 + pre + { + margin-top:5px; + } + + #man > p,#man > ul,#man > ol,#man > dl,#man > pre + { + margin-left:5%; + } + + #man dt + { + clear:left; + margin:0; + } + + #man dt.flush + { + float:left; + width:8ex; + } + + #man dd + { + margin:0 0 0 9ex; + } + + #man code,#man strong,#man b + { + font-weight:bold; + color:#ECEDEE; + } + + #man pre code + { + font-weight:normal; + color:#DCDDDE; + background:inherit; + } + + #man em,var,u + { + font-style:normal; + color:#CCCDCE; + border-bottom:1px solid #999; + } + + #man ol.man,#man ol.man li + { + float:left; + width:33%; + list-style-type:none; + text-transform:uppercase; + font-size:18px; + color:#666; + letter-spacing:1px; + margin:2px 0 10px; + padding:0; + } + + #man ol.man + { + width:100%; + } + + #man ol.man li.tl + { + text-align:left; + } + + #man ol.man li.tc + { + text-align:center; + letter-spacing:4px; + } + + #man ol.man li.tr + { + text-align:right; + } + + #man ol.man a + { + color:#666; + } + + #man ol.man a:hover + { + color:#CCCDCE; + } + + #toc + { + position: absolute; + top:0; + bottom:0; + left: 0; + padding-left: 30px; + width: 195px; + overflow: auto; + overflow-x: hidden; + font-size: 15px; + } + #toc li + { + text-wrap: word-wrap; + } + #toc a + { + display: inline-block; + width: 100%; + color: #fff; + text-decoration:none; + } + #toc > a:hover + { + color: rgba(255,255,255,0.7); + } + #toc > ul > li + { + border-bottom:1px solid #0f1214; + padding:5px 0 5px 5px; + list-style: none; + line-height: 1.3; + } + #toc ul ul + { + display: none; + } + #toc ul ul > li + { + border-top:1px solid rgba(0, 0, 0, 0.1); + color:#FFFFFF; + font-size:85%; + line-height:1.3; + list-style:disc outside none; + margin-left:25px; + max-width:165px; + padding:3px 0 5px 5px; + } + #toc li.active > a + { + color:#CD5; + } + + .sh_sourceCode + { + font-family: monospace; + overflow:hidden; + } + + #toc .toggler + { + -moz-user-select:none; + background:none repeat scroll 0 0 #000000; + color:#FFFFFF; + display:inline-block; + font-weight:bold; + height:31px; + line-height:32px; + margin:-5px 8px -18px -33px; + outline:medium none; + padding:0; + text-align:center; + width:25px; + } + .current-section + { + position: fixed; + top: 0; + margin: 0 !important; + } + #toctitle + { + background:none repeat scroll 0 0 #000000; + color:#CCDD55; + font-size:18px; + margin: 0 0 10px -30px; + padding: 10px; + } + + +
Node v0.1.91
- +

node(1)

  1. node(1)
  2. +
  3. node(1)
  4. -
+ \ No newline at end of file diff --git a/doc/doc.js b/doc/doc.js index 3f092e4..00e8abd 100644 --- a/doc/doc.js +++ b/doc/doc.js @@ -1,63 +1,178 @@ -$(function() { - var count = 0; - var cur_level, last_level = 0, html = ""; - $(":header").filter("h2, h3").each(function(i, el){ - $(this).attr("id", $(this).text().replace(/\(.*\)$/gi, "").replace(/[\s\.]+/gi, "-").toLowerCase()+"-"+(count++)) - - cur_level = el.tagName.substr(1,1); - - if(cur_level > last_level){ - html += "
    "; - } else if (cur_level < last_level){ - html += "
" - } - if(i > 0){ - html += ""; - } - html += '
  • '; - html += ''+$(el).text().replace(/\(.*\)$/gi, "")+""; - - last_level = cur_level; - }); - - html += ""; - - $("#toc").append(html); - - $("#toc ul li").addClass("topLevel"); - - $("#toc ul li ul").each(function(i, el){ - $(el).parent().removeClass("topLevel").prepend('+'); - }) - - $("#toc ul li ul").hide(); - $("#toc ul li .toggler").bind("click", function(e){ - var el = $("ul", $(this).parent()); - if(el.css("display") == "none"){ - el.slideDown(); - $(this).text("–"); - } else { - el.slideUp(); - $(this).text("+"); - } - e.preventDefault(); - return false; - }); - - $('a[href*=#]').click(function() { - if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') - && location.hostname == this.hostname) { - var $target = $(this.hash); - $target = $target.length && $target - || $('[name=' + this.hash.slice(1) +']'); - if ($target.length) { - var targetOffset = $target.offset().top; - $('html,body') - .animate({scrollTop: targetOffset}, 500); - return false; - } - } - }); - - sh_highlightDocument(); -}); \ No newline at end of file +var NodeDoc = {}; + +NodeDoc.init = function() +{ + NodeDoc.generateToc(); + NodeDoc.setupScrollUpdate(); + NodeDoc.setupSmoothScrolling(); + + // Unblock rendering + setTimeout(function() + { + sh_highlightDocument(); + }, 100); +}; +NodeDoc.generateToc = function() +{ + var cur_level, last_level = 0, html = []; + + $('h2, h3').each(function(i) + { + var $this = $(this); + $this.attr('id', $this.text().replace(/\(.*\)$/gi, '').replace(/[\s\.]+/gi, '-').replace(/('|"|:)/gi, '').toLowerCase() + '-' + i); + + cur_level = this.tagName.substr(1, 1); + + if (cur_level > last_level) + { + html.push('
    • '); + } + else if (cur_level < last_level) + { + html.push('
    '); + } + + if (cur_level == last_level || cur_level < last_level) + { + html.push('
  • '); + } + + html.push('' + $this.text().replace(/\(.*\)$/gi, '') + ''); + if (cur_level == last_level || cur_level > last_level) + { + html.push('
  • '); + } + + last_level = cur_level; + }); + + html.push(''); + + var $toc = $('#toc').append(html.join('')).find('ul li ul').each(function() + { + $(this).parent().prepend('+'); + }).hide(); + + $('.toggler').live('click', function() + { + var $toggler = $('ul', $(this).parent()); + + if (!$toggler.is(':visible')) + { + $toggler.slideDown(); + $(this).text('–'); + } + else + { + $toggler.slideUp(); + $(this).text('+'); + } + + return false; + }); + + $('#toc > ul > li').live('click', function(e) + { + if ($(e.target).parents('ul').length < 2) + { + $(this).closest('li').find('.toggler').click(); + } + }); +}; +NodeDoc.setupScrollUpdate = function() +{ + $.extend($.expr[':'],{ + text: function(a,c, arr) + { + return $.trim($(a).text()) === (arr[3] || 'av34'); + } + }); + var $headlines = $('h2'); + var scrollTimeout; + + function updateNavigation() + { + var bodyCenter = $('body').scrollTop()+10; + + var $last = $('
    '); + var found = false; + + $headlines.each(function(index) + { + var $this = $(this); + + if ($this.offset().top > bodyCenter) + { + if (scrollTimeout) + { + clearTimeout(scrollTimeout); + } + + scrollTimeout = setTimeout(function() + { + updateNav($last); + }, 100); + return false; + } + + $last = $this; + }); + + if ($last.is('#dummy')) + { + $('.current-section').remove(); + } + + function updateNav($last) + { + var $activeToc = $('#toc > ul > li > a:text("'+$last.text()+'")').parent().addClass('active').siblings().removeClass('active').end(); + + if ($activeToc.length) + { + var newHash = $activeToc.find('> a:not(.toggler)').attr('href'); + + var $elementHash = $('#man h2'+newHash); + + $('title').text($('title').text().replace(/-- (.*) for/, '-- '+$last.text()+' for')); + + $('.current-section').remove(); + $currentSelection = $last.clone().width($last.width()).addClass('current-section'); + $last.after($currentSelection); + } + + } + } + + updateNavigation(); + + $('#man').scroll(updateNavigation); +}; +NodeDoc.setupSmoothScrolling = function() +{ + $('a[href*="#"]').live('click', function() + { + var $this = $(this); + if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) + { + var $target = $(this.hash); + $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']'); + + if ($target.length) + { + var targetOffset = $('#man').scrollTop()+$target.offset().top; + + if ($this.closest('#toc').length && $this.parents('ul').length > 1) + { + targetOffset -= 45; + } + + $('#man').animate({ + scrollTop: targetOffset + }, 200); + + return false; + } + } + }); +}; +NodeDoc.init(); \ No newline at end of file -- 2.7.4