Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: annotate deprecated and experimental APIs on list page #4483

Merged
merged 1 commit into from Feb 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs_app/src/app/custom-elements/api/api-list.component.html
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
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
Expand Up @@ -199,6 +199,16 @@ aio-api-list {
color: $blue-500;
}
}

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

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

Expand Down