Include symbols from oli.js using interface and implements tags
Instead of regex parsing, we define tags for interface and implements.
This commit is contained in:
committed by
Tim Schaub
parent
b758d92790
commit
aaf6101d0f
@@ -14,12 +14,14 @@
|
|||||||
],
|
],
|
||||||
"include": [
|
"include": [
|
||||||
"src",
|
"src",
|
||||||
|
"externs/oli.js",
|
||||||
"externs/olx.js"
|
"externs/olx.js"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"node_modules/jsdoc/plugins/markdown",
|
"node_modules/jsdoc/plugins/markdown",
|
||||||
"apidoc/plugins/inheritdoc",
|
"apidoc/plugins/inheritdoc",
|
||||||
|
"apidoc/plugins/interface",
|
||||||
"apidoc/plugins/exports",
|
"apidoc/plugins/exports",
|
||||||
"apidoc/plugins/todo",
|
"apidoc/plugins/todo",
|
||||||
"apidoc/plugins/observable",
|
"apidoc/plugins/observable",
|
||||||
|
|||||||
+10
-16
@@ -1,6 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* This plugin parses externs/oli.js as well as goog.exportSymbol and
|
* This plugin removes unexported symbols from the documentation.
|
||||||
* goog.exportProperty calls to build a list of API symbols and properties.
|
|
||||||
* Unexported modules linked from @param or @fires will be marked unexported,
|
* Unexported modules linked from @param or @fires will be marked unexported,
|
||||||
* and the documentation will not contain the constructor. Everything else is
|
* and the documentation will not contain the constructor. Everything else is
|
||||||
* marked undocumented, which will remove it from the docs.
|
* marked undocumented, which will remove it from the docs.
|
||||||
@@ -17,22 +16,9 @@ function collectExports(source) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function collectOliExports(source) {
|
|
||||||
var oli = source.match(/[^\{]oli\.([^;^ ]*);? ?/g);
|
|
||||||
if (oli) {
|
|
||||||
i = 0; ii = oli.length;
|
|
||||||
for (; i < ii; ++i) {
|
|
||||||
property = 'ol.' + oli[i].match(/oli.([^;]*)/)[1]
|
|
||||||
.replace('.prototype.', '#');
|
|
||||||
unexported.push(property);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var encoding = env.conf.encoding || 'utf8';
|
var encoding = env.conf.encoding || 'utf8';
|
||||||
var fs = require('jsdoc/fs');
|
var fs = require('jsdoc/fs');
|
||||||
collectExports(fs.readFileSync('build/symbols.json', encoding));
|
collectExports(fs.readFileSync('build/symbols.json', encoding));
|
||||||
collectOliExports(fs.readFileSync('externs/oli.js', encoding));
|
|
||||||
|
|
||||||
|
|
||||||
exports.handlers = {
|
exports.handlers = {
|
||||||
@@ -42,6 +28,9 @@ exports.handlers = {
|
|||||||
if (e.doclet.meta.filename == "olx.js" && e.doclet.longname != 'olx') {
|
if (e.doclet.meta.filename == "olx.js" && e.doclet.longname != 'olx') {
|
||||||
api.push(e.doclet.longname);
|
api.push(e.doclet.longname);
|
||||||
}
|
}
|
||||||
|
if (e.doclet.longname.indexOf('oli.') === 0) {
|
||||||
|
unexported.push(e.doclet.longname.replace(/^oli\./, 'ol.'));
|
||||||
|
}
|
||||||
if (api.indexOf(e.doclet.longname) > -1) {
|
if (api.indexOf(e.doclet.longname) > -1) {
|
||||||
var names, name;
|
var names, name;
|
||||||
var params = e.doclet.params;
|
var params = e.doclet.params;
|
||||||
@@ -87,7 +76,7 @@ exports.handlers = {
|
|||||||
doclet.properties = [];
|
doclet.properties = [];
|
||||||
}
|
}
|
||||||
doclet.properties.unshift(propertyDoclet);
|
doclet.properties.unshift(propertyDoclet);
|
||||||
e.doclets.splice(i, 1)
|
e.doclets.splice(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,6 +93,11 @@ exports.handlers = {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (doclet.memberof && doclet.memberof.indexOf('oli.') === 0 &&
|
||||||
|
unexported.indexOf(doclet.memberof) > -1) {
|
||||||
|
// Always document members of referenced oli interfaces
|
||||||
|
continue;
|
||||||
|
}
|
||||||
doclet.unexported = (api.indexOf(fqn) === -1 && unexported.indexOf(fqn) !== -1);
|
doclet.unexported = (api.indexOf(fqn) === -1 && unexported.indexOf(fqn) !== -1);
|
||||||
if (api.indexOf(fqn) === -1 && unexported.indexOf(fqn) === -1) {
|
if (api.indexOf(fqn) === -1 && unexported.indexOf(fqn) === -1) {
|
||||||
e.doclets.splice(j, 1);
|
e.doclets.splice(j, 1);
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
var util = require('util');
|
||||||
|
exports.defineTags = function(dictionary) {
|
||||||
|
|
||||||
|
var classTag = dictionary.lookUp('class');
|
||||||
|
dictionary.defineTag('interface', {
|
||||||
|
mustHaveValue: false,
|
||||||
|
onTagged: function(doclet, tag) {
|
||||||
|
classTag.onTagged.apply(this, arguments);
|
||||||
|
doclet.interface = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dictionary.defineTag('implements', {
|
||||||
|
mustHaveValue: true,
|
||||||
|
onTagged: function(doclet, tag) {
|
||||||
|
if (!doclet.implements) {
|
||||||
|
doclet.implements = [];
|
||||||
|
}
|
||||||
|
doclet.implements.push(tag.value.match(/^{(.*)}$/)[1]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user