docs(badges): add badges in hero to identify doc type to viewer, and stability. Stylize var.template for new api style docs. Add stable, experimental, docsNotRequired tagdef in dgeni

This commit is contained in:
Eric Jimenez 2016-04-18 15:57:16 -04:00 committed by Naomi Black
parent 258014c9de
commit c934fb704f
10 changed files with 127 additions and 18 deletions

View File

@ -1,14 +1,28 @@
- var textFormat = '' // Refer to jade.template.html and addJadeDataDocsProcessor to figure out where the context of this jade file originates
- var textFormat = '';
- var headerTitle = title + (typeof varType !== 'undefined' ? (': ' + varType) : ''); - var headerTitle = title + (typeof varType !== 'undefined' ? (': ' + varType) : '');
- var capitalize = function capitalize(str) { return str.charAt(0).toUpperCase() + str.slice(1); }
- var useBadges = docType || stability;
if current.path[4] && current.path[3] == 'api' if current.path[4] && current.path[3] == 'api'
- var textFormat = 'is-standard-case' - var textFormat = 'is-standard-case'
header(class="hero background-sky") header(class="hero background-sky")
h1(class="hero-title text-display-1 #{textFormat}") #{headerTitle} span(class="hero-title-with-badges" layout="row" layout-align="start center")
h1(class="hero-title text-display-1 #{textFormat}") #{headerTitle}
if useBadges
span(class="badges")
if docType
span(class="status-badge").
#{capitalize(docType)}
if stability
span(layout="row" class="status-badge")
// badge circle is filled based on stability by matching a css selector in _hero.scss
span(class="status-circle status-#{stability}")
span Stability: #{capitalize(stability)}
if subtitle if subtitle
h2.hero-subtitle.text-subhead #{subtitle} h2.hero-subtitle.text-subhead #{subtitle}
else if current.path[0] == "docs" else if current.path[0] == "docs"
!= partial("_version-dropdown") != partial("_version-dropdown")

View File

@ -9,7 +9,7 @@
background: #1976D2; background: #1976D2;
box-shadow: none; box-shadow: none;
// temporary hack to remove space between example title and code-example // temporary hack to remove space between example title and code-example
margin-bottom: -18px; margin-bottom: -5px;
z-index: 1; z-index: 1;
position: relative; position: relative;
border-bottom-right-radius: 0; border-bottom-right-radius: 0;

View File

@ -1,15 +1,44 @@
$hero-padding: ($unit * 10) ($unit * 6) ($unit * 5); $hero-padding: ($unit * 10) ($unit * 6) ($unit * 7);
.hero { .hero {
position: relative; position: relative;
padding: $hero-padding; padding: $hero-padding;
height: $unit * 8; height: $unit * 10;
.hero-title-with-badges {
margin-bottom: $unit;
}
.status-circle {
margin-right: 4px;
border-radius: 50%;
width: 10px;
height: 10px;
display: inline-block;
}
// status-*, will be matched by the results in addJadeDataDocsProcessor.js, and reflect in _hero.jade
.status-deprecated {
background: #E53935;
}
.status-stable {
background: #558b2f;
}
.status-experimental {
background: #9575cd;
}
@media handheld and (max-width: $phone-breakpoint), @media handheld and (max-width: $phone-breakpoint),
screen and (max-device-width: $phone-breakpoint), screen and (max-device-width: $phone-breakpoint),
screen and (max-width: $tablet-breakpoint) { screen and (max-width: $tablet-breakpoint) {
height: auto; height: auto;
padding-top: 40px; padding-top: 40px;
.badges {
margin-top: 48px;
}
} }
&.is-large { &.is-large {
@ -24,7 +53,28 @@ $hero-padding: ($unit * 10) ($unit * 6) ($unit * 5);
} }
} }
.badges {
padding-left: 8px;
.status-badge {
color: #0143A3;
margin-left: 4px;
padding-left: 8px;
padding-right: 8px;
background-color: rgba(255,255,255,0.5);
border-radius: 2px;
line-height: 20px;
display: inline-block;
}
}
button {
// Override md-button from angular material to align language select with hero title.
margin: 0 !important;
}
.hero-title { .hero-title {
display: inline; // title will be inline with badges
text-transform: uppercase; text-transform: uppercase;
margin: 0; margin: 0;
opacity: .87; opacity: .87;
@ -93,4 +143,4 @@ $hero-padding: ($unit * 10) ($unit * 6) ($unit * 5);
display: block; display: block;
} }
} }
} }

View File

@ -58,12 +58,32 @@ module.exports = function addJadeDataDocsProcessor() {
// GET DATA FOR EACH PAGE (CLASS, VARS, FUNCTIONS) // GET DATA FOR EACH PAGE (CLASS, VARS, FUNCTIONS)
var modulePageInfo = _(doc.exports) var modulePageInfo = _(doc.exports)
.map(function(exportDoc) { .map(function(exportDoc) {
// STABILITY STATUS
// Supported tags:
// @stable
// @experimental
// @deprecated
// Default is the empty string (no badge)
// Do not capitalize the strings, they are intended for use in constructing a css class from _hero.scss
// and used in _hero.jade
var stability = '';
if (_.has(exportDoc, 'stable')) {
stability = 'stable';
} else if (_.has(exportDoc, 'experimental')) {
stability = 'experimental';
} else if (_.has(exportDoc, 'deprecated')) {
stability = 'deprecated';
}
var dataDoc = { var dataDoc = {
name: exportDoc.name + '-' + exportDoc.docType, name: exportDoc.name + '-' + exportDoc.docType,
title: exportDoc.name, title: exportDoc.name,
docType: exportDoc.docType, docType: exportDoc.docType,
exportDoc: exportDoc exportDoc: exportDoc,
stability: stability
}; };
if (exportDoc.symbolTypeName) dataDoc.varType = titleCase(exportDoc.symbolTypeName); if (exportDoc.symbolTypeName) dataDoc.varType = titleCase(exportDoc.symbolTypeName);
if (exportDoc.originalModule) dataDoc.originalModule = exportDoc.originalModule; if (exportDoc.originalModule) dataDoc.originalModule = exportDoc.originalModule;
return dataDoc; return dataDoc;

View File

@ -0,0 +1,5 @@
module.exports = function() {
return {
name: 'docsNotRequired'
};
};

View File

@ -0,0 +1,5 @@
module.exports = function() {
return {
name: 'experimental'
};
};

View File

@ -2,5 +2,8 @@ module.exports = [
require('./deprecated'), require('./deprecated'),
require('./howToUse'), require('./howToUse'),
require('./whatItDoes'), require('./whatItDoes'),
require('./internal') require('./internal'),
require('./stable'),
require('./experimental'),
require('./docsNotRequired'),
]; ];

View File

@ -0,0 +1,5 @@
module.exports = function() {
return {
name: 'stable'
};
};

View File

@ -1,3 +1,4 @@
{# Use this document to generate the _data.json files for harp.js. This acts as the link between dgeni, jade, and harp #}
{ {
{%- for item in doc.data %} {%- for item in doc.data %}
"{$ item.name $}" : { "{$ item.name $}" : {
@ -11,6 +12,9 @@
{%- if item.originalModule %} {%- if item.originalModule %}
"originalModule" : "{$ item.originalModule $}", "originalModule" : "{$ item.originalModule $}",
{%- endif %} {%- endif %}
{%- if item.stability %}
"stability" : "{$ item.stability $}",
{%- endif %}
"docType": "{$ item.docType $}" "docType": "{$ item.docType $}"
}{% if not loop.last %},{% endif %} }{% if not loop.last %},{% endif %}
{% endfor -%} {% endfor -%}

View File

@ -4,20 +4,23 @@
{% block body %} {% block body %}
include {$ relativePath(doc.path, '_util-fns') $} include {$ relativePath(doc.path, '_util-fns') $}
.l-main-section
h2(class="variable export") .div(layout="row" layout-xs="column" class="row-margin")
pre.prettyprint div(flex="20" flex-xs="100")
h2 Variable Export
div(flex="80" flex-xs="100")
pre.prettyprint.no-bg
code. code.
export {$ doc.name $}{$ returnType(doc.returnType) $} export {$ doc.name $}{$ returnType(doc.returnType) $}
p.location-badge. p.location-badge.
exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} } exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} }
defined in {$ githubViewLink(doc) $} defined in {$ githubViewLink(doc) $}
:marked :marked
{%- if doc.notYetDocumented %} {%- if doc.notYetDocumented %}
*Not Yet Documented* *Not Yet Documented*
{% else %} {% else %}
{$ doc.description | indentForMarkdown(4) | trimBlankLines $} {$ doc.description | indentForMarkdown(2) | trimBlankLines $}
{% endif -%} {% endif -%}
{% endblock %} {% endblock %}