Skip to content

Commit 1da2b70

Browse files
authored
chore: add additional structure to generated docs (#3985)
* For API docs, wrap each generated document in `.docs-api` * For markdown docs, wrap each generated document in `.docs-markdown` * Remove the `h1` from API docs that contained only the component name * Change the `h2` for API docs to be a friendlier title followed by an example import. * Increase header level for API by one across the board (so that they're "under" the new `h2`) * A few misc. docs fixes
1 parent b1e5ff6 commit 1da2b70

File tree

8 files changed

+64
-60
lines changed

8 files changed

+64
-60
lines changed

src/lib/input/autosize.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,21 @@ import {Directive, ElementRef, Input, OnInit} from '@angular/core';
1515
},
1616
})
1717
export class MdTextareaAutosize implements OnInit {
18-
/** Minimum number of rows for this textarea. */
18+
/** @deprecated Use mdAutosizeMinRows */
1919
@Input() minRows: number;
2020

21-
get mdAutosizeMinRows(): number {
22-
return this.minRows;
23-
}
24-
25-
@Input() set mdAutosizeMinRows(value: number) {
26-
this.minRows = value;
27-
}
21+
/** Minimum number of rows for this textarea. */
22+
@Input()
23+
get mdAutosizeMinRows(): number { return this.minRows; }
24+
set mdAutosizeMinRows(value: number) { this.minRows = value; }
2825

29-
/** Maximum number of rows for this textarea. */
26+
/** @deprecated Use mdAutosizeMaxRows */
3027
@Input() maxRows: number;
3128

32-
get mdAutosizeMaxRows(): number {
33-
return this.maxRows;
34-
}
35-
36-
@Input() set mdAutosizeMaxRows(value: number) {
37-
this.maxRows = value;
38-
}
29+
/** Minimum number of rows for this textarea. */
30+
@Input()
31+
get mdAutosizeMaxRows(): number { return this.maxRows; }
32+
set mdAutosizeMaxRows(value: number) { this.maxRows = value; }
3933

4034
/** Cached height of a textarea with a single row. */
4135
private _cachedLineHeight: number;

src/lib/input/input-container.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ let nextUniqueId = 0;
5858
export class MdPlaceholder {}
5959

6060

61-
/** The hint directive, used to tag content as hint labels (going under the input). */
61+
/** Hint text to be shown underneath the input. */
6262
@Directive({
6363
selector: 'md-hint, mat-hint',
6464
host: {
@@ -75,7 +75,7 @@ export class MdHint {
7575
@Input() id: string = `md-input-hint-${nextUniqueId++}`;
7676
}
7777

78-
/** Directive, used to display a single error message under the input. */
78+
/** Single error message to be shown underneath the input. */
7979
@Directive({
8080
selector: 'md-error, mat-error',
8181
host: {
@@ -84,21 +84,21 @@ export class MdHint {
8484
})
8585
export class MdErrorDirective { }
8686

87-
/** The input prefix. */
87+
/** Prefix to be placed the the front of the input. */
8888
@Directive({
8989
selector: '[mdPrefix], [matPrefix], [md-prefix]'
9090
})
9191
export class MdPrefix {}
9292

9393

94-
/** The input suffix. */
94+
/** Suffix to be placed at the end of the input. */
9595
@Directive({
9696
selector: '[mdSuffix], [matSuffix], [md-suffix]'
9797
})
9898
export class MdSuffix {}
9999

100100

101-
/** The input directive, used to mark the input that `MdInputContainer` is wrapping. */
101+
/** Marker for the input element that `MdInputContainer` is wrapping. */
102102
@Directive({
103103
selector: `input[mdInput], textarea[mdInput], input[matInput], textarea[matInput]`,
104104
host: {
@@ -252,8 +252,7 @@ export class MdInputDirective {
252252

253253

254254
/**
255-
* Component that represents a text input. It encapsulates the <input> HTMLElement and
256-
* improve on its behaviour, along with styling it according to the Material Design.
255+
* Container for text inputs that applies Material Design styling and behavior.
257256
*/
258257
@Component({
259258
moduleId: module.id,

src/lib/radio/radio.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
`<md-radio>` provides the same functionality as a native `<input type="radio">` enhanced with
1+
`<md-radio>` provides the same functionality as a native `<input type="radio">` enhanced with
22
Material Design styling and animations.
33

44
<!-- example(radio-overview) -->
55

6-
All radio buttons with the same `name` comprise a set from which only one may be selected at a time.
6+
All radio-buttons with the same `name` comprise a set from which only one may be selected at a time.
77

88
### Radio-button label
99
The radio-button label is provided as the content to the `<md-checkbox>` element. The label can be
@@ -18,7 +18,7 @@ specify an appropriate label.
1818

1919
### Radio groups
2020
Radio-buttons should typically be placed inside of an `<md-radio-group>` unless the DOM structure
21-
would make that impossible (e.g., radio buttons inside of table cells). The radio-group has a
21+
would make that impossible (e.g., radio-buttons inside of table cells). The radio-group has a
2222
`value` property that reflects the currently selected radio-button inside of the group.
2323

2424
Individual radio-buttons inside of a radio-group will inherit the `name` of the group.

tools/dgeni/templates/class.template.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<h3 class="docs-api-h3 docs-api-class-name">{$ class.name $}</h3>
1+
<h4 class="docs-api-h4 docs-api-class-name">
2+
<code>{$ class.name $}</code>
3+
</h4>
24
<p class="docs-api-class-description">{$ class.description $}</p>
35

46
{%- if class.directiveExportAs -%}

tools/dgeni/templates/componentGroup.template.html

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,36 @@
1919
{% include 'class.template.html' %}
2020
{% endmacro %}
2121

22-
<h1 class="docs-api-h1">{$ doc.name $}</h1>
23-
<h2 class="docs-api-h2">
24-
Module: <code>{$ doc.ngModule.name $}</code>
25-
</h2>
26-
27-
28-
{%- if doc.services.length -%}
29-
<h2 class="docs-api-h2">Services</h2>
30-
{% for service in doc.services %}
31-
{$ class(service) $}
32-
{% endfor %}
33-
{%- endif -%}
34-
35-
36-
{%- if doc.directives.length -%}
37-
<h2>Directives</h2>
38-
{% for directive in doc.directives %}
39-
{$ class(directive) $}
40-
{% endfor %}
41-
{%- endif -%}
42-
43-
{%- if doc.additionalClasses.length -%}
44-
<h2>Additional classes</h2>
45-
{% for other in doc.additionalClasses %}
46-
{$ class(other) $}
47-
{% endfor %}
48-
{%- endif -%}
22+
<div class="docs-api">
23+
<h2>
24+
API reference for Angular Material {$ doc.name $}
25+
</h2>
26+
27+
<p class="docs-api-module-import">
28+
<code>
29+
import {{$ doc.ngModule.name $}} from '@angular/material';
30+
</code>
31+
</p>
32+
33+
{%- if doc.services.length -%}
34+
<h3 class="docs-api-h3">Services</h3>
35+
{% for service in doc.services %}
36+
{$ class(service) $}
37+
{% endfor %}
38+
{%- endif -%}
39+
40+
41+
{%- if doc.directives.length -%}
42+
<h3 class="docs-api-h3">Directives</h3>
43+
{% for directive in doc.directives %}
44+
{$ class(directive) $}
45+
{% endfor %}
46+
{%- endif -%}
47+
48+
{%- if doc.additionalClasses.length -%}
49+
<h3 class="docs-api-h3">Additional classes</h3>
50+
{% for other in doc.additionalClasses %}
51+
{$ class(other) $}
52+
{% endfor %}
53+
{%- endif -%}
54+
</div>

tools/dgeni/templates/method-list.template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{%- if methodList.length -%}
2-
<h4 class="docs-api-h4 docs-api-method-header">Methods</h4>
2+
<h5 class="docs-api-h5 docs-api-method-header">Methods</h5>
33
{% for m in methodList %}
44
{$ method(m) $}
55
{% endfor %}

tools/dgeni/templates/property-list.template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{%- if propertyList.length -%}
2-
<h4 class="docs-api-h4 docs-api-method-header">Properties</h4>
2+
<h5 class="docs-api-h5 docs-api-method-header">Properties</h5>
33
<table class="docs-api-properties-table">
44
<tr class="docs-api-properties-header-row">
55
<th class="docs-api-properties-th">Name</th>

tools/gulp/tasks/docs.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ const MARKDOWN_TAGS_TO_CLASS_ALIAS = [
4141
'td',
4242
'th',
4343
'tr',
44-
'ul'
44+
'ul',
45+
'pre',
46+
'code',
4547
];
4648

4749
task('docs', ['markdown-docs', 'highlight-docs', 'api-docs', 'minify-html-docs']);
@@ -95,20 +97,21 @@ task('minify-html-docs', ['api-docs'], () => {
9597
function transformMarkdownFiles(buffer: Buffer, file: any): string {
9698
let content = buffer.toString('utf-8');
9799

98-
/* Replace <!-- example(..) --> comments with HTML elements. */
100+
// Replace <!-- example(..) --> comments with HTML elements.
99101
content = content.replace(EXAMPLE_PATTERN, (match: string, name: string) =>
100102
`<div material-docs-example="${name}"></div>`
101103
);
102104

103-
/* Replaces the URL in anchor elements inside of compiled markdown files. */
105+
// Replace the URL in anchor elements inside of compiled markdown files.
104106
content = content.replace(LINK_PATTERN, (match: string, head: string, link: string) =>
105107
// The head is the first match of the RegExp and is necessary to ensure that the RegExp matches
106108
// an anchor element. The head will be then used to re-create the existing anchor element.
107109
// If the head is not prepended to the replaced value, then the first match will be lost.
108110
`${head} href="${fixMarkdownDocLinks(link, file.path)}"`
109111
);
110112

111-
return content;
113+
// Finally, wrap the entire generated in a doc in a div with a specific class.
114+
return `<div class="docs-markdown">${content}</div>`;
112115
}
113116

114117
/** Fixes paths in the markdown files to work in the material-docs-io. */

0 commit comments

Comments
 (0)