Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 0cc9ad2

Browse files
petebacondarwinwardbell
authored andcommitted
fix(api-builder): tighten up check for decorator (#3369)
1 parent 9386a66 commit 0cc9ad2

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

tools/api-builder/angular.io-package/processors/addJadeDataDocsProcessor.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,27 @@ function processExportDoc(exportDoc) {
3838
stability = 'deprecated';
3939
exportDoc.showDeprecatedNotes = true;
4040
}
41-
41+
4242
var howToUse = '';
4343
if(_.has(exportDoc, 'howToUse')) {
4444
var howToUseArray = exportDoc.tags.tags.filter(function(tag) {
4545
return tag.tagName === 'howToUse'
4646
});
47-
47+
4848
// Remove line breaks, there should only be one tag
4949
howToUse = howToUseArray[0].description.replace(/(\r\n|\n|\r)/gm," ");
5050
}
51-
51+
5252
var whatItDoes = '';
5353
if(_.has(exportDoc, 'whatItDoes')) {
5454
var whatItDoesArray = exportDoc.tags.tags.filter(function(tag) {
5555
return tag.tagName === 'whatItDoes'
5656
});
57-
57+
5858
// Remove line breaks, there should only be one tag
5959
whatItDoes = whatItDoesArray[0].description.replace(/(\r\n|\n|\r)/gm," ");
6060
}
61-
61+
6262
// SECURITY STATUS
6363
// Supported tags:
6464
// @security
@@ -68,13 +68,13 @@ function processExportDoc(exportDoc) {
6868
var securityArray = exportDoc.tags.tags.filter(function(tag) {
6969
return tag.tagName === 'security'
7070
});
71-
71+
7272
// Remove line breaks, there should only be one tag
7373
security = securityArray[0].description.replace(/(\r\n|\n|\r)/gm," ");
74-
74+
7575
exportDoc.showSecurityNotes = true;
7676
}
77-
77+
7878
return {stability: stability, howToUse: howToUse, whatItDoes: whatItDoes, security: security};
7979
}
8080

@@ -110,7 +110,7 @@ module.exports = function addJadeDataDocsProcessor() {
110110
*
111111
* Modules must be public and have content
112112
*/
113-
113+
114114
_.forEach(docs, function(doc) {
115115
if (doc.docType === 'module' && !doc.internal && doc.exports.length) {
116116
modules.push(doc);
@@ -124,15 +124,15 @@ module.exports = function addJadeDataDocsProcessor() {
124124
intro: doc.description.replace('"', '\"').replace(/\s*(\r?\n|\r)\s*/g," "),
125125
docType: 'module'
126126
}];
127-
127+
128128
var decorators = {};
129-
129+
130130
// GET DATA FOR EACH PAGE (CLASS, VARS, FUNCTIONS)
131131
var modulePageInfo = _(doc.exports)
132132
.map(function(exportDoc) {
133133
// if it ends with "Decorator", we store it in the map
134134
// to later merge with the token
135-
if (exportDoc.name.endsWith("Decorator")) {
135+
if (exportDoc.name.endsWith("Decorator") && exportDoc.callMember) {
136136
var p = processExportDoc(exportDoc.callMember);
137137
decorators[exportDoc.name] = {
138138
stability : p.stability,
@@ -146,7 +146,7 @@ module.exports = function addJadeDataDocsProcessor() {
146146

147147
} else {
148148
var p = processExportDoc(exportDoc);
149-
149+
150150
// Data inserted into jade-data.template.html
151151
var dataDoc = {
152152
name: exportDoc.name + '-' + exportDoc.docType,
@@ -158,23 +158,23 @@ module.exports = function addJadeDataDocsProcessor() {
158158
whatItDoes: p.whatItDoes,
159159
security: p.security
160160
};
161-
161+
162162
if (exportDoc.symbolTypeName) dataDoc.varType = titleCase(exportDoc.symbolTypeName);
163163
if (exportDoc.originalModule) dataDoc.originalModule = exportDoc.originalModule;
164-
164+
165165
return dataDoc;
166166
}
167167
})
168168
.filter(function(s) { return !!s; }) // filter out all null values
169169
.sortBy('name')
170170
.value();
171-
171+
172172
// find a matching symbol for every decorator item
173173
// and merge the data
174174
_.forEach(Object.keys(decorators), function(name) {
175175
var varToken = name.split("Decorator")[0];
176176
var c = modulePageInfo.filter(function(n) { return n.exportDoc.name === varToken; });
177-
177+
178178
c[0].docType = decorators[name].docType;
179179
Object.assign(c[0].exportDoc, decorators[name]);
180180
});

0 commit comments

Comments
 (0)