From 0cefbe1997fe7dca32cf38a42ea29936b41a8029 Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 2 Jun 2012 11:21:16 +0200 Subject: [PATCH] display inherited properties --- source/Ox.UI/js/Code/DocPage.js | 50 ++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/source/Ox.UI/js/Code/DocPage.js b/source/Ox.UI/js/Code/DocPage.js index 987b444b..e2fcb536 100644 --- a/source/Ox.UI/js/Code/DocPage.js +++ b/source/Ox.UI/js/Code/DocPage.js @@ -80,19 +80,32 @@ Ox.DocPage = function(options, self) { function getItem(item, level, name) { Ox.Log('Core', 'getItem', item, level, name) - var $elements = [$('
') - .css({paddingLeft: (level ? level * 32 - 16 : 0) + 'px'}) - .html( - '' + (name || item.name) + ' ' - + '<' + item.types.join('> or <') + '> ' - + (item['class'] ? '(class: ' + item['class'] + ') ' : '') - + (item['default'] ? '(default: ' + item['default'] + ') ' : '') - + Ox.sanitizeHTML(item.summary) - ) - ]; - ['description'].concat( - item.order || ['returns', 'arguments', 'properties', 'events'] - ).concat(['tests', 'source']).forEach(function(section) { + var $elements = [ + $('
') + .css({paddingLeft: (level ? level * 32 - 16 : 0) + 'px'}) + .html( + '' + (name || item.name) + ' ' + + '<' + item.types.join('> or <') + '> ' + + (item['class'] ? '(class: ' + item['class'] + ') ' : '') + + (item['default'] ? '(default: ' + item['default'] + ') ' : '') + + Ox.sanitizeHTML(item.summary) + ) + ], + sections = ['description'].concat( + item.order || ['returns', 'arguments', 'properties'] + ).concat(['events', 'tests', 'source']), + index = sections.indexOf('properties') + 1 || 1; + if (item.inherited) { + Array.prototype.splice.apply(sections, [index, 0].concat( + item.inherited.map(function(v, i) { + var section = 'properties inherited from ' + + v.name + ''; + item[section] = v.properties; + return section; + }) + )); + } + sections.forEach(function(section) { var className = 'OxLine' + Ox.uid(); if (item[section]) { if (section == 'description') { @@ -149,10 +162,13 @@ Ox.DocPage = function(options, self) { }); }) ) - .append('' + Ox.toTitleCase( - section == 'returns' ? 'usage' - : section == 'tests' ? 'examples' - : section + .append('' + ( + Ox.startsWith('properties ', section) ? section + : Ox.toTitleCase( + section == 'returns' ? 'usage' + : section == 'tests' ? 'examples' + : section + ) ) + '') ); if (section == 'tests') {