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

Add ability to mark items as being in preview #272

Merged
merged 5 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 9.2.0 (2023-02-27)

- Add ability to mark features as being in preview. [#272](https://github.com/blackbaud/skyux-docs-tools/pull/272)

## 9.1.5 (2023-10-09)

- Allow a demo page to be created without the `moduleName` input. [#268](https://github.com/blackbaud/skyux-docs-tools/pull/268)
Expand Down
2 changes: 1 addition & 1 deletion projects/docs-tools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@skyux/docs-tools",
"version": "9.1.5",
"version": "9.2.0",
"peerDependencies": {
"@angular/common": "^16.2.5",
"@angular/core": "^16.2.5",
Expand Down
16 changes: 16 additions & 0 deletions projects/docs-tools/src/modules/demo-page/demo-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
>
<ng-content select="sky-docs-demo-page-summary"></ng-content>

<sky-alert
*ngIf="
moduleTypeDefinitions?.hasPreviewFeatures ||
testingTypeDefinitions?.hasPreviewFeatures
"
class="sky-docs-demo-page-preview-alert sky-margin-stacked-lg"
>This component currently has preview inputs available that may not be
Blackbaud-SteveBrush marked this conversation as resolved.
Show resolved Hide resolved
fully represented in the design documentation, the demo, or code examples.
<ng-container *ngIf="siteOptions?.previewFeaturesUrl"
>Learn more about this work
<a [skyAppLink]="siteOptions?.previewFeaturesUrl"
>here.</a
></ng-container
></sky-alert
>

<ng-content select="sky-docs-demo"></ng-content>

<div class="sky-docs-demo-page-main">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ import { SkyDocsTypeDefinitionsService } from '../type-definitions/type-definiti
import { MockTypeDocAdapterService } from '../type-definitions/fixtures/mock-type-definitions.service';
import { SkyDocsTypeDocAdapterService } from '../type-definitions/typedoc-adapter.service';
import { TypeDocKind } from '../type-definitions/typedoc-types';
import { SkyDocsToolsSiteOptions } from '../shared/docs-tools-site-options';

function getPreviewAlert(): HTMLElement | null {
return document.querySelector('.sky-docs-demo-page-preview-alert');
}

function getPreviewAlertLink(): HTMLAnchorElement | null {
return getPreviewAlert().querySelector('a');
}

function getService(
provider: SkyDocsTypeDefinitionsProvider = {
anchorIds: {},
Expand Down Expand Up @@ -181,7 +191,7 @@ describe('Demo page component', () => {
let component: DemoPageFixtureComponent;
let mockMediaQueryService: MockSkyMediaQueryService;

beforeEach(() => {
function setupTestBed(): void {
mockMediaQueryService = new MockSkyMediaQueryService();
TestBed.configureTestingModule({
imports: [DemoPageFixturesModule],
Expand All @@ -191,8 +201,25 @@ describe('Demo page component', () => {
useValue: mockMediaQueryService,
},
{ provide: SkyDocsTypeDefinitionsService, useValue: getService() },
{
provide: SkyDocsTypeDefinitionsProvider,
useValue: {
anchorIds: {
FooUser: 'foo-user',
},
typeDefinitions: [
{
name: 'FooUser',
},
],
},
},
],
});
}

beforeEach(() => {
setupTestBed();

fixture = TestBed.createComponent(DemoPageFixtureComponent);
component = fixture.componentInstance;
Expand Down Expand Up @@ -321,4 +348,54 @@ describe('Demo page component', () => {
);
expect(sidebarLinks[1].getAttribute('href')).toEqual('/bar');
});

it('should not show the preview features alert if there are no preview features', () => {
fixture.detectChanges();
const previewAlert = getPreviewAlert();
expect(previewAlert).toBeNull();
});

it('should show the preview features alert if there are preview features - no link', () => {
spyOn(
MockTypeDocAdapterService.prototype,
'toClassDefinition'
).and.callFake((entry) => {
return {
hasPreviewFeatures: true,
anchorId: entry.anchorId,
name: entry.name,
};
});
fixture.detectChanges();
const previewAlert = getPreviewAlert();
const previewAlertLink = getPreviewAlertLink();
expect(previewAlert).not.toBeNull();
expect(previewAlertLink).toBeNull();
});

it('should show the preview features alert if there are preview features - with a link when provided by the consumer', () => {
TestBed.resetTestingModule();
TestBed.overrideProvider(SkyDocsToolsSiteOptions, {
useValue: { previewFeaturesUrl: 'www.blackbaud.com' },
});
setupTestBed();

fixture = TestBed.createComponent(DemoPageFixtureComponent);
component = fixture.componentInstance;
spyOn(
MockTypeDocAdapterService.prototype,
'toClassDefinition'
).and.callFake((entry) => {
return {
hasPreviewFeatures: true,
anchorId: entry.anchorId,
name: entry.name,
};
});
fixture.detectChanges();
const previewAlert = getPreviewAlert();
const previewAlertLink = getPreviewAlertLink();
expect(previewAlert).not.toBeNull();
expect(previewAlertLink).not.toBeNull();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Input,
OnInit,
QueryList,
inject,
} from '@angular/core';

import { ActivatedRoute, Router } from '@angular/router';
Expand All @@ -30,6 +31,7 @@ import { SkyDocsDemoPageDomAdapterService } from './demo-page-dom-adapter.servic
import { SkyDocsDemoPageTitleService } from './demo-page-title.service';
import { SkyDocsTypeDefinitionsService } from '../type-definitions/type-definitions.service';
import { SkyDocsTypeDefinitions } from '../type-definitions/type-definitions';
import { SkyDocsToolsSiteOptions } from '../shared/docs-tools-site-options';

/**
* The demo page component wraps all documentation components and handles the configuration and layout of the page.
Expand Down Expand Up @@ -161,12 +163,19 @@ export class SkyDocsDemoPageComponent
*/
public sidebarRoutes: StacheNavLink[];

protected hasPreviewFeatures = false;

@ContentChild(SkyDocsDesignGuidelinesComponent)
private designGuidelinesComponent: SkyDocsDesignGuidelinesComponent;

@ContentChildren(SkyDocsCodeExamplesComponent)
private codeExampleComponents: QueryList<SkyDocsCodeExamplesComponent>;

protected readonly siteOptions: SkyDocsToolsSiteOptions | undefined = inject(
SkyDocsToolsSiteOptions,
{ optional: true }
);

#_additionalSourceCodePaths: string[] | undefined;
#_additionalTestingSourceCodePaths: string[] | undefined;
#_moduleSourceCodePath: string | undefined;
Expand Down
4 changes: 4 additions & 0 deletions projects/docs-tools/src/modules/demo-page/demo-page.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ import { SkyDocsDemoPageComponent } from './demo-page.component';
import { SkyDocsDemoPageModuleInfoComponent } from './demo-page-module-info.component';

import { SkyDocsDemoPageTypeDefinitionsComponent } from './demo-page-type-definitions.component';
import { SkyAlertModule } from '@skyux/indicators';
import { SkyAppLinkModule } from '@skyux/router';

@NgModule({
imports: [
CommonModule,
RouterModule,
SkyAlertModule,
SkyAppLinkModule,
SkyCodeBlockModule,
SkyCodeModule,
SkyDocsDemoModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class MockSkyAppConfig {
base: '/demo-test-base/',
},
routes: [],
params: {
getAll: (_: unknown) => {},
},
};

public skyux: any = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export class SkyDocsToolsSiteOptions {
public previewFeaturesUrl: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ describe('Class definition component', function () {
anchorId: 'service-fooservice',
description: 'This description has a FooUser.',
name: 'FooService',
hasPreviewFeatures: false,
};

fixture.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ export interface SkyDocsClassDefinition extends SkyDocsEntryDefinition {
methods?: SkyDocsClassMethodDefinition[];

properties?: SkyDocsClassPropertyDefinition[];

hasPreviewFeatures: boolean;
Blackbaud-SteveBrush marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe('Directive definition component', function () {
anchorId: 'foo-anchor-id',
name: 'FooComponent',
selector: 'app-foo',
hasPreviewFeatures: false,
};

fixture.detectChanges();
Expand All @@ -77,13 +78,15 @@ describe('Directive definition component', function () {
anchorId: 'foo-anchor-id',
name: 'FooComponent',
selector: 'app-foo',
hasPreviewFeatures: false,
inputProperties: [
{
name: 'config',
decorator: {
name: 'Input',
},
isOptional: true,
isPreview: false,
type: {
type: 'reference',
name: 'Config',
Expand All @@ -97,6 +100,7 @@ describe('Directive definition component', function () {
name: 'Output',
},
isOptional: true,
isPreview: false,
type: {
type: 'reference',
name: 'EventEmitter',
Expand Down Expand Up @@ -130,13 +134,15 @@ describe('Directive definition component', function () {
anchorId: 'foo-anchor-id',
name: 'FooComponent',
selector: 'app-foo',
hasPreviewFeatures: false,
eventProperties: [
{
name: 'click',
decorator: {
name: 'Output',
},
isOptional: false,
isPreview: false,
type: {},
},
],
Expand All @@ -156,6 +162,7 @@ describe('Directive definition component', function () {
anchorId: 'component-foocomponent',
name: 'FooComponent',
description: 'This description has a [[FooUser]].',
hasPreviewFeatures: false,
selector: 'app-foo',
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ export interface SkyDocsDirectiveDefinition extends SkyDocsEntryDefinition {
inputProperties?: SkyDocsClassPropertyDefinition[];

selector: string;

hasPreviewFeatures: boolean;
Blackbaud-SteveBrush marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ describe('Enumeration definition component', function () {
anchorId: 'foo-anchor-id',
name: 'Foo',
description: 'This description has a FooUser.',
hasPreviewFeatures: false,
members: [
{
name: 'Bar',
isPreview: false,
},
],
};
Expand All @@ -90,9 +92,11 @@ describe('Enumeration definition component', function () {
anchorId: 'foo-anchor-id',
name: 'Foo',
description: 'This description has a `Date`.',
hasPreviewFeatures: false,
members: [
{
name: 'Bar',
isPreview: false,
},
],
};
Expand All @@ -112,10 +116,12 @@ describe('Enumeration definition component', function () {
anchorId: 'foo-anchor-id',
name: 'Foo',
description: '',
hasPreviewFeatures: false,
members: [
{
description: 'This description has a FooUser.',
name: 'Bar',
isPreview: false,
},
],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ import { SkyDocsEnumerationMemberDefinition } from './enumeration-member-definit
*/
export interface SkyDocsEnumerationDefinition extends SkyDocsEntryDefinition {
members: SkyDocsEnumerationMemberDefinition[];
hasPreviewFeatures: boolean;
Blackbaud-SteveBrush marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ export interface SkyDocsEnumerationMemberDefinition {

description?: string;

isPreview: boolean;

name: string;
}
Loading
Loading