Document typedefs and enums used by API symbols

It is no longer necessary to add api annotations to typedefs and enums
that are used by API symbols.
This commit is contained in:
Andreas Hocevar
2016-06-03 09:28:53 +02:00
parent 3d8ca68bac
commit eddd006fcf
5 changed files with 38 additions and 13 deletions

View File

@@ -11,6 +11,7 @@ exports.defineTags = function(dictionary) {
canHaveType: false, canHaveType: false,
canHaveName: false, canHaveName: false,
onTagged: function(doclet, tag) { onTagged: function(doclet, tag) {
includeTypes(doclet);
var level = tag.text || "experimental"; var level = tag.text || "experimental";
if (levels.indexOf(level) >= 0) { if (levels.indexOf(level) >= 0) {
doclet.stability = level; doclet.stability = level;
@@ -25,11 +26,15 @@ exports.defineTags = function(dictionary) {
/* /*
* Based on @stability annotations, and assuming that items with no @stability * Based on @api annotations, and assuming that items with no @api annotation
* annotation should not be documented, this plugin removes undocumented symbols * should not be documented, this plugin removes undocumented symbols
* from the documentation. * from the documentation.
*/ */
var api = [];
var classes = {};
var types = {};
function hasApiMembers(doclet) { function hasApiMembers(doclet) {
return doclet.longname.split('#')[0] == this.longname; return doclet.longname.split('#')[0] == this.longname;
} }
@@ -71,8 +76,28 @@ function includeAugments(doclet) {
} }
} }
var api = []; function extractTypes(item) {
var classes = {}; item.type.names.forEach(function(type) {
types[type] = true;
//TODO handle Array.<type> etc.
});
}
function includeTypes(doclet) {
if (doclet.params && doclet.kind != 'class') {
doclet.params.forEach(extractTypes);
}
if (doclet.returns) {
doclet.returns.forEach(extractTypes);
}
if (doclet.isEnum) {
types[doclet.meta.code.name] = true;
}
if (doclet.type && doclet.meta.code.type == 'MemberExpression') {
// types in olx.js
extractTypes(doclet);
}
}
exports.handlers = { exports.handlers = {
@@ -120,7 +145,7 @@ exports.handlers = {
// constructor from the docs. // constructor from the docs.
doclet._hideConstructor = true; doclet._hideConstructor = true;
includeAugments(doclet); includeAugments(doclet);
} else if (!doclet._hideConstructor) { } else if (!doclet._hideConstructor && !(doclet.kind == 'typedef' && doclet.longname in types)) {
// Remove all other undocumented symbols // Remove all other undocumented symbols
doclet.undocumented = true; doclet.undocumented = true;
} }

View File

@@ -39,7 +39,7 @@ var self = this;
<?js <?js
item.typedefs.forEach(function (v) { item.typedefs.forEach(function (v) {
?> ?>
<li data-name="<?js= v.longname ?>" class="<?js= v.stability !== 'stable' ? 'unstable' : ''?>"> <li data-name="<?js= v.longname ?>" class="<?js= (v.stability && v.stability !== 'stable') ? 'unstable' : ''?>">
<?js= self.linkto(v.longname, v.name) ?> <?js= self.linkto(v.longname, v.name) ?>
</li> </li>
<?js <?js
@@ -56,7 +56,7 @@ var self = this;
item.methods.forEach(function (v) { item.methods.forEach(function (v) {
?> ?>
<li data-name="<?js= v.longname ?>" class="<?js= v.stability !== 'stable' ? 'unstable' : ''?>"> <li data-name="<?js= v.longname ?>" class="<?js= (v.stability && v.stability !== 'stable') ? 'unstable' : ''?>">
<?js= self.linkto(v.longname, v.name) ?> <?js= self.linkto(v.longname, v.name) ?>
</li> </li>
<?js <?js
@@ -73,7 +73,7 @@ var self = this;
item.fires.forEach(function (v) { item.fires.forEach(function (v) {
v = self.find({longname: v})[0] || {longname: v, name: v.split(/#?event:/)[1]}; v = self.find({longname: v})[0] || {longname: v, name: v.split(/#?event:/)[1]};
?> ?>
<li data-name="<?js= v.longname ?>" class="<?js= (v.stability != 'stable' ? 'unstable' : '') ?>"> <li data-name="<?js= v.longname ?>" class="<?js= (v.stability && v.stability != 'stable') ? 'unstable' : '' ?>">
<?js= self.linkto(v.longname, v.name) ?> <?js= self.linkto(v.longname, v.name) ?>
</li> </li>
<?js <?js

View File

@@ -21,7 +21,7 @@
var setter = prop.readonly ? 'no' : 'yes'; var setter = prop.readonly ? 'no' : 'yes';
?> ?>
<tr class="<?js= prop.stability !== 'stable' ? 'unstable' : '' ?>"> <tr class="<?js= (prop.stability && prop.stability !== 'stable') ? 'unstable' : '' ?>">
<td class="name"><code><?js= prop.name ?></code></td> <td class="name"><code><?js= prop.name ?></code></td>
<td class="type"> <td class="type">
<?js if (prop.type && prop.type.names) {?> <?js if (prop.type && prop.type.names) {?>

View File

@@ -2,6 +2,6 @@
var data = obj; var data = obj;
var self = this; var self = this;
if (data.stability != 'stable') { ?> if (data.stability && data.stability != 'stable') { ?>
<span class="stability <?js= data.stability ?>"><?js= data.stability ?></span> <span class="stability <?js= data.stability ?>"><?js= data.stability ?></span>
<?js } ?> <?js } ?>