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() {
|
Ox.Event = function() {
|
||||||
var $eventHandler = $('<div>'),
|
var $eventHandler = $('<div>'),
|
||||||
|
@ -632,7 +632,7 @@ requires
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Ox.Request
|
Ox.Request request object
|
||||||
*/
|
*/
|
||||||
Ox.Request = function() {
|
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) {
|
Ox.DateInput = function(options, self) {
|
||||||
|
|
||||||
var self = $.extend(self || {}, {
|
var self = $.extend(self || {}, {
|
||||||
|
|
45
docs/api.js
45
docs/api.js
|
@ -7,7 +7,9 @@ $(function() {
|
||||||
app.$document = $(document);
|
app.$document = $(document);
|
||||||
app.$window = $(window);
|
app.$window = $(window);
|
||||||
|
|
||||||
|
app.$ui = {};
|
||||||
app.docstrings = {};
|
app.docstrings = {};
|
||||||
|
|
||||||
$("<div>").load('../build/js/ox.ui.js', function(data) {
|
$("<div>").load('../build/js/ox.ui.js', function(data) {
|
||||||
app.source = data;
|
app.source = data;
|
||||||
var docstrings = app.source.match(/\/\*\*\n([\s\S]+?\*\/\n.*?)\n/gm)
|
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.docstrings[name[1]] = Ox.trim(doc.join('\n'));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
app.$ui = {};
|
});
|
||||||
app.docs = getDocsJSON();
|
app.docs = getDocsJSON();
|
||||||
app.$ui.actionList = constructList();
|
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({
|
var $main = new Ox.SplitPanel({
|
||||||
elements: [
|
elements: [
|
||||||
|
@ -46,7 +47,6 @@ $(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$main.appendTo(app.$body);
|
$main.appendTo(app.$body);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function constructList() {
|
function constructList() {
|
||||||
|
@ -70,11 +70,6 @@ function constructList() {
|
||||||
app.docs.forEach(function(v) {
|
app.docs.forEach(function(v) {
|
||||||
items.push(v.name);
|
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 = 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 } })
|
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) {
|
if(!data.keys) {
|
||||||
|
@ -117,6 +112,7 @@ function getDocHtml(doc) {
|
||||||
if(app.docstrings[doc.name])
|
if(app.docstrings[doc.name])
|
||||||
$('<pre>').html(app.docstrings[doc.name]).appendTo($div);
|
$('<pre>').html(app.docstrings[doc.name]).appendTo($div);
|
||||||
|
|
||||||
|
if(doc.options) {
|
||||||
var $options = $('<div>').html("Options: ")
|
var $options = $('<div>').html("Options: ")
|
||||||
.css({'marginBottom': '20px'})
|
.css({'marginBottom': '20px'})
|
||||||
.appendTo($div);
|
.appendTo($div);
|
||||||
|
@ -137,6 +133,7 @@ function getDocHtml(doc) {
|
||||||
}
|
}
|
||||||
$option.appendTo($options);
|
$option.appendTo($options);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var methods = Ox.keys(doc.methods);
|
var methods = Ox.keys(doc.methods);
|
||||||
if (methods.length > 0) {
|
if (methods.length > 0) {
|
||||||
|
@ -166,6 +163,7 @@ function getDocHtml(doc) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(doc.functionString) {
|
||||||
var $methodcode = $('<pre>').html(doc.functionString.replace(/</g, '<'))
|
var $methodcode = $('<pre>').html(doc.functionString.replace(/</g, '<'))
|
||||||
.hide();
|
.hide();
|
||||||
var $button = new Ox.Button({
|
var $button = new Ox.Button({
|
||||||
|
@ -180,6 +178,7 @@ function getDocHtml(doc) {
|
||||||
.appendTo($div)
|
.appendTo($div)
|
||||||
$('<span>').html(' View Source').appendTo($div)
|
$('<span>').html(' View Source').appendTo($div)
|
||||||
$methodcode.appendTo($div);
|
$methodcode.appendTo($div);
|
||||||
|
}
|
||||||
return $div;
|
return $div;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,26 +207,34 @@ function getDocsJSON() {
|
||||||
function getDoc(key) {
|
function getDoc(key) {
|
||||||
var standardElement = new Ox.Element();
|
var standardElement = new Ox.Element();
|
||||||
var standardMethods = Ox.filter(Ox.keys(standardElement), function(m) { return typeof standardElement[m] === 'function' });
|
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') {
|
//FIXME: eventually we want to document all Ox values and functions
|
||||||
return false;
|
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 {
|
try {
|
||||||
var o = new Ox[key]();
|
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') {
|
if ('options' in o && typeof o['options'] == 'function') {
|
||||||
var functionString = Ox[key].toString();
|
|
||||||
var opts = o.options();
|
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 = 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() });
|
$.each(_methods, function(i, m) { methods[m] = o[m].toString() });
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
'name': key,
|
'name': key,
|
||||||
'options': opts,
|
'options': opts,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user