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

Commit 3dd114d

Browse files
Eric Jimeneznaomiblack
Eric Jimenez
authored andcommitted
docs(class overview): list instance and static members with in-page hyperlinks. Also link constructor when present. Focus member on click. Badges look better in viewports of 600px or less
1 parent 9b9e6dd commit 3dd114d

File tree

8 files changed

+129
-21
lines changed

8 files changed

+129
-21
lines changed

public/_includes/_hero.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if current.path[4] && current.path[3] == 'api'
88
- var textFormat = 'is-standard-case'
99

1010
header(class="hero background-sky")
11-
span(class="hero-title-with-badges" layout="row" layout-align="start center")
11+
span(class="hero-title-with-badges" layout="row" layout-xs="column" layout-align="start center" layout-align-xs="start start")
1212
h1(class="hero-title text-display-1 #{textFormat}") #{headerTitle}
1313
if useBadges
1414
span(class="badges")

public/resources/css/base/_type.scss

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ p code {
110110
opacity: 0.87;
111111
}
112112
h2 {
113-
font-size: 15px;
114-
text-transform: uppercase;
115-
color: #78909C;
113+
font-size: 20px;
116114
}
117115
h3 {
118116
font-size: 16px;

public/resources/css/module/_api.scss

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,32 @@ input.api-filter {
7676
}
7777

7878
.docs-content {
79+
.anchor-offset {
80+
display: block;
81+
position: relative;
82+
top: -250px;
83+
visibility: hidden;
84+
}
85+
86+
.anchor-focused {
87+
background-color: transparent !important;
88+
89+
-moz-animation: fade 1s linear; /* Firefox */
90+
-webkit-animation: fade 1s linear; /* Safari and Chrome */
91+
-o-animation: fade 1s linear; /* Opera */
92+
animation: fade 1s linear;
93+
}
94+
95+
@keyframes fade {
96+
0% { background-color: $sunshine }
97+
}
98+
99+
.h2-api-docs {
100+
font-size: 15px !important;
101+
text-transform: uppercase !important;
102+
color: #78909C !important;
103+
}
104+
79105
.api-list {
80106
list-style: none;
81107
padding: 0 0 ($unit * 4);
@@ -113,7 +139,7 @@ input.api-filter {
113139
color: #1a2326;
114140

115141
&.selector {
116-
margin: 0 0 8px 0;
142+
margin: 0;
117143
}
118144

119145
&.location-badge {
@@ -155,6 +181,32 @@ input.api-filter {
155181
padding: 0;
156182
}
157183

184+
.no-bg-with-indent {
185+
padding-top: 0;
186+
padding-bottom: 0;
187+
padding-left: 16px;
188+
margin-top: 6px;
189+
margin-bottom: 0;
190+
background: none;
191+
}
192+
193+
.code-background {
194+
padding: 0 5px 0;
195+
196+
span.pln {
197+
color: #1E88E5 !important;
198+
}
199+
}
200+
201+
.code-anchor {
202+
cursor: pointer;
203+
text-decoration: none;
204+
205+
&:hover {
206+
text-decoration: underline;
207+
}
208+
}
209+
158210
code {
159211
font-size: 14px;
160212
color: #1a2326;

public/resources/css/module/_hero.scss

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $hero-padding: ($unit * 10) ($unit * 6) ($unit * 7);
3737
padding-top: 40px;
3838

3939
.badges {
40-
margin-top: 48px;
40+
margin-top: $unit * 6;
4141
}
4242
}
4343

@@ -65,6 +65,21 @@ $hero-padding: ($unit * 10) ($unit * 6) ($unit * 7);
6565
border-radius: 2px;
6666
line-height: 20px;
6767
display: inline-block;
68+
69+
&:first-child {
70+
margin-left: 0;
71+
}
72+
}
73+
}
74+
75+
@media screen and (max-width: 599px) {
76+
.badges {
77+
margin-top: $unit;
78+
padding-left: 0;
79+
}
80+
81+
.hero-title-with-badges {
82+
margin-bottom: $unit * 2;
6883
}
6984
}
7085

public/resources/js/controllers/app-controller.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ angularIO.controller('AppCtrl', ['$mdDialog', '$timeout', '$http', '$sce', funct
3434
userfeedback.api.startFeedback(configuration);
3535
};
3636

37+
// URL hash keeps track of which method the user wants to view in the API doc.
38+
// Refer to _api.scss (.anchor-focused) and class.template.html (where ng-class is used) for details.
39+
vm.isApiDocMemberFocused = function(memberName) {
40+
var apiDocFocusedMember = window.location.hash.replace('#!#', '').replace('-anchor', '');
41+
return apiDocFocusedMember === memberName;
42+
};
43+
3744
/*
3845
* Prettify Code
3946
*

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

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
.div(layout="row" layout-xs="column" class="row-margin")
99
div(flex="20" flex-xs="100")
10-
h2 What it does
10+
h2(class="h2-api-docs") What it does
1111
div(flex="80" flex-xs="100")
1212
:marked
1313
{%- if doc.whatItDoes %}
@@ -18,7 +18,7 @@
1818

1919
.div(layout="row" layout-xs="column" class="row-margin")
2020
div(flex="20" flex-xs="100")
21-
h2 How to use
21+
h2(class="h2-api-docs") How to use
2222
div(flex="80" flex-xs="100")
2323
:marked
2424
{%- if doc.howToUse %}
@@ -27,12 +27,46 @@
2727
*Not yet documented*
2828
{% endif %}
2929

30+
.div(class="row-margin" layout="row" layout-xs="column")
31+
div(flex="20" flex-xs="100")
32+
h2(class="h2-api-docs") Class Overview
33+
div(flex="80" flex-xs="100")
34+
code.no-bg class {$ doc.name $} {
35+
36+
{% if doc.statics.length %}
37+
.div(layout="column")
38+
{% for member in doc.statics %}{% if not member.internal %}
39+
pre(class="prettyprint no-bg" ng-class="{ 'anchor-focused': appCtrl.isApiDocMemberFocused('{$ member.name $}') }")
40+
a(class="code-anchor" href="#{$ member.name $}-anchor")
41+
code(class="code-background") {$ member.name | indent(6, false) | trim $}
42+
code {$ paramList(member.parameters) | indent(8, false) | trim $}{$ returnType(member.returnType) $}
43+
{% endif %}{% endfor %}
44+
{% endif %}
45+
{% if doc.constructorDoc.name %}
46+
.div(layout="column")
47+
pre(class="prettyprint no-bg-with-indent")
48+
a(class="code-anchor" href="#constructor")
49+
code(class="code-background") {$ doc.constructorDoc.name $}
50+
code {$ paramList(doc.constructorDoc.parameters) | indent(8, false) | trim $}
51+
{% endif %}
52+
{% if doc.members.length %}
53+
.div(layout="column")
54+
{% for member in doc.members %}{% if not member.internal %}
55+
pre(class="prettyprint no-bg-with-indent")
56+
a(class="code-anchor" href="#{$ member.name $}-anchor")
57+
code(class="code-background") {$ member.name | indent(6, false) | trim $}
58+
code {$ paramList(member.parameters) | indent(8, false) | trim $}{$ returnType(member.returnType) $}
59+
{% endif %}{% endfor %}
60+
{% endif %}
61+
p.selector
62+
code.no-bg }
63+
3064
{% block additional %}
3165
{% endblock %}
3266

3367
.div(class="row-margin" layout="row" layout-xs="column")
3468
div(flex="20" flex-xs="100")
35-
h2 Class Description
69+
h2(class="h2-api-docs") Class Description
3670
div(class="class-description-content" flex="80" flex-xs="100")
3771
:marked
3872
{%- if doc.description.length > 2 %}
@@ -43,7 +77,7 @@
4377

4478
.div(layout="row" layout-xs="column" class="row-margin")
4579
div(flex="20" flex-xs="100")
46-
h2 Class Export
80+
h2(class="h2-api-docs") Class Export
4781
div(flex="80" flex-xs="100")
4882
pre.prettyprint.no-bg
4983
code.no-pln.
@@ -53,7 +87,7 @@
5387
{% block annotations %}
5488
.div(layout="row" layout-xs="column" class="row-margin")
5589
div(flex="20" flex-xs="100")
56-
h2 Annotations
90+
h2(class="h2-api-docs") Annotations
5791
div(flex="80" flex-xs="100")
5892
{%- for decorator in doc.decorators %}
5993
pre.prettyprint.no-bg
@@ -72,9 +106,10 @@
72106
{%- if doc.constructorDoc and not doc.constructorDoc.internal %}
73107
.div(layout="row" layout-xs="column" class="row-margin")
74108
div(flex="20" flex-xs="100")
75-
h2 Constructor
109+
h2(class="h2-api-docs") Constructor
76110
div(flex="80" flex-xs="100")
77-
pre.prettyprint.no-bg
111+
a(name="constructor" class="anchor-offset")
112+
pre(class="prettyprint no-bg" ng-class="{ 'anchor-focused': appCtrl.isApiDocMemberFocused('{$ doc.constructorDoc.name $}') }")
78113
code.
79114
{$ doc.constructorDoc.name $}{$ paramList(doc.constructorDoc.parameters) | indent(8, false) | trim $}
80115
:marked
@@ -88,7 +123,7 @@
88123
{% if doc.statics.length %}
89124
.div(layout="row" layout-xs="column" class="row-margin")
90125
div(flex="20" flex-xs="100")
91-
h2 Static Members
126+
h2(class="h2-api-docs") Static Members
92127
div(flex="80" flex-xs="100")
93128
{% for member in doc.statics %}{% if not member.internal %}
94129
pre.prettyprint.no-bg
@@ -111,10 +146,11 @@
111146
{% if doc.members.length %}
112147
.div(layout="row" layout-xs="column" class="instance-members" class="row-margin")
113148
div(flex="20" flex-xs="100")
114-
h2 Instance Members
149+
h2(class="h2-api-docs") Class Details
115150
div(flex="80" flex-xs="100")
116151
{% for member in doc.members %}{% if not member.internal %}
117-
pre.prettyprint.no-bg
152+
a(name="{$ member.name $}-anchor" class="anchor-offset")
153+
pre(class="prettyprint no-bg" ng-class="{ 'anchor-focused': appCtrl.isApiDocMemberFocused('{$ member.name $}') }")
118154
code.
119155
{$ member.name $}{$ paramList(member.parameters) | indent(8, false) | trim $}{$ returnType(member.returnType) $}
120156

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{%- if doc.directiveOptions.selector.split(',').length %}
1111
.div(layout="row" layout-xs="column" class="row-margin")
1212
div(flex="20" flex-xs="100")
13-
h2 Selectors
13+
h2(class="h2-api-docs") Selectors
1414
div(flex="80" flex-xs="100")
1515
{% for selector in doc.directiveOptions.selector.split(',') %}
1616
p.selector
@@ -21,7 +21,7 @@
2121
{% if doc.outputs %}
2222
.div(layout="row" layout-xs="column" class="row-margin")
2323
div(flex="20" flex-xs="100")
24-
h2 Outputs
24+
h2(class="h2-api-docs") Outputs
2525
div(flex="80" flex-xs="100")
2626
{% for binding, property in doc.outputs %}
2727
div(class="code-margin")
@@ -36,7 +36,7 @@
3636
{% if doc.inputs %}
3737
.div(layout="row" layout-xs="column" class="row-margin")
3838
div(flex="20" flex-xs="100")
39-
h2 Inputs
39+
h2(class="h2-api-docs") Inputs
4040
div(flex="80" flex-xs="100")
4141
{% for binding, property in doc.inputs %}
4242
div(class="code-margin")
@@ -51,7 +51,7 @@
5151
{%- if doc.directiveOptions.exportAs %}
5252
.div(layout="row" layout-xs="column" class="row-margin")
5353
div(flex="20" flex-xs="100")
54-
h2 Exported as
54+
h2(class="h2-api-docs") Exported as
5555
div(flex="80" flex-xs="100")
5656
p.input
5757
code {$ doc.directiveOptions.exportAs $}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
.div(layout="row" layout-xs="column" class="row-margin")
99
div(flex="20" flex-xs="100")
10-
h2 Variable Export
10+
h2(class="h2-api-docs") Variable Export
1111
div(flex="80" flex-xs="100")
1212
pre.prettyprint.no-bg
1313
code.

0 commit comments

Comments
 (0)