Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* add-links: Add links to the source code for protractor.js, locators.js,
* and webdriver.js.
* add-toc: Add the table of contents.
*/
config.append('processing.processors', [
require('./processors/tag-fixer'),
require('./processors/filter-jsdoc'),
require('./processors/add-links'),
require('./processors/add-toc')
]);
// Configure the tags that will be parsed from the jsDoc.
var tagDefs = require('dgeni-packages/jsdoc/tag-defs');
// Parse the following annotations.
tagDefs.push({name: 'alias'});
tagDefs.push({name: 'augments'});
tagDefs.push({name: 'deprecated'});
tagDefs.push({name: 'example'});
tagDefs.push({name: 'private'});
tagDefs.push({name: 'see'});
tagDefs.push({name: 'type'});
tagDefs.push({name: 'view'});
// The name tag should not be required.
var nameTag = _.find(tagDefs, {name: 'name'});
nameTag.required = false;
config.set('processing.tagDefinitions', tagDefs);
// OutputPath for docs that do not already have them.
config.set('rendering.contentsFolder',
*/
config.append('rendering.filters', [
require('./filters/link-slugify')
]);
// Configure the tags that will be parsed from the jsDoc.
var tagDefs = require('dgeni-packages/jsdoc/tag-defs');
// Parse the following annotations.
tagDefs.push({name: 'alias'});
tagDefs.push({name: 'augments'});
tagDefs.push({name: 'deprecated'});
tagDefs.push({name: 'example'});
tagDefs.push({name: 'private'});
tagDefs.push({name: 'see'});
tagDefs.push({name: 'type'});
tagDefs.push({name: 'view'});
// The name tag should not be required.
var nameTag = _.find(tagDefs, {name: 'name'});
nameTag.required = false;
config.set('processing.tagDefinitions', tagDefs);
// OutputPath for docs that do not already have them.
config.set('rendering.contentsFolder',
path.resolve(config.basePath, 'build'));
// Base path is the protractor root dir.
var basePath = path.resolve(packagePath, '..');
// Generate documentation for protractor, locators, and webdriver.
var _ = require('lodash');
var path = require('path');
var Package = require('dgeni').Package;
var jsDocProcessor = require('dgeni-packages/jsdoc');
// Configure the tags that will be parsed from the jsDoc.
jsDocProcessor.config(function(parseTagsProcessor) {
var tagDefs = parseTagsProcessor.tagDefinitions;
// Parse the following annotations.
tagDefs.push({name: 'alias'});
tagDefs.push({name: 'augments'});
tagDefs.push({name: 'deprecated'});
tagDefs.push({name: 'example'});
tagDefs.push({name: 'extends'});
tagDefs.push({name: 'external'});
tagDefs.push({name: 'private'});
tagDefs.push({name: 'type'});
tagDefs.push({name: 'view'});
tagDefs.push({name: 'template'});
tagDefs.push({name: 'fileoverview'});
tagDefs.push({name: 'const'});
tagDefs.push({name: 'throws'});
return docs.filter(doc => {
const isPublic = isPublicDoc(doc);
// Update the API document name in case the "@docs-public" tag is used
// with an alias name.
if (isPublic && doc instanceof ApiDoc.BaseApiDoc) {
const docsPublicTag = getDocsPublicTag(doc);
if (docsPublicTag !== undefined && docsPublicTag.description) {
doc.name = docsPublicTag.description;
}
}
// Filter out private class members which could be annotated
// with the "@docs-private" tag.
if (isPublic && doc instanceof ClassExportDoc.ClassExportDoc) {
doc.members = doc.members.filter(memberDoc => isPublicDoc(memberDoc));
}
return isPublic;
});
}
docs.forEach(doc => {
if (!(doc instanceof ExportDoc.ExportDoc)) {
return;
}
// Check for Dgeni documents that refer to the same TypeScript symbol. Those can be
// considered as duplicates of the current document.
const similarDocs = docs.filter(d => d.symbol === doc.symbol);
if (similarDocs.length > 1) {
// If there are multiple docs that refer to the same TypeScript symbol, but have a
// different name than the resolved symbol, we can remove those documents, since they
// are just aliasing an already existing export.
similarDocs.filter(d => d.symbol.name !== d.name).forEach(d => duplicates.add(d));
const docsWithSameName = similarDocs.filter(d => d.symbol.name === d.name);
// If there are multiple docs that refer to the same TypeScript symbol and have
// the same name, we need to remove all of those duplicates except one.
if (docsWithSameName.length > 1) {
docsWithSameName.slice(1).forEach(d => duplicates.add(d));
}
function isProperty(doc) {
if (doc instanceof PropertyMemberDoc.PropertyMemberDoc ||
// The latest Dgeni version no longer treats getters or setters as properties.
// From a user perspective, these are still properties and should be handled the same
// way as normal properties.
(!isMethod(doc) && (doc.isGetAccessor || doc.isSetAccessor))) {
return !isGenericTypeParameter(doc);
}
return false;
}
function isDirective(doc) {
function isGenericTypeParameter(doc) {
if (doc.containerDoc instanceof ClassExportDoc.ClassExportDoc) {
return doc.containerDoc.typeParams && `<${doc.name}>` === doc.containerDoc.typeParams;
}
return false;
}
function isProperty(doc) {
function isPublicDoc(doc) {
if (_isEnforcedPublicDoc(doc)) {
return true;
}
if (_hasDocsPrivateTag(doc) || doc.name.startsWith('_')) {
return false;
}
else if (doc instanceof MemberDoc.MemberDoc) {
return !_isInternalMember(doc);
}
return true;
}
/** Gets the @docs-public tag from the given document if present. */