Ox.DocPage = function(options, self) { self = self || {}; var that = Ox.Element({}, self) .defaults({ item: {} }) .options(options || {}) .addClass('OxText') .css({ overflow: 'auto' }); Ox.print('-------------------item', self.options.item) that.append($('
' + self.options.item.name + '
'));
getItem(self.options.item, 0).forEach(function($element) {
that.append($element);
});
function getItem(item, level, name) {
var $elements = [$('' + (name || item.name) + ' ' +
'<' + item.types.join('>
or <') + '>
' +
(item.default ? 'default: ' + item.default + '
' : '') +
Ox.parseHTML(item.summary)
)
];
[
'description', 'usage', 'arguments', 'properties', 'events', 'examples', 'source'
].forEach(function(section) {
var className = 'OxLine' + Ox.uid();
if (item[section]) {
if (section == 'description') {
$elements.push($('> ' +
Ox.encodeHTML(example.statement)
.replace(/ /g, ' ')
.replace(/\n/g, '
\n ') +
'
'
)
);
example.result && $elements.push($('' + Ox.parseHTML(example.result) + '
'
)
)
});
} else if (section == 'source') {
var html = '';
item.source.forEach(function(token) {
html += '' +
Ox.encodeHTML(token.source)
.replace(/ /g, ' ')
.replace(/\n/g, '' + html + '
')
);
} else {
item[section].forEach(function(v) {
var name = section == 'usage' ?
item.name + v.name + ' returns ' : null;
$elements = Ox.merge(
$elements,
Ox.map(getItem(v, level + 1, name), function($element) {
return $element.addClass(className);
})
);
});
}
}
}
})
return $elements;
}
return that;
};