Skip to content

Commit

Permalink
docs: annotate deprecated and experimental APIs on list page (Reactiv…
Browse files Browse the repository at this point in the history
  • Loading branch information
abraham authored and benlesh committed Feb 1, 2019
1 parent 06f1a25 commit b74b1c0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
5 changes: 4 additions & 1 deletion docs_app/src/app/custom-elements/api/api-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ <h2>{{section.title}}</h2>
<ul class="api-list">
<ng-container *ngFor="let item of section.items">
<li *ngIf="item.show" class="api-item">
<a [href]="item.path"><span class="symbol {{item.docType}}"></span> {{item.title}}</a>
<a [href]="item.path">
<span class="symbol {{item.docType}}"></span>
<span class="stability {{item.stability}}">{{item.title}} {{!item.stability || item.stability === 'stable' ? '' : '(' + item.stability + ')'}}</span>
</a>
</li>
</ng-container>
</ul>
Expand Down
31 changes: 28 additions & 3 deletions docs_app/src/app/custom-elements/api/api-list.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe('ApiListComponent', () => {
});
});

describe('initial critera from location', () => {
describe('initial criteria from location', () => {
let locationService: TestLocationService;

beforeEach(() => {
Expand All @@ -110,7 +110,7 @@ describe('ApiListComponent', () => {
component.filteredSections.subscribe(filtered => {
expect(filtered.length).toBe(1, 'sections');
expect(filtered[0].name).toBe(section, 'section name');
const items = filtered[0].items.filter(item => item.show);
const items = filtered[0].items.filter(currentItem => currentItem.show);
expect(items.length).toBe(1, 'items');

const item = items[0];
Expand Down Expand Up @@ -198,6 +198,31 @@ describe('ApiListComponent', () => {
expect(search.type).toBe('class');
});
});

describe('item stability rendering', () => {

beforeEach(() => {
fixture.detectChanges();
});

function expectRenderedStability(path: string, title: string, classes: string) {
const apiListElement: HTMLElement = fixture.nativeElement;
const a = apiListElement.querySelector(`a[href="${path}"] ${classes}`) as HTMLElement;
expect((a.textContent as string).trim()).toEqual(title.trim());
}

it('should display stable', () => {
expectRenderedStability('api/common/class_2', 'Class 2', '.stability');
});

it('should display experimental', () => {
expectRenderedStability('api/common/class_1', 'Class 1 (experimental)', '.stability.experimental');
});

it('should display deprecated', () => {
expectRenderedStability('api/core/function_1', 'Function 1 (deprecated)', '.stability.deprecated');
});
});
});

////// Helpers ////////
Expand Down Expand Up @@ -268,7 +293,7 @@ const apiSections: ApiSection[] = [
{
"name": "function_1",
"title": "Function 1",
"path": "api/core/function 1",
"path": "api/core/function_1",
"docType": "function",
"stability": "deprecated",
"securityRisk": true
Expand Down
10 changes: 10 additions & 0 deletions docs_app/src/styles/2-modules/_api-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@ aio-api-list {
color: $blue-500;
}
}

.stability {
&.deprecated {
text-decoration: line-through;
}

&.experimental {
font-style: italic;
}
}
}
}

Expand Down

0 comments on commit b74b1c0

Please sign in to comment.