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

Commit b5d2973

Browse files
Eric Jimeneznaomiblack
authored andcommitted
feat(security badge): add a security badge to api docs. Only appears if @security is present in angular2
1 parent 96238bb commit b5d2973

File tree

6 files changed

+34
-2
lines changed

6 files changed

+34
-2
lines changed

public/_includes/_hero.jade

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ header(class="hero background-sky")
2020
// badge circle is filled based on stability by matching a css selector in _hero.scss
2121
span(class="status-circle status-#{stability}")
2222
span Stability: #{capitalize(stability)}
23+
if security
24+
span(class="status-badge security-risk-badge").
25+
Security Risk
2326

2427
if subtitle
2528
h2.hero-subtitle.text-subhead #{subtitle}

public/resources/css/module/_hero.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,18 @@ $hero-padding: ($unit * 10) ($unit * 6) ($unit * 7);
8383
margin-left: 0;
8484
}
8585
}
86+
87+
.security-risk-badge {
88+
background-color: #FFF59D;
89+
}
8690
}
8791

8892
@media screen and (max-width: 599px) {
93+
/* three items */
94+
.badges .status-badge:nth-child(3) {
95+
margin-left: 0;
96+
margin-top: 4px;
97+
}
8998

9099
.hero-title-with-badges {
91100
margin-bottom: $unit * 2;

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module.exports = function addJadeDataDocsProcessor() {
7575
} else if (_.has(exportDoc, 'deprecated')) {
7676
stability = 'deprecated';
7777
}
78-
78+
7979
var howToUse = '';
8080
if(_.has(exportDoc, 'howToUse')) {
8181
var howToUseArray = exportDoc.tags.tags.filter(function(tag) {
@@ -96,14 +96,25 @@ module.exports = function addJadeDataDocsProcessor() {
9696
whatItDoes = whatItDoesArray[0].description.replace(/(\r\n|\n|\r)/gm,"");
9797
}
9898

99+
// SECURITY STATUS
100+
// Supported tags:
101+
// @security
102+
// Default is no security risk assessed for api
103+
var security = false;
104+
if (_.has(exportDoc, 'security')) {
105+
security = true;
106+
}
107+
108+
// Data inserted into jade-data.template.html
99109
var dataDoc = {
100110
name: exportDoc.name + '-' + exportDoc.docType,
101111
title: exportDoc.name,
102112
docType: exportDoc.docType,
103113
exportDoc: exportDoc,
104114
stability: stability,
105115
howToUse: howToUse,
106-
whatItDoes: whatItDoes
116+
whatItDoes: whatItDoes,
117+
security: security
107118
};
108119

109120
if (exportDoc.symbolTypeName) dataDoc.varType = titleCase(exportDoc.symbolTypeName);

tools/api-builder/angular.io-package/tag-defs/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ module.exports = [
66
require('./stable'),
77
require('./experimental'),
88
require('./docsNotRequired'),
9+
require('./security'),
910
];
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = function() {
2+
return {
3+
name: 'security'
4+
};
5+
};

tools/api-builder/angular.io-package/templates/jade-data.template.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
{%- if item.stability %}
1616
"stability" : "{$ item.stability $}",
1717
{%- endif %}
18+
{%- if item.security %}
19+
"security" : "{$ item.security $}",
20+
{%- endif %}
1821
"docType": "{$ item.docType $}"
1922
}{% if not loop.last %},{% endif %}
2023
{% endfor -%}

0 commit comments

Comments
 (0)