Skip to content

Commit 64c4ee3

Browse files
committed
chore(website): Fix parsing of summaries in function list
Still not a great solution. See "locator" in #/api?view=ElementFinder fixes angular#2486
1 parent b506aac commit 64c4ee3

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

website/js/api-controller.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,25 @@
153153

154154
// Add short description.
155155
if (item.description) {
156-
item.shortDescription =
157-
item.description.substring(0., item.description.indexOf('.') + 1);
156+
// Find the correct portion of the description
157+
158+
// The following parsing is OK most of the time
159+
var sentenceEnd = item.description.indexOf('.') + 1 || Infinity;
160+
var paragraphEnd = item.description.indexOf('</p>') + 4;
161+
if (paragraphEnd == 3) {
162+
paragraphEnd = Infinity
163+
}
164+
var shortDescription = item.description.substring(0, Math.min(
165+
item.description.length, sentenceEnd, paragraphEnd)).trim();
166+
167+
// Remove <p> tags
168+
if (shortDescription.substr(0,3) == '<p>') {
169+
shortDescription = shortDescription.substr(3);
170+
if (shortDescription.substr(-4) == '</p>') {
171+
shortDescription = shortDescription.substr(0, shortDescription.length - 4);
172+
}
173+
}
174+
item.shortDescription = shortDescription;
158175
}
159176
});
160177

@@ -201,7 +218,6 @@
201218

202219
var addItemToList = function(item, depth) {
203220
if (item.inList) {
204-
console.log(item.name);
205221
return;
206222
}
207223
item.treeClasses = 'depth-' + depth;
@@ -217,7 +233,6 @@
217233
});
218234
}
219235
if (item.extends) {
220-
console.log(item.base.name);
221236
var parent = self.itemsByName[item.base.name];
222237
if (parent != null) {
223238
addItemToList(parent, depth + 1);

website/js/directives.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@
5656
scope: {
5757
list: '=ptorFunctionList'
5858
},
59+
controller: function($scope, $sce) {
60+
$scope.trust = function(html) {
61+
return $sce.trustAsHtml(html);
62+
};
63+
},
5964
templateUrl: 'partials/ptor-function-list.html'
6065
};
6166
});

website/partials/ptor-function-list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
ng-bind="item.displayName">
1515
</a>
1616
</td>
17-
<td ng-bind="item.shortDescription"></td>
17+
<td ng-bind-html="trust(item.shortDescription)"></td>
1818
</tr>
1919
</tbody>
2020
</table>

0 commit comments

Comments
 (0)