diff --git a/aio/tools/transforms/angular-api-package/index.js b/aio/tools/transforms/angular-api-package/index.js index a87aed7810..216b09f29b 100644 --- a/aio/tools/transforms/angular-api-package/index.js +++ b/aio/tools/transforms/angular-api-package/index.js @@ -24,6 +24,7 @@ module.exports = new Package('angular-api', [basePackage, typeScriptPackage]) .processor(require('./processors/markBarredODocsAsPrivate')) .processor(require('./processors/filterPrivateDocs')) .processor(require('./processors/computeSearchTitle')) + .processor(require('./processors/simplifyMemberAnchors')) // Where do we get the source files? .config(function(readTypeScriptModules, readFilesProcessor, collectExamples) { diff --git a/aio/tools/transforms/angular-api-package/processors/simplifyMemberAnchors.js b/aio/tools/transforms/angular-api-package/processors/simplifyMemberAnchors.js new file mode 100644 index 0000000000..2519d22870 --- /dev/null +++ b/aio/tools/transforms/angular-api-package/processors/simplifyMemberAnchors.js @@ -0,0 +1,26 @@ +/** + * Members that have overloads get long unwieldy anchors because they must be distinguished + * by their parameter lists. + * But the primary overload doesn't not need this distinction, so can just be the name of the member. + */ +module.exports = function simplifyMemberAnchors() { + return { + $runAfter: ['extra-docs-added'], + $runBefore: ['computing-paths'], + $process: function(docs) { + return docs.forEach(doc => { + if (doc.members) { + doc.members.forEach(member => member.anchor = computeAnchor(member)); + } + if (doc.statics) { + doc.statics.forEach(member => member.anchor = computeAnchor(member)); + } + }); + } + }; +}; + +function computeAnchor(member) { + // if the member is a "call" type then it has no name + return encodeURI(member.name.trim() || 'call'); +}