Skip to content

Commit 521ffd4

Browse files
committed
docs: show additional interfaces
* Shows additional interfaces in the Dgeni API documentation * Adds documentation for the `RippleGlobalOptions` Closes #8298.
1 parent 8dfe470 commit 521ffd4

File tree

8 files changed

+124
-63
lines changed

8 files changed

+124
-63
lines changed

src/lib/core/ripple/ripple-renderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export class RippleRenderer {
8585
}
8686

8787
const radius = config.radius || distanceToFurthestCorner(x, y, containerRect);
88-
const duration = RIPPLE_FADE_IN_DURATION * (1 / (config.speedFactor || 1));
88+
const duration = RIPPLE_FADE_IN_DURATION / (config.speedFactor || 1);
8989
const offsetX = x - containerRect.left;
9090
const offsetY = y - containerRect.top;
9191

src/lib/core/ripple/ripple.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,17 @@ import {RippleConfig, RippleRenderer} from './ripple-renderer';
2323
import {RippleRef} from './ripple-ref';
2424

2525
export interface RippleGlobalOptions {
26+
/**
27+
* Whether ripples should be disabled. Ripples can be still launched manually by using
28+
* the `launch()` method. Therefore focus indicators will still show up.
29+
*/
2630
disabled?: boolean;
31+
32+
/**
33+
* If set, the default duration of the fade-in animation is divided by this value. For example,
34+
* setting it to 0.5 will cause the ripple fade-in animation to take twice as long.
35+
* A changed speedFactor will not affect the fade-out duration of the ripples.
36+
*/
2737
baseSpeedFactor?: number;
2838
}
2939

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {ClassExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassExportDoc';
2+
import {ClassLikeExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassLikeExportDoc';
3+
import {PropertyMemberDoc} from 'dgeni-packages/typescript/api-doc-types/PropertyMemberDoc';
4+
import {NormalizedMethodMemberDoc} from './normalize-method-parameters';
5+
6+
export interface CategorizedClassLikeDoc extends ClassLikeExportDoc {
7+
methods: CategorizedMethodMemberDoc[];
8+
properties: CategorizedPropertyMemberDoc[];
9+
isDeprecated: boolean;
10+
}
11+
12+
export interface CategorizedClassDoc extends ClassExportDoc, CategorizedClassLikeDoc {
13+
isDirective: boolean;
14+
isService: boolean;
15+
isNgModule: boolean;
16+
directiveExportAs?: string | null;
17+
directiveSelectors?: string[];
18+
extendedDoc: ClassLikeExportDoc | null;
19+
}
20+
21+
export interface CategorizedPropertyMemberDoc extends PropertyMemberDoc {
22+
description: string;
23+
isDeprecated: boolean;
24+
isDirectiveInput: boolean;
25+
isDirectiveOutput: boolean;
26+
directiveInputAlias: string;
27+
directiveOutputAlias: string;
28+
}
29+
30+
export interface CategorizedMethodMemberDoc extends NormalizedMethodMemberDoc {
31+
showReturns: boolean;
32+
isDeprecated: boolean;
33+
}

tools/dgeni/common/sort-members.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {CategorizedMethodMemberDoc, CategorizedPropertyMemberDoc} from '../processors/categorizer';
21
import {isDirectiveInput, isDirectiveOutput} from './decorators';
2+
import {CategorizedMethodMemberDoc, CategorizedPropertyMemberDoc} from './dgeni-definitions';
33

44
/** Combined type for a categorized method member document. */
55
type CategorizedMemberDoc = CategorizedMethodMemberDoc & CategorizedPropertyMemberDoc;

tools/dgeni/processors/categorizer.ts

Lines changed: 34 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
import {Processor, DocCollection} from 'dgeni';
2-
import {ClassExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassExportDoc';
3-
import {PropertyMemberDoc} from 'dgeni-packages/typescript/api-doc-types/PropertyMemberDoc';
4-
import {
5-
NormalizedMethodMemberDoc,
6-
normalizeMethodParameters
7-
} from '../common/normalize-method-parameters';
1+
import {DocCollection, Processor} from 'dgeni';
2+
import {MethodMemberDoc} from 'dgeni-packages/typescript/api-doc-types/MethodMemberDoc';
83
import {
94
decorateDeprecatedDoc,
105
getDirectiveInputAlias,
@@ -19,35 +14,15 @@ import {
1914
isProperty,
2015
isService
2116
} from '../common/decorators';
22-
import {ClassLikeExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassLikeExportDoc';
23-
import {MethodMemberDoc} from 'dgeni-packages/typescript/api-doc-types/MethodMemberDoc';
17+
import {
18+
CategorizedClassDoc,
19+
CategorizedClassLikeDoc,
20+
CategorizedMethodMemberDoc,
21+
CategorizedPropertyMemberDoc
22+
} from '../common/dgeni-definitions';
23+
import {normalizeMethodParameters} from '../common/normalize-method-parameters';
2424
import {sortCategorizedMembers} from '../common/sort-members';
2525

26-
export interface CategorizedClassDoc extends ClassExportDoc {
27-
methods: CategorizedMethodMemberDoc[];
28-
properties: CategorizedPropertyMemberDoc[];
29-
isDirective: boolean;
30-
isService: boolean;
31-
isNgModule: boolean;
32-
isDeprecated: boolean;
33-
directiveExportAs?: string | null;
34-
directiveSelectors?: string[];
35-
extendedDoc: ClassLikeExportDoc | null;
36-
}
37-
38-
export interface CategorizedPropertyMemberDoc extends PropertyMemberDoc {
39-
description: string;
40-
isDeprecated: boolean;
41-
isDirectiveInput: boolean;
42-
isDirectiveOutput: boolean;
43-
directiveInputAlias: string;
44-
directiveOutputAlias: string;
45-
}
46-
47-
export interface CategorizedMethodMemberDoc extends NormalizedMethodMemberDoc {
48-
showReturns: boolean;
49-
isDeprecated: boolean;
50-
}
5126

5227
/**
5328
* Processor to add properties to docs objects.
@@ -62,34 +37,47 @@ export class Categorizer implements Processor {
6237
$runBefore = ['docs-processed'];
6338

6439
$process(docs: DocCollection) {
65-
docs.filter(doc => doc.docType === 'class').forEach(doc => this.decorateClassDoc(doc));
40+
docs
41+
.filter(doc => doc.docType === 'class' || doc.docType === 'interface')
42+
.forEach(doc => this.decorateClassLikeDoc(doc));
6643
}
6744

6845
/**
69-
* Decorates all class docs inside of the dgeni pipeline.
70-
* - Methods and properties of a class-doc will be extracted into separate variables.
71-
* - Identifies directives, services or NgModules and marks them them in class-doc.
46+
* Decorates all class and interface docs inside of the dgeni pipeline.
47+
* - Members of a class and interface document will be extracted into separate variables.
7248
*/
73-
private decorateClassDoc(classDoc: CategorizedClassDoc) {
49+
private decorateClassLikeDoc(classLikeDoc: CategorizedClassLikeDoc) {
7450
// Resolve all methods and properties from the classDoc.
75-
classDoc.methods = classDoc.members
51+
classLikeDoc.methods = classLikeDoc.members
7652
.filter(isMethod)
7753
.filter(filterDuplicateMembers) as CategorizedMethodMemberDoc[];
7854

79-
classDoc.properties = classDoc.members
55+
classLikeDoc.properties = classLikeDoc.members
8056
.filter(isProperty)
8157
.filter(filterDuplicateMembers) as CategorizedPropertyMemberDoc[];
8258

8359
// Call decorate hooks that can modify the method and property docs.
84-
classDoc.methods.forEach(doc => this.decorateMethodDoc(doc));
85-
classDoc.properties.forEach(doc => this.decoratePropertyDoc(doc));
60+
classLikeDoc.methods.forEach(doc => this.decorateMethodDoc(doc));
61+
classLikeDoc.properties.forEach(doc => this.decoratePropertyDoc(doc));
8662

87-
decorateDeprecatedDoc(classDoc);
63+
decorateDeprecatedDoc(classLikeDoc);
8864

8965
// Sort members
90-
classDoc.methods.sort(sortCategorizedMembers);
91-
classDoc.properties.sort(sortCategorizedMembers);
66+
classLikeDoc.methods.sort(sortCategorizedMembers);
67+
classLikeDoc.properties.sort(sortCategorizedMembers);
68+
69+
// Special decorations for real class documents that don't apply for interfaces.
70+
if (classLikeDoc.docType === 'class') {
71+
this.decorateClassDoc(classLikeDoc as CategorizedClassDoc);
72+
}
73+
}
9274

75+
/**
76+
* Decorates all Dgeni class documents for a simpler use inside of the template.
77+
* - Identifies directives, services or NgModules and marks them them inside of the doc.
78+
* - Links the Dgeni document to the Dgeni document that the current class extends from.
79+
*/
80+
private decorateClassDoc(classDoc: CategorizedClassDoc) {
9381
// Classes can only extend a single class. This means that there can't be multiple extend
9482
// clauses for the Dgeni document. To make the template syntax simpler and more readable,
9583
// store the extended class in a variable.

tools/dgeni/processors/component-grouper.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
import {CategorizedClassDoc} from './categorizer';
21
import {DocCollection, Document, Processor} from 'dgeni';
2+
import {InterfaceExportDoc} from 'dgeni-packages/typescript/api-doc-types/InterfaceExportDoc';
33
import * as path from 'path';
4+
import {CategorizedClassDoc} from '../common/dgeni-definitions';
45

56
/** Component group data structure. */
67
export class ComponentGroup {
78

9+
/** Unique document type for Dgeni. */
10+
docType = 'componentGroup';
11+
812
/** Name of the component group. */
913
name: string;
1014

@@ -24,32 +28,26 @@ export class ComponentGroup {
2428
id: string;
2529

2630
/** Known aliases for the component group. */
27-
aliases: string[];
28-
29-
/** Unique document type for Dgeni. */
30-
docType: string;
31+
aliases: string[] = [];
3132

3233
/** List of categorized class docs that are defining a directive. */
33-
directives: CategorizedClassDoc[];
34+
directives: CategorizedClassDoc[] = [];
3435

3536
/** List of categorized class docs that are defining a service. */
36-
services: CategorizedClassDoc[];
37+
services: CategorizedClassDoc[] = [];
3738

3839
/** Additional classes that belong to the component group. */
39-
additionalClasses: CategorizedClassDoc[];
40+
additionalClasses: CategorizedClassDoc[] = [];
41+
42+
/** Additional interfaces that belong to the component group. */
43+
additionalInterfaces: InterfaceExportDoc[] = [];
4044

4145
/** NgModule that defines the current component group. */
42-
ngModule: CategorizedClassDoc | null;
46+
ngModule: CategorizedClassDoc | null = null;
4347

4448
constructor(name: string) {
4549
this.name = name;
4650
this.id = `component-group-${name}`;
47-
this.aliases = [];
48-
this.docType = 'componentGroup';
49-
this.directives = [];
50-
this.services = [];
51-
this.additionalClasses = [];
52-
this.ngModule = null;
5351
}
5452
}
5553

@@ -97,6 +95,8 @@ export class ComponentGrouper implements Processor {
9795
group.ngModule = doc;
9896
} else if (doc.docType == 'class') {
9997
group.additionalClasses.push(doc);
98+
} else if (doc.docType == 'interface') {
99+
group.additionalInterfaces.push(doc);
100100
}
101101
});
102102

tools/dgeni/templates/componentGroup.template.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
{% include 'class.template.html' %}
2020
{% endmacro %}
2121

22+
{% macro interface(interface) -%}
23+
{% include 'interface.template.html' %}
24+
{% endmacro %}
25+
2226
<div class="docs-api">
2327
<h2>
2428
API reference for Angular {$ doc.packageDisplayName $} {$ doc.displayName $}
@@ -60,4 +64,14 @@ <h3 id="additional_classes" class="docs-header-link docs-api-h3">
6064
{$ class(other) $}
6165
{% endfor %}
6266
{%- endif -%}
67+
68+
{%- if doc.additionalInterfaces.length -%}
69+
<h3 id="additional_interfaces" class="docs-header-link docs-api-h3">
70+
<span header-link="additional_interfaces"></span>
71+
Additional interfaces
72+
</h3>
73+
{% for item in doc.additionalInterfaces %}
74+
{$ interface(item) $}
75+
{% endfor %}
76+
{%- endif -%}
6377
</div>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<h4 id="{$ interface.name $}" class="docs-header-link docs-api-h4 docs-api-interface-name">
2+
<span header-link="{$ interface.name $}"></span>
3+
<code>{$ interface.name $}</code>
4+
</h4>
5+
6+
{%- if interface.description -%}
7+
<p class="docs-api-interface-description">{$ interface.description | marked | safe $}</p>
8+
{%- endif -%}
9+
10+
{%- if interface.isDeprecated -%}
11+
<div class="docs-api-interface-deprecated-marker">Deprecated</div>
12+
{%- endif -%}
13+
14+
{$ propertyList(interface.properties) $}
15+
16+
{$ methodList(interface.methods) $}

0 commit comments

Comments
 (0)