From 24af1f65d4246ecd7c4c30e2acee18c470438823 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 6 Dec 2010 18:40:27 +0100 Subject: [PATCH] load comments from source --- docs/api.js | 132 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 95 insertions(+), 37 deletions(-) diff --git a/docs/api.js b/docs/api.js index 20c3aee8..e98b04b5 100644 --- a/docs/api.js +++ b/docs/api.js @@ -7,6 +7,25 @@ $(function() { app.$document = $(document); app.$window = $(window); + app.docstrings = {}; + $("
').html(doc.methods[m]).hide(); - var title = m; - var options = /function \((.*?)\)/.exec(doc.methods[m]); - if(options) { - title = title + '('+options[1]+')'; + function cell(content) { + return $('').css({'padding-right': '4px'}).html(content); + } + + var $div = $(' '); + var title = $('').html('Ox.'+doc.name) + .appendTo($div); + + if(app.docstrings[doc.name]) + $('
').html(app.docstrings[doc.name]).appendTo($div); + + var $options = $('').html("Options: ") + .css({'marginBottom': '20px'}) + .appendTo($div); + var $table = $('').attr({'cellpadding': '4'}) + .appendTo($options); + Ox.keys(doc.options).forEach(function(k) { + var $option = $('
'); + cell(k).appendTo($option); + if(typeof(doc.options[k]) != 'undefined') { + cell(typeof doc.options[k]).appendTo($option); + if(Ox.isNull(doc.options[k])) + cell(' null').appendTo($option); + else + cell(' ' + doc.options[k].toString() + '').appendTo($option); + } else { + cell(' ').appendTo($option); + cell('required, no default value').appendTo($option); } - var lable = new Ox.Label({ - title: title, - width: 190 - }) - .css({'float': 'left', 'margin-right': '4px'}) - .addClass("margin") - .appendTo($m); - var b = new Ox.Button({ + $option.appendTo($options); + }); + + var methods = Ox.keys(doc.methods); + if (methods.length > 0) { + var $methods = $(' ').html("Methods:").appendTo($div); + methods.forEach(function(m) { + var $method = $('').appendTo($methods); + var $code = $('').html(doc.methods[m]).hide(); + var options = /function \((.*?)\)/.exec(doc.methods[m]); + var lable = new Ox.Label({ + title: m + '('+options[1]+')', + width: 190 + }) + .css({'float': 'left', 'margin-right': '4px'}) + .addClass("margin") + .appendTo($method); + var $button = new Ox.Button({ + title: [ + {id: "one", title: "expand"}, + {id: "two", title: "collapse"}, + ], + type: "image" + }) + .addClass("margin") + .appendTo($method) + .click(function() { $code.toggle()}); + $code.appendTo($method); + }); + } + + var $methodcode = $('').html(doc.functionString.replace(/').html(doc.functionString).appendTo(wrapper); - return wrapper; + .addClass("margin") + .click(function() { $methodcode.toggle()}) + .appendTo($div) + $('').html(' View Source').appendTo($div) + $methodcode.appendTo($div); + return $div; } function getObjectByName(obj, name) {