Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 3339c4b

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

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

website/js/api-controller.js

+24-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,30 @@
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;
175+
176+
if(shortDescription.substr(0, 3) == 'See') {
177+
console.log(item.description + ' -> ' + shortDescription);
178+
console.log([sentenceEnd, paragraphEnd, item.description.length]);
179+
}
158180
}
159181
});
160182

website/js/directives.js

+5
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

+1-1
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)