build(aio): simplify the primary overload's anchor
The primary link to a member should simply be its name, and not require the parameter list.
This commit is contained in:
parent
a301dba68f
commit
ffda3e41e0
|
@ -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) {
|
||||
|
|
26
aio/tools/transforms/angular-api-package/processors/simplifyMemberAnchors.js
vendored
Normal file
26
aio/tools/transforms/angular-api-package/processors/simplifyMemberAnchors.js
vendored
Normal file
|
@ -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');
|
||||
}
|
Loading…
Reference in New Issue