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

Commit 7f19c8c

Browse files
committed
Disambiguate between material and cdk docs
1 parent 9d96f7c commit 7f19c8c

File tree

7 files changed

+40
-41
lines changed

7 files changed

+40
-41
lines changed

src/app/pages/component-viewer/component-api.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
API for {{componentViewer.componentDocItem.id}}
33
</span>
44
<doc-viewer
5-
documentUrl="/assets/documents/api/{{componentViewer.componentDocItem.id}}.html"
5+
documentUrl="/assets/documents/api/{{componentViewer.componentDocItem.packageName}}-{{componentViewer.componentDocItem.id}}.html"
66
class="docs-component-view-text-content docs-component-api"
77
(contentLoaded)="toc.updateScrollPosition()"></doc-viewer>
8-
<table-of-contents #toc
9-
headerSelectors=".docs-api-h3,.docs-api-h4"
8+
<table-of-contents #toc
9+
headerSelectors=".docs-api-h3,.docs-api-h4"
1010
container=".mat-drawer-content"></table-of-contents>

src/app/pages/component-viewer/component-overview.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Overview for {{componentViewer.componentDocItem.id}}
33
</span>
44
<doc-viewer
5-
documentUrl="/assets/documents/overview/{{componentViewer.componentDocItem.id}}.html"
5+
documentUrl="/assets/documents/overview/{{componentViewer.componentDocItem.packageName}}-{{componentViewer.componentDocItem.id}}.html"
66
class="docs-component-view-text-content docs-component-overview"
77
(contentLoaded)="toc.updateScrollPosition()">
88
</doc-viewer>

src/app/pages/component-viewer/component-viewer.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('ComponentViewer', () => {
4242
it('should set page title correctly', () => {
4343
const component = fixture.componentInstance;
4444
fixture.detectChanges();
45-
const expected = `${component.docItems.getItemById(docItemsId).name}`;
45+
const expected = `${component.docItems.getItemById(docItemsId, 'material').name}`;
4646
expect(component._componentPageTitle.title).toEqual(expected);
4747
});
4848
});

src/app/pages/component-viewer/component-viewer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ export class ComponentViewer {
2323
public _componentPageTitle: ComponentPageTitle,
2424
public docItems: DocumentationItems) {
2525
this._route.params.subscribe(params => {
26-
this.componentDocItem = docItems.getItemById(params['id']);
26+
this.componentDocItem = docItems.getItemById(
27+
params['id'],
28+
this._route.parent.snapshot.params['section']);
2729

2830
if (this.componentDocItem) {
2931
this._componentPageTitle.title = `${this.componentDocItem.name}`;

src/app/shared/documentation-items/documentation-items.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ describe('DocViewer', () => {
3737
});
3838

3939
it('should get a doc item by id', () => {
40-
expect(docsItems.getItemById('button')).toBeDefined();
40+
expect(docsItems.getItemById('button', 'material')).toBeDefined();
4141
});
4242
});

src/app/shared/documentation-items/documentation-items.ts

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {Injectable} from '@angular/core';
33
export interface DocItem {
44
id: string;
55
name: string;
6+
packageName?: string;
67
examples?: string[];
78
}
89

@@ -107,52 +108,47 @@ const DOCS: {[key: string]: DocCategory[]} = {
107108
}
108109
],
109110
[CDK] : [
110-
{
111-
id: 'components',
112-
name: 'Components',
113-
items: [
114-
{id: 'table', name: 'Table', examples: []},
115-
{id: 'stepper', name: 'Stepper', examples: []},
116-
117-
]
118-
},
119111
{
120112
id: 'component-composition',
121-
name: 'Component Composition',
113+
name: 'Common Behaviors',
122114
items: [
115+
{id: 'a11y', name: 'Accessibility', examples: []},
123116
{id: 'observers', name: 'Observers', examples: []},
124117
{id: 'layout', name: 'Layout', examples: []},
125118
{id: 'overlay', name: 'Overlay', examples: []},
126119
{id: 'portal', name: 'Portal', examples: []},
127120
{id: 'bidi', name: 'Bidirectionality', examples: []},
128121
{id: 'scrolling', name: 'Scrolling', examples: []},
129-
{id: 'viewport', name: 'Viewport', examples: []},
130-
]
131-
},
132-
{
133-
id: 'utilities',
134-
name: 'Utilities',
135-
items: [
136-
{id: 'coercion', name: 'Coercion', examples: []},
137-
{id: 'collections', name: 'Collections', examples: []},
138-
{id: 'keycodes', name: 'Keycodes', examples: []},
139-
{id: 'platform', name: 'Platform', examples: []},
140-
{id: 'rxjs', name: 'RxJS', examples: []},
141122
]
142123
},
143124
{
144-
id: 'accessibility',
145-
name: 'Accessibility',
125+
id: 'components',
126+
name: 'Components',
146127
items: [
147-
{id: 'focus-key-manager', name: 'Focus Key Manager', examples: []},
148-
{id: 'focus-trap', name: 'Focus Trap', examples: []},
149-
{id: 'interactivity-checker', name: 'Interactivity Checker', examples: []},
150-
{id: 'list-key-manager', name: 'List Key Manager', examples: []},
151-
{id: 'live-announcer', name: 'Live Announcer', examples: []},
128+
{id: 'table', name: 'Table', examples: []},
129+
{id: 'stepper', name: 'Stepper', examples: []},
130+
152131
]
153132
},
133+
// TODO(jelbourn): re-add utilities and a11y as top-level categories once we can generate
134+
// their API docs with dgeni. Currently our setup doesn't generate API docs for constants
135+
// and standalone functions (much of the utilities) and we have no way of generating API
136+
// docs more granularly than directory-level (within a11y) (same for viewport).
154137
]
155138
};
139+
140+
for (let category of DOCS[COMPONENTS]) {
141+
for (let doc of category.items) {
142+
doc.packageName = 'material';
143+
}
144+
}
145+
146+
for (let category of DOCS[CDK]) {
147+
for (let doc of category.items) {
148+
doc.packageName = 'cdk';
149+
}
150+
}
151+
156152
const ALL_COMPONENTS = DOCS[COMPONENTS].reduce(
157153
(result, category) => result.concat(category.items), []);
158154
const ALL_CDK = DOCS[CDK].reduce((result, cdk) => result.concat(cdk.items), []);
@@ -175,8 +171,9 @@ export class DocumentationItems {
175171
return [];
176172
}
177173

178-
getItemById(id: string): DocItem {
179-
return ALL_DOCS.find(i => i.id === id);
174+
getItemById(id: string, section: string): DocItem {
175+
const sectionLookup = section == 'cdk' ? 'cdk' : 'material';
176+
return ALL_DOCS.find(doc => doc.id === id && doc.packageName == sectionLookup);
180177
}
181178

182179
getCategoryById(id: string): DocCategory {

src/app/shared/table-of-contents/table-of-contents.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ export class TableOfContents implements OnInit {
8181
}
8282

8383
ngOnDestroy(): void {
84-
this._routeSubscription.unsubscribe();
85-
this._scrollSubscription.unsubscribe();
86-
this._fragmentSubscription.unsubscribe();
84+
this._routeSubscription && this._routeSubscription.unsubscribe();
85+
this._scrollSubscription && this._scrollSubscription.unsubscribe();
86+
this._fragmentSubscription && this._fragmentSubscription.unsubscribe();
8787
}
8888

8989
updateScrollPosition(): void {

0 commit comments

Comments
 (0)