cleanup api docs
This commit is contained in:
parent
79bbc1d75a
commit
ba9bf2ee4b
|
@ -276,7 +276,7 @@ requires
|
|||
}();
|
||||
|
||||
/**
|
||||
Creates an Ox.Event
|
||||
Ox.Event event object
|
||||
*/
|
||||
Ox.Event = function() {
|
||||
var $eventHandler = $('<div>'),
|
||||
|
@ -632,7 +632,7 @@ requires
|
|||
*/
|
||||
|
||||
/**
|
||||
Ox.Request
|
||||
Ox.Request request object
|
||||
*/
|
||||
Ox.Request = function() {
|
||||
|
||||
|
@ -3298,6 +3298,18 @@ requires
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
options:
|
||||
format: 'short'
|
||||
value: date value
|
||||
weekday: false
|
||||
width: {
|
||||
day: 32,
|
||||
month: options.format == 'long' ? 80 : (options.format == 'medium' ? 40 : 32),
|
||||
weekday: options.format == 'long' ? 80 : 40,
|
||||
year: 48
|
||||
}
|
||||
*/
|
||||
Ox.DateInput = function(options, self) {
|
||||
|
||||
var self = $.extend(self || {}, {
|
||||
|
|
45
docs/api.js
45
docs/api.js
|
@ -7,7 +7,9 @@ $(function() {
|
|||
app.$document = $(document);
|
||||
app.$window = $(window);
|
||||
|
||||
app.$ui = {};
|
||||
app.docstrings = {};
|
||||
|
||||
$("<div>").load('../build/js/ox.ui.js', function(data) {
|
||||
app.source = data;
|
||||
var docstrings = app.source.match(/\/\*\*\n([\s\S]+?\*\/\n.*?)\n/gm)
|
||||
|
@ -26,11 +28,10 @@ $(function() {
|
|||
app.docstrings[name[1]] = Ox.trim(doc.join('\n'));
|
||||
}
|
||||
})
|
||||
app.$ui = {};
|
||||
});
|
||||
app.docs = getDocsJSON();
|
||||
app.$ui.actionList = constructList();
|
||||
app.$ui.actionInfo = Ox.Container().css({padding: '8px'});
|
||||
|
||||
app.$ui.actionInfo = Ox.Container().css({padding: '8px'}).html('select action on the left.');
|
||||
|
||||
var $main = new Ox.SplitPanel({
|
||||
elements: [
|
||||
|
@ -47,7 +48,6 @@ $(function() {
|
|||
|
||||
$main.appendTo(app.$body);
|
||||
});
|
||||
});
|
||||
|
||||
function constructList() {
|
||||
return new Ox.TextList({
|
||||
|
@ -70,11 +70,6 @@ function constructList() {
|
|||
app.docs.forEach(function(v) {
|
||||
items.push(v.name);
|
||||
});
|
||||
Ox.keys(app.docstrings).forEach(function(v) {
|
||||
if(!$.inArray(v.name, items)) {
|
||||
items.push(v.name);
|
||||
}
|
||||
});
|
||||
items = Ox.map(items, function(i) { return {name: i}});
|
||||
items.sort(function(a, b) { if(a.name < b.name) { return -1 } else if( a.name == b.name) { return 0 }else { return 1 } })
|
||||
if(!data.keys) {
|
||||
|
@ -117,6 +112,7 @@ function getDocHtml(doc) {
|
|||
if(app.docstrings[doc.name])
|
||||
$('<pre>').html(app.docstrings[doc.name]).appendTo($div);
|
||||
|
||||
if(doc.options) {
|
||||
var $options = $('<div>').html("Options: ")
|
||||
.css({'marginBottom': '20px'})
|
||||
.appendTo($div);
|
||||
|
@ -137,6 +133,7 @@ function getDocHtml(doc) {
|
|||
}
|
||||
$option.appendTo($options);
|
||||
});
|
||||
}
|
||||
|
||||
var methods = Ox.keys(doc.methods);
|
||||
if (methods.length > 0) {
|
||||
|
@ -166,6 +163,7 @@ function getDocHtml(doc) {
|
|||
});
|
||||
}
|
||||
|
||||
if(doc.functionString) {
|
||||
var $methodcode = $('<pre>').html(doc.functionString.replace(/</g, '<'))
|
||||
.hide();
|
||||
var $button = new Ox.Button({
|
||||
|
@ -180,6 +178,7 @@ function getDocHtml(doc) {
|
|||
.appendTo($div)
|
||||
$('<span>').html(' View Source').appendTo($div)
|
||||
$methodcode.appendTo($div);
|
||||
}
|
||||
return $div;
|
||||
}
|
||||
|
||||
|
@ -208,26 +207,34 @@ function getDocsJSON() {
|
|||
function getDoc(key) {
|
||||
var standardElement = new Ox.Element();
|
||||
var standardMethods = Ox.filter(Ox.keys(standardElement), function(m) { return typeof standardElement[m] === 'function' });
|
||||
var firstLetter = key.substring(0,1);
|
||||
if (firstLetter != firstLetter.toUpperCase() || typeof Ox[key] != 'function') {
|
||||
return false;
|
||||
|
||||
//FIXME: eventually we want to document all Ox values and functions
|
||||
if (!/^[A-Z][a-z]/.test(key)) {
|
||||
return false
|
||||
}
|
||||
var functionString = Ox[key].toString();
|
||||
if (typeof Ox[key] != 'function') {
|
||||
return {
|
||||
'name': key,
|
||||
'functionString': functionString
|
||||
}
|
||||
}
|
||||
var functionString = Ox[key].toString();
|
||||
try {
|
||||
var o = new Ox[key]();
|
||||
} catch(err) {
|
||||
return {
|
||||
'name': key,
|
||||
'functionString': functionString
|
||||
}
|
||||
catch(err) {
|
||||
return false;
|
||||
}
|
||||
var methods = {};
|
||||
var opts = {};
|
||||
if ('options' in o && typeof o['options'] == 'function') {
|
||||
var functionString = Ox[key].toString();
|
||||
var opts = o.options();
|
||||
var _methods = Ox.filter(Ox.keys(o), function(m) { return (functionString.indexOf('that.'+m+' =') > -1 && typeof o[m] === 'function')});
|
||||
var methods = {};
|
||||
$.each(_methods, function(i, m) { methods[m] = o[m].toString() });
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
return {
|
||||
'name': key,
|
||||
'options': opts,
|
||||
|
|
Loading…
Reference in New Issue
Block a user