Skip to content

Commit fd4e2bf

Browse files
committed
Deploy preview for PR 326 🛫
1 parent e316e8c commit fd4e2bf

File tree

869 files changed

+48100
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

869 files changed

+48100
-0
lines changed

‎pr-preview/pr-326/35.c7d20d6b8b8df622.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pr-preview/pr-326/3rdpartylicenses.txt

Lines changed: 772 additions & 0 deletions
Large diffs are not rendered by default.

‎pr-preview/pr-326/581.debff4a02681a413.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pr-preview/pr-326/662.b7f4f3604834f411.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { BaseExampleComponent } from './baseexample.component';
3+
import { HttpClient } from '@angular/common/http';
4+
import { MarkdownService } from 'app/services/markdown/markdown.service';
5+
import { DocumentationService } from 'app/services/documentation.service';
6+
import { ActivatedRoute } from '@angular/router';
7+
import { environment } from 'environment';
8+
9+
@Component({
10+
selector: 'doc-base-page',
11+
template: `
12+
<doc-template-next
13+
[markdown]="markdown"
14+
[codeExample]="codeExample"
15+
[example]="example"
16+
[design]="design"
17+
[guidance]="guidance"
18+
[implementation]="implementation"
19+
[typedoc]="typedoc_content">
20+
<router-outlet></router-outlet>
21+
</doc-template-next>`,
22+
})
23+
export class BaseDocPageComponent extends BaseExampleComponent implements OnInit {
24+
implementation;
25+
ngOnInit() {
26+
const ctx = this;
27+
// console.log(this.route.snapshot.data.sections);
28+
this.typedoc_target = this.route.snapshot.data.componentName;
29+
if (this.typedoc_target) {
30+
this.service.getComponentProperties(this.typedoc_target)
31+
.subscribe(
32+
(data) => { this.setupTypedocContent(data); },
33+
(error) => { throw new Error(error); }
34+
);
35+
}
36+
37+
// todo: see if we can find out if we should make the call or not
38+
if (this.route.snapshot.data.sections.indexOf('component-example.html') !== -1) {
39+
this._http.get(this.getAssetURI('/component-example.html'), { responseType: 'text' as 'json'})
40+
.subscribe((res: any) => {
41+
// console.log(res.text());
42+
ctx.example = res;
43+
});
44+
}
45+
if (this.route.snapshot.data.sections.indexOf('component-example.ts') !== -1) {
46+
this._http.get(this.getAssetURI('component-example.ts'), { responseType: 'text' as 'json'}).subscribe((res: any) => {
47+
// console.log(res.text());
48+
ctx.codeExample = res;
49+
});
50+
}
51+
if (this.route.snapshot.data.sections.indexOf('documentation.md') !== -1) {
52+
this._http.get(this.getAssetURI('documentation.md'), { responseType: 'text' as 'json'}).subscribe((res: any) => {
53+
// console.log(res.text());
54+
ctx.markdown = res;
55+
});
56+
}
57+
if (this.route.snapshot.data.sections.indexOf('design.md') !== -1) {
58+
this._http.get(this.getAssetURI('design.md'), { responseType: 'text' as 'json'}).subscribe((res: any) => {
59+
// console.log(res.text());
60+
ctx.design = res;
61+
});
62+
}
63+
if (this.route.snapshot.data.sections.indexOf('guidance.md') !== -1) {
64+
this._http.get(this.getAssetURI('guidance.md'), { responseType: 'text' as 'json'}).subscribe((res: any) => {
65+
// console.log(res.text());
66+
ctx.guidance = res;
67+
});
68+
}
69+
if (this.route.snapshot.data.sections.indexOf('implementation.md') !== -1) {
70+
this._http.get(this.getAssetURI('implementation.md'), { responseType: 'text' as 'json'}).subscribe((res: any) => {
71+
// console.log(res.text());
72+
ctx.implementation = res;
73+
});
74+
}
75+
}
76+
77+
constructor(
78+
public _http: HttpClient,
79+
public service: DocumentationService,
80+
public mdService: MarkdownService,
81+
public route: ActivatedRoute) {
82+
83+
super(_http, service, mdService);
84+
}
85+
86+
public getAssetURI (file: string): string {
87+
return `./${this.route.snapshot.data.path}/${file}`;
88+
}
89+
90+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import {
2+
Component,
3+
OnInit,
4+
} from '@angular/core';
5+
import { HttpClient } from '@angular/common/http';
6+
7+
import { DocumentationService } from '../app/services/documentation.service';
8+
import { MarkdownService } from '../app/services/markdown/markdown.service';
9+
10+
@Component({
11+
selector: 'doc-base-example',
12+
template: `<h1>overwrite me</h1>`
13+
})
14+
export class BaseExampleComponent implements OnInit {
15+
public typedoc_target: string = '';
16+
public typedoc_content: string = '';
17+
public markdown: string = '';
18+
public guidance: string = '';
19+
public example: string = '';
20+
public codeExample: string = '';
21+
public design: string = '';
22+
23+
public sections = [
24+
'markdown',
25+
'design',
26+
'guidance',
27+
'implementation'
28+
];
29+
30+
public base;
31+
32+
constructor(
33+
public http: HttpClient,
34+
public service: DocumentationService,
35+
public mdService: MarkdownService) {}
36+
37+
public ngOnInit(): void {
38+
this.service.getComponentProperties(this.typedoc_target)
39+
.subscribe(
40+
(data) => { this.setupTypedocContent(data); },
41+
(error) => { throw new Error(error); }
42+
);
43+
}
44+
45+
public setupTypedocContent(obj: any): void {
46+
if (!obj || obj.length === 0) {
47+
return;
48+
}
49+
this.typedoc_content += `
50+
<h2 class="sam heading">API Reference</h2>
51+
<table class="sam-ui definition celled table">
52+
<thead>
53+
<tr>
54+
<th>Name</th>
55+
<th>Type</th>
56+
<th>Comment</th>
57+
</tr>
58+
</thead>`;
59+
obj.forEach((item) => {
60+
const comment = item['comment'] && item['comment']['shortText'] ? item.comment.shortText : '';
61+
const type = item['type'] && item['type']['name'] ? item.type.name : '';
62+
let deprecated;
63+
if (item.comment && item.comment.tags) {
64+
const depItems = item.comment.tags.filter(
65+
tag => tag.tag === 'deprecated'
66+
);
67+
deprecated = depItems.length > 0 ? true : false;
68+
}
69+
this.typedoc_content += `
70+
<tr>
71+
<td>
72+
${deprecated
73+
? '<em><i class="fa fa-thumbs-down"></i>&nbsp;Deprecated</em><br>'
74+
: ''}
75+
@${item.decorators[0].name}( ) ${item.name}
76+
</td>
77+
<td>${type}</td>
78+
<td>${comment}</td>
79+
</tr>
80+
`;
81+
});
82+
this.typedoc_content += '</tbody></table>';
83+
}
84+
85+
public fetchSection (section: string) {
86+
87+
const fileName = section === 'markdown'
88+
? 'documentation'
89+
: section;
90+
91+
return this.mdService
92+
.get(`${this.base}${fileName}.md`)
93+
.subscribe(
94+
(data: any) => {
95+
this[section] = data.text();
96+
},
97+
(err) => {
98+
this[section] = '';
99+
}
100+
);
101+
}
102+
103+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { NO_ERRORS_SCHEMA } from '@angular/core';
2+
import {
3+
inject,
4+
async,
5+
TestBed,
6+
ComponentFixture
7+
} from '@angular/core/testing';
8+
import {RouterTestingModule} from '@angular/router/testing';
9+
import { HttpClientModule } from '@angular/common/http';
10+
// Load the implementations that should be tested
11+
import { BaseExampleComponent } from './baseexample.component';
12+
import { MarkdownService } from '../app/services/markdown/markdown.service';
13+
import { DocumentationService } from '../app/services/documentation.service';
14+
import { Router, ActivatedRoute, NavigationEnd } from '@angular/router';
15+
import { Observable } from 'rxjs';
16+
17+
describe(`BaseExampleComponent tests`, () => {
18+
let comp: BaseExampleComponent;
19+
let fixture: ComponentFixture<BaseExampleComponent>;
20+
21+
beforeEach(() => {
22+
TestBed.configureTestingModule({
23+
imports: [RouterTestingModule, HttpClientModule],
24+
declarations: [ BaseExampleComponent ],
25+
providers: [
26+
{
27+
provide: MarkdownService,
28+
useValue: {
29+
get: function(filename){
30+
return Observable.of({});
31+
}
32+
}
33+
},
34+
{
35+
provide: DocumentationService,
36+
useValue: {
37+
loadData: function(){
38+
return Observable.of({});
39+
},
40+
getComponentProperties: function(name){
41+
return Observable.of([]);
42+
}
43+
}
44+
},
45+
{
46+
provide: ActivatedRoute, useValue: {
47+
data: Observable.create({ markdownfile: 'test' })
48+
}
49+
}
50+
],
51+
schemas: [NO_ERRORS_SCHEMA]
52+
});
53+
fixture = TestBed.createComponent(BaseExampleComponent);
54+
comp = fixture.componentInstance;
55+
fixture.detectChanges(); // trigger initial data binding
56+
});
57+
58+
it(`should be initialized`, () => {
59+
expect(fixture).toBeDefined();
60+
expect(comp).toBeDefined();
61+
});
62+
63+
64+
});

0 commit comments

Comments
 (0)