diff --git a/source/Ox.UI/js/Code/DocPage.js b/source/Ox.UI/js/Code/DocPage.js index c3550f6d..2b5aab93 100644 --- a/source/Ox.UI/js/Code/DocPage.js +++ b/source/Ox.UI/js/Code/DocPage.js @@ -94,17 +94,25 @@ Ox.DocPage = function(options, self) { 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; - }) - )); - } + index = { + events: sections.indexOf('events') + 1 + ( + item.inheritedproperties ? item.inheritedproperties.length : 0 + ), + properties: sections.indexOf('properties') + 1 || 1 + }; + ['properties', 'events'].forEach(function(key) { + var key_ = 'inherited' + key; + if (item[key_]) { + Array.prototype.splice.apply(sections, [index[key], 0].concat( + item[key_].map(function(v, i) { + var section = key + ' inherited from ' + + v.name + ''; + item[section] = v[key]; + return section; + }) + )); + } + }); sections.forEach(function(section) { var className = 'OxLine' + Ox.uid(); if (item[section]) { @@ -163,12 +171,13 @@ Ox.DocPage = function(options, self) { }) ) .append('' + ( - Ox.startsWith(section, 'Properties') ? section - : Ox.toTitleCase( - section == 'returns' ? 'usage' - : section == 'tests' ? 'examples' - : section - ) + Ox.contains(section, 'inherited') + ? section[0].toUpperCase() + section.slice(1) + : Ox.toTitleCase( + section == 'returns' ? 'usage' + : section == 'tests' ? 'examples' + : section + ) ) + '') ); if (section == 'tests') { diff --git a/source/Ox/js/JavaScript.js b/source/Ox/js/JavaScript.js index 780dbcb0..613e785f 100644 --- a/source/Ox/js/JavaScript.js +++ b/source/Ox/js/JavaScript.js @@ -19,7 +19,10 @@ Ox.doc Generates documentation for annotated JavaScript events <[o]|u> Events (array of doc objects) Present if the item fires any events file File name - inherited <[o]|u> Inherited properties (array of doc objects) + inheritedevents <[o]|u> Inherited events (array of doc objects) + Present if the item has a class, and any item in its inheritance + chain fires events + inheritedproperties <[o]|u> Inherited properties (array of doc objects) Present if the item has a class, and any item in its inheritance chain has (unshadowed) properties line Line number @@ -39,7 +42,7 @@ Ox.doc Generates documentation for annotated JavaScript Present if the `type` of the item is `"function"`. summary One-line summary, with some Markdown See Ox.parseMarkdown for details - tests <[o]> Tests (array of test objects) + tests <[o]|u> Tests (array of test objects) expected Expected result statement Statement types <[s]> Types of the item @@ -97,12 +100,17 @@ Ox.doc = (function() { var constructors = getConstructors(items), instances = {}, nodes = {}; function hasProperty(item, property) { var properties = item.properties || [], - inherited = item.inherited ? item.inherited.map(function(v) { - return v.properties; - }) : []; - return Ox.contains(properties.concat(inherited).map(function(property) { - return property.name; - }), property.name); + inheritedproperties = item.inheritedproperties + ? item.inheritedproperties.map(function(v) { + return v.properties; + }) + : []; + return Ox.contains( + properties.concat(inheritedproperties).map(function(property) { + return property.name; + }), + property.name + ); } var foo = {}; constructors.forEach(function(constructor) { @@ -117,18 +125,23 @@ Ox.doc = (function() { || Ox.last(items[Ox.indexOf(items, function(item) { return item.name == parentName; })].returns); - parent && parent.properties && parent.properties.forEach(function(property) { - if (!hasProperty(child, property)) { - if (!child.inherited) { - child.inherited = []; + ['properties', 'events'].forEach(function(key) { + parent[key] && parent[key].forEach(function(value) { + var key_ = 'inherited' + key; + if (key == 'events' || !hasProperty(child, value)) { + if (!child[key_]) { + child[key_] = []; + } + if (!child[key_].some(function(v) { + return v.name == parentName; + })) { + child[key_].push( + Ox.extend({name: parentName}, key, []) + ); + } + Ox.last(child[key_])[key].push(value); } - if (!child.inherited.some(function(v) { - return v.name == parentName; - })) { - child.inherited.push({name: parentName, properties: []}); - } - Ox.last(child.inherited).properties.push(property); - } + }) }); }); }); @@ -225,7 +238,6 @@ Ox.doc = (function() { item.tests = item.tests || []; item.tests.push(parseTest(line)); } else if ((subitem = parseItem(line))) { - item.name == 'Ox.getset' && Ox.print(line, subitem) if (subitem.signature) { item.returns = item.returns || []; item.returns.push(parseNode(node));