Ox.DocPage = function(options, self) { self = self || {}; var that = Ox.Element({}, self) .defaults({ item: {} }) .options(options || {}) .addClass('OxDocPage OxText') .css({ overflow: 'auto' }); 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.encodeHTML(example.result) + '
'
)
)
});
} else if (section == 'source') {
// fixme: not the right place to fix path
$elements.push($('' + self.options.item.file.replace(Ox.PATH, '') +
' line ' + self.options.item.line + '
'
)
);
$elements.push(
Ox.SyntaxHighlighter({
showLineNumbers: true,
// fixme: silly
source: item.source.map(function(token) {
return token.source;
}).join(''),
offset: self.options.item.line
})
.addClass(className)
.css({
borderWidth: '1px',
marginTop: '8px',
})
);
} 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;
};