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

feat(dgeni,daffio)!: align dgeni and daffio doc types #3333

Merged
merged 2 commits into from
Nov 1, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import {
import { By } from '@angular/platform-browser';
import { RouterTestingModule } from '@angular/router/testing';

import { DaffApiNavDoc } from '@daffodil/docs-utils';

import { DaffioApiListSectionComponent } from './api-list-section.component';
import { DaffioApiReference } from '../../models/api-reference';

@Component({
template: `
Expand All @@ -20,22 +21,18 @@ import { DaffioApiReference } from '../../models/api-reference';
],
})
class WrapperComponent {
apiListValue: Array<DaffioApiReference> = [
apiListValue: Array<DaffApiNavDoc> = [
{
id: 'name1Component',
title: 'title1Component',
path: 'path1',
docType: 'docType1',
docTypeShorthand: 'dt',
children: [],
},
{
id: 'name2Module',
title: 'title2Module',
path: 'path2',
docType: 'docType2',
docTypeShorthand: 'dt',
children: [],
},
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {
import { RouterLink } from '@angular/router';

import { DaffArticleEncapsulatedDirective } from '@daffodil/design';

import { DaffioApiReference } from '../../models/api-reference';
import { DaffApiNavDoc } from '@daffodil/docs-utils';

@Component({
selector: 'daffio-api-list-section',
Expand All @@ -29,5 +28,5 @@ export class DaffioApiListSectionComponent {
/**
* A list of references for API documents.
*/
@Input() children: Array<DaffioApiReference>;
@Input() children: Array<DaffApiNavDoc>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,30 @@ import { RouterLink } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';

import { DaffContainerModule } from '@daffodil/design/container';
import { DaffDocsApiNavList } from '@daffodil/docs-utils';

import { DaffioApiListComponent } from './api-list.component';
import { DaffioApiReference } from '../../models/api-reference';
import { DaffioApiListSectionComponent } from '../api-list-section/api-list-section.component';

@Component({ template: '<daffio-api-list [apiList]="apiListValue"></daffio-api-list>' })
class WrapperComponent {
apiListValue: DaffioApiReference = {
apiListValue: DaffDocsApiNavList = {
id: 'id',
title: 'title',
docType: '',
docTypeShorthand: '',
path: '',
children: [
{
id: 'name1Component',
title: 'title1Component',
path: 'path1',
docType: 'docType1',
docTypeShorthand: 'dt',
children: [
{
id: 'name1ComponentChild',
title: 'title1ComponentChild',
path: 'path1/child',
docType: 'docType1',
docTypeShorthand: 'dt',
children: [],
},
],
Expand All @@ -47,7 +45,6 @@ class WrapperComponent {
title: 'title2Module',
path: 'path2',
docType: 'docType2',
docTypeShorthand: 'dt',
children: [],
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
HostBinding,
} from '@angular/core';

import { DaffioApiReference } from '../../models/api-reference';
import { DaffDocsApiNavList } from '@daffodil/docs-utils';

@Component({
selector: 'daffio-api-list',
Expand All @@ -19,5 +19,5 @@ export class DaffioApiListComponent {
/**
* A list of references for API documents.
*/
@Input() apiList: DaffioApiReference;
@Input() apiList: DaffDocsApiNavList;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ import {
import { By } from '@angular/platform-browser';
import { RouterTestingModule } from '@angular/router/testing';

import {
DaffApiNavPackageDoc,
DaffApiPackageDoc,
DaffDocsGenericNavList,
} from '@daffodil/docs-utils';

import { DaffioApiPackageComponent } from './api-package.component';
import { DaffioApiReference } from '../../models/api-reference';
import { DaffioApiListSectionComponent } from '../api-list-section/api-list-section.component';

@Component({
Expand All @@ -24,7 +29,7 @@ import { DaffioApiListSectionComponent } from '../api-list-section/api-list-sect
],
})
class WrapperComponent {
apiListValue: DaffioApiReference;
apiListValue: DaffApiPackageDoc;
}

describe('DaffioApiPackageComponent', () => {
Expand All @@ -50,39 +55,35 @@ describe('DaffioApiPackageComponent', () => {
id: 'Root',
path: 'path',
docType: 'package',
docTypeShorthand: 'pk',
title: 'title',
description: 'description',
breadcrumbs: [],
children: [
{
id: 'name1Component',
title: 'title1Component',
path: 'path1',
docType: 'docType1',
docTypeShorthand: 'dt',
children: [],
},
{
id: 'name2Module',
title: 'title2Module',
path: 'path2',
docType: 'package',
docTypeShorthand: 'pk',
children: [
{
id: 'name1Component',
title: 'title1Component',
path: 'path1',
docType: 'docType1',
docTypeShorthand: 'dt',
children: [],
},
{
id: 'name2Module',
title: 'title2Module',
path: 'path2',
docType: 'package',
docTypeShorthand: 'pk',
children: [],
},
],
Expand All @@ -104,10 +105,10 @@ describe('DaffioApiPackageComponent', () => {
});

describe('for every subpackage in children', () => {
let subpackages: Array<DaffioApiReference>;
let subpackages: Array<DaffDocsGenericNavList<DaffApiNavPackageDoc>>;

beforeEach(() => {
subpackages = wrapper.apiListValue.children.filter((d) => d.docType === 'package');
subpackages = wrapper.apiListValue.children.filter((d): d is DaffDocsGenericNavList<DaffApiNavPackageDoc> => d.docType === 'package');
});

it('should render a link with the title', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { RouterLink } from '@angular/router';

import { DaffArticleEncapsulatedDirective } from '@daffodil/design';
import { DAFF_ARTICLE_COMPONENTS } from '@daffodil/design/article';
import { DaffApiPackageDoc } from '@daffodil/docs-utils';

import { DaffioApiPackageFilterPipe } from './not-packages.pipe';
import { DaffioApiReference } from '../../models/api-reference';
import { DaffioApiListSectionComponent } from '../api-list-section/api-list-section.component';

@Component({
Expand All @@ -35,5 +35,5 @@ export class DaffioApiPackageComponent {
/**
* A list of references for API documents.
*/
@Input() doc: DaffioApiReference;
@Input() doc: DaffApiPackageDoc;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PipeTransform,
} from '@angular/core';

import { DaffioApiReference } from '../../models/api-reference';
import { DaffApiDoc } from '@daffodil/docs-utils';

/**
* Filters packages from a list of API docs.
Expand All @@ -15,7 +15,7 @@ import { DaffioApiReference } from '../../models/api-reference';
standalone: true,
})
export class DaffioApiPackageFilterPipe implements PipeTransform {
transform(docs: Array<DaffioApiReference>, exclude = false) {
transform(docs: Array<DaffApiDoc>, exclude = false) {
return exclude
? docs.filter((doc) => doc.docType !== 'package')
: docs.filter((doc) => doc.docType === 'package');
Expand Down
10 changes: 0 additions & 10 deletions apps/daffio/src/app/docs/api/models/api-doc.ts

This file was deleted.

13 changes: 0 additions & 13 deletions apps/daffio/src/app/docs/api/models/api-reference.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,42 @@ import { RouterTestingModule } from '@angular/router/testing';
import { DaffioRoute } from 'apps/daffio/src/app/core/router/route.type';
import { BehaviorSubject } from 'rxjs';

import { DaffDocsApiNavList } from '@daffodil/docs-utils';

import { DaffioApiListPageComponent } from './api-list-page.component';
import { DaffioApiListComponent } from '../../components/api-list/api-list.component';
import { DaffioApiReference } from '../../models/api-reference';

@Component({
template: '',
selector: 'daffio-api-list',
})
class MockDaffioApiListComponent {
@Input() apiList: DaffioApiReference[] = [];
@Input() apiList: DaffDocsApiNavList[] = [];
}

describe('DaffioApiListPageComponent', () => {
let component: DaffioApiListPageComponent;
let fixture: ComponentFixture<DaffioApiListPageComponent>;
let dataSpy: BehaviorSubject<DaffioRoute['data']>;

const stubDocsList: DaffioApiReference = {
const stubDocsList: DaffDocsApiNavList = {
id: 'id',
title: 'title',
docType: '',
docTypeShorthand: '',
path: '',
children: [
{
id: 'name1Component',
title: 'title1Component',
path: 'path1',
docType: 'docType1',
docTypeShorthand: 'dt',
children: [],
},
{
id: 'name2Module',
title: 'title2Module',
path: 'path2',
docType: 'docType2',
docTypeShorthand: 'dt',
children: [],
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import { ActivatedRoute } from '@angular/router';
import {
map,
Observable,
tap,
} from 'rxjs';

import { DaffioApiReference } from '../../models/api-reference';
import { DaffDocsApiNavList } from '@daffodil/docs-utils';

@Component({
selector: '<daffio-api-list-page>',
selector: 'daffio-api-list-page',
templateUrl: './api-list-page.component.html',
styleUrls: ['./api-list-page.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
Expand All @@ -22,7 +21,7 @@ export class DaffioApiListPageComponent implements OnInit {
/**
* A list of references for API documents.
*/
apiList$: Observable<DaffioApiReference>;
apiList$: Observable<DaffDocsApiNavList>;

constructor(
private route: ActivatedRoute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ import { RouterTestingModule } from '@angular/router/testing';
import { cold } from 'jasmine-marbles';
import { BehaviorSubject } from 'rxjs';

import { DaffDoc } from '@daffodil/docs-utils';

import { DaffioApiPageComponent } from './api-page.component';
import { DaffioDoc } from '../../../models/doc';
import { DaffioDocsFactory } from '../../../testing/factories/docs.factory';

@Component({ selector: 'daffio-doc-viewer', template: '' })
class MockDaffioDocViewerComponent {
@Input() doc: DaffioDoc;
@Input() doc: DaffDoc;
}

describe('DaffioApiPageComponent', () => {
let component: DaffioApiPageComponent;
let fixture: ComponentFixture<DaffioApiPageComponent>;
const doc: DaffioDoc = new DaffioDocsFactory().create();
const doc: DaffDoc = new DaffioDocsFactory().create();
const stubActivatedRoute = {
data: new BehaviorSubject({}),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { DaffioApiDoc } from '../../models/api-doc';
import { DaffApiDoc } from '@daffodil/docs-utils';

interface ApiResolverData {
doc: DaffioApiDoc;
doc: DaffApiDoc;
}

@Component({
Expand All @@ -19,7 +19,7 @@ interface ApiResolverData {
})
export class DaffioApiPageComponent implements OnInit {

doc$: Observable<DaffioApiDoc>;
doc$: Observable<DaffApiDoc>;

constructor(private route: ActivatedRoute) { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
</daff-article>
}
</div>
<daffio-docs-table-of-contents
*ngIf="doc.tableOfContents"
class="daffio-doc-viewer__table-of-contents"
[tableOfContents]="doc.tableOfContents.json">
</daffio-docs-table-of-contents>
@if (isGuideDoc) {
<daffio-docs-table-of-contents
class="daffio-doc-viewer__table-of-contents"
[tableOfContents]="doc.tableOfContents.json">
</daffio-docs-table-of-contents>
}
</div>
Loading
Loading