Skip to content

Commit

Permalink
[rc] Fixed usage of markdown pipe within type definition components (#59
Browse files Browse the repository at this point in the history
)

* Bump acorn from 6.4.0 to 6.4.1 (#40)

Bumps [acorn](https://github.com/acornjs/acorn) from 6.4.0 to 6.4.1.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](acornjs/acorn@6.4.0...6.4.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Assorted fixes; unit tests (#42)

* Updated changelog/package.json for 3.2.0 release (#43)

* Adding license (#47)

Added license to address blackbaud/skyux2-docs#894

* Fixed href generator for lowercase type names (#49)

* Updated changelog/package.json for 3.2.1 release (#50)

* Added theme picker control panel to demo (#52)

* Added theme picker control panel to demo

* Added tests

* Added theme switcher to sample page.

* Addressed PR feedback

* Fixed import paths

* Updated CHANGELOG and package.json for 3.3.0 release (#53)

* Update README.md

* [rc] Fix anchor links and markdown parsing

* Fix unit tests

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Denise Pena <Denise.Pena@blackbaud.me>
Co-authored-by: Paul Crowder <paul.crowder@blackbaud.com>
  • Loading branch information
4 people authored May 20, 2020
1 parent be2a1f8 commit cb676e4
Show file tree
Hide file tree
Showing 19 changed files with 82 additions and 14,573 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
},
"app": {
"styles": [
"@skyux/theme/css/sky.css",
"@skyux/docs-tools/css/docs-tools.css"
]
}
Expand Down Expand Up @@ -117,4 +116,4 @@ export class AppExtrasModule { }
- Code examples are automatically generated from source code added to `./src/app/public/plugin-resources/code-examples`.
- Each code example should be self-contained (in its own folder) and have its own module. The module will dictate its own exports, imports, providers, or entry components.
- Code examples are not instrumented for code coverage and are not included in any build results.
- Any additional NPM packages that are needed for the code example to run should be added to the `packageDependencies` attribute on the `SkyDocsCodeExamples` component.
- Any additional NPM packages that are needed for the code example to run should be added to the `packageDependencies` attribute on the `SkyDocsCodeExamples` component.
14,533 changes: 0 additions & 14,533 deletions package-lock.json

This file was deleted.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"scripts": {
"build": "skyux build-public-library && node ./scripts/prepare-package.js",
"build:ci": "npm run build",
"build:dev-bundle": "npm run build && node ./scripts/dev-bundle.js",
"test": "skyux test --coverage library",
"test:watch": "skyux watch --coverage library",
"start": "skyux serve",
"start": "npm run build:dev-bundle && skyux serve",
"e2e": "skyux e2e",
"lint": "skyux lint"
},
Expand Down Expand Up @@ -58,7 +59,7 @@
"@blackbaud/skyux-lib-media": "2.0.0-rc.0",
"@blackbaud/skyux-lib-restricted-view": "2.0.0-rc.0",
"@blackbaud/skyux-lib-stache": "4.0.0-rc.2",
"@skyux-sdk/builder": "4.0.0-rc.10",
"@skyux-sdk/builder": "4.0.0-rc.11",
"@skyux-sdk/builder-plugin-skyux": "4.0.0-rc.0",
"@skyux-sdk/e2e": "4.0.0-rc.1",
"@skyux-sdk/testing": "4.0.0-rc.3",
Expand All @@ -67,6 +68,7 @@
"@skyux/avatar": "4.0.0",
"@skyux/config": "4.0.0",
"@skyux/core": "4.1.0",
"@skyux/docs-tools": "4.0.0-rc.6",
"@skyux/errors": "4.0.0",
"@skyux/forms": "4.0.0",
"@skyux/http": "4.0.0",
Expand Down
10 changes: 10 additions & 0 deletions scripts/dev-bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const fs = require('fs-extra');
const rimraf = require('rimraf');

const json = fs.readJsonSync('./package.json');
const dest = `./node_modules/${json.name}`;

rimraf.sync(dest);

fs.ensureDirSync(dest);
fs.copySync('./dist', dest);
12 changes: 7 additions & 5 deletions src/app/app-extras.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ import {
SkyCodeModule
} from '@blackbaud/skyux-lib-code-block';

// Do not import from public_api since the SKY UX plugin needs to assign providers from the same place.
// (The SKY UX plugin pulls types from node_modules.)
import {
SkyDocsToolsModule,
SkyDocsToolsOptions
} from '@skyux/docs-tools'; // <-- Important!

import {
SkyAlertModule
} from '@skyux/indicators';
Expand All @@ -19,11 +26,6 @@ import {
SkyAppLinkModule
} from '@skyux/router';

import {
SkyDocsToolsModule,
SkyDocsToolsOptions
} from './public/public_api';

@NgModule({
exports: [
SkyAlertModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class FooComponent<U extends FooUser> implements OnInit {
public baz: boolean = false;

/**
* This is the description for bar input. You must provide FooEnum values.
* This is the description for bar input. You must provide `FooEnum` values.
* @defaultvalue FooEnum.Foo
*/
@Input()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import {
SkyDocsDemoControlPanelComponent
} from '../demo-control-panel.component';

import {
SkyDocsDemoControlPanelChange
} from '../demo-control-panel-change';

import {
SkyDocsDemoComponent
} from '../demo.component';
Expand Down Expand Up @@ -57,7 +61,7 @@ export class DemoFixtureComponent {

public onDemoReset(): void { }

public onDemoSelectionChange(): void { }
public onDemoSelectionChange(change: SkyDocsDemoControlPanelChange): void { }

public changeFormControls(): void {
this.showRadios = false;
Expand Down
2 changes: 1 addition & 1 deletion src/app/public/modules/safe-html/safe-html.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div
class="sky-docs-safe-html"
[innerHtml]="getTrustedHtml(innerHtml | skyDocsMarkdown)"
[innerHtml]="getTrustedHtml(innerHtml)"
></div>
10 changes: 5 additions & 5 deletions src/app/public/modules/safe-html/safe-html.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
NgModule
} from '@angular/core';
CommonModule
} from '@angular/common';

import {
SkyDocsMarkdownModule
} from '../markdown/markdown.module';
NgModule
} from '@angular/core';

import {
SkyDocsSafeHtmlComponent
Expand All @@ -15,7 +15,7 @@ import {
SkyDocsSafeHtmlComponent
],
imports: [
SkyDocsMarkdownModule
CommonModule
],
exports: [
SkyDocsSafeHtmlComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Anchor link service', function () {

it('should add anchor links to known types', () => {
const service = new SkyDocsAnchorLinkService(mockTypeDefinitionsProvider);
const content = 'Foo FooComponent FooUser Foo2 [[Foo]] [[FooUser]] FooComponent [[Foo]] (FooUser) >Foo< FooUnknown UnknownFoo FooEnum.Foo';
const content = 'Foo FooComponent FooUser Foo2 [[Foo]] [[FooUser]] FooComponent [[Foo]] (FooUser) >Foo< FooUnknown UnknownFoo FooEnum.Foo `FooUser` <a href="#">FooUser</a>';
const result = service.applyTypeAnchorLinks(content);

expect(result).toEqual([
Expand All @@ -59,7 +59,9 @@ describe('Anchor link service', function () {
'>Foo<',
'FooUnknown',
'UnknownFoo',
'<a class="sky-docs-anchor-link" href="#foo-enum">FooEnum</a>.Foo'
'<a class="sky-docs-anchor-link" href="#foo-enum">FooEnum</a>.Foo',
'<a class="sky-docs-anchor-link" href="#foo-user">FooUser</a>',
'<a href="#">FooUser</a>'
].join(' '));
});

Expand Down
10 changes: 10 additions & 0 deletions src/app/public/modules/type-definitions/anchor-link.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class SkyDocsAnchorLinkService {
content = this.removeDoubleSquareBrackets(content);

Object.keys(this.anchorIds).forEach((typeName) => {
content = this.removeBackticks(typeName, content);
const anchorId = this.anchorIds[typeName];
const anchorHtml = `<a class="sky-docs-anchor-link" href="#${anchorId}">${typeName}</a>`;
const regex = createRegex(typeName);
Expand Down Expand Up @@ -74,4 +75,13 @@ export class SkyDocsAnchorLinkService {
return content;
}

/**
* Removes backtick characters around known types to prevent
* the markdown pipe from wrapping them with code elements.
*/
private removeBackticks(typeName: string, content: string): string {
const regexp = new RegExp(`\`(${typeName})\``, 'g');
return content.replace(regexp, typeName);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<sky-docs-safe-html
class="sky-docs-class-definition-description"
[innerHtml]="config.description | skyDocsTypeAnchorLinks"
[innerHtml]="config.description | skyDocsTypeAnchorLinks | skyDocsMarkdown"
></sky-docs-safe-html>

<ng-container *ngIf="config.properties && config.properties.length">
Expand All @@ -20,7 +20,7 @@
[propertyType]="property.type"
>
<sky-docs-safe-html
[innerHtml]="property.description | skyDocsTypeAnchorLinks"
[innerHtml]="property.description | skyDocsTypeAnchorLinks | skyDocsMarkdown"
></sky-docs-safe-html>
</sky-docs-property-definition>
</sky-docs-property-definitions>
Expand All @@ -36,7 +36,7 @@
>
<sky-docs-safe-html
class="sky-docs-class-definition-method-description"
[innerHtml]="method.description | skyDocsTypeAnchorLinks"
[innerHtml]="method.description | skyDocsTypeAnchorLinks | skyDocsMarkdown"
></sky-docs-safe-html>

<sky-code-block
Expand All @@ -58,7 +58,7 @@ <h4 class="sky-docs-class-definition-heading">
[parameterType]="parameter.type"
>
<sky-docs-safe-html
[innerHtml]="parameter.description | skyDocsTypeAnchorLinks"
[innerHtml]="parameter.description | skyDocsTypeAnchorLinks | skyDocsMarkdown"
></sky-docs-safe-html>
</sky-docs-parameter-definition>
</sky-docs-parameter-definitions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<sky-docs-safe-html
class="sky-docs-directive-definition-description"
[innerHtml]="config.description | skyDocsTypeAnchorLinks"
[innerHtml]="config.description | skyDocsTypeAnchorLinks | skyDocsMarkdown"
></sky-docs-safe-html>

<h4 class="sky-docs-directive-definition-h4">
Expand Down Expand Up @@ -44,7 +44,7 @@ <h4 class="sky-docs-directive-definition-h4">
[propertyType]="property.type"
>
<sky-docs-safe-html
[innerHtml]="property.description | skyDocsTypeAnchorLinks"
[innerHtml]="property.description | skyDocsTypeAnchorLinks | skyDocsMarkdown"
></sky-docs-safe-html>
</sky-docs-property-definition>
<sky-docs-property-definition *ngFor="let property of eventProperties"
Expand All @@ -56,7 +56,7 @@ <h4 class="sky-docs-directive-definition-h4">
[propertyType]="property.type"
>
<sky-docs-safe-html
[innerHtml]="property.description | skyDocsTypeAnchorLinks"
[innerHtml]="property.description | skyDocsTypeAnchorLinks | skyDocsMarkdown"
></sky-docs-safe-html>
</sky-docs-property-definition>
</sky-docs-property-definitions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[propertyName]="member.name"
>
<sky-docs-safe-html
[innerHtml]="member.description | skyDocsTypeAnchorLinks"
[innerHtml]="member.description | skyDocsTypeAnchorLinks | skyDocsMarkdown"
></sky-docs-safe-html>
</sky-docs-property-definition>
</sky-docs-property-definitions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<sky-docs-safe-html
class="sky-docs-interface-definition-description"
[innerHtml]="config.description | skyDocsTypeAnchorLinks"
[innerHtml]="config.description | skyDocsTypeAnchorLinks | skyDocsMarkdown"
></sky-docs-safe-html>

<sky-code-block
Expand All @@ -29,7 +29,7 @@
[propertyType]="property.type"
>
<sky-docs-safe-html
[innerHtml]="property.description | skyDocsTypeAnchorLinks"
[innerHtml]="property.description | skyDocsTypeAnchorLinks | skyDocsMarkdown"
></sky-docs-safe-html>
</sky-docs-property-definition>
</sky-docs-property-definitions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</sky-docs-heading-anchor>

<sky-docs-safe-html
[innerHtml]="config.description | skyDocsTypeAnchorLinks"
[innerHtml]="config.description | skyDocsTypeAnchorLinks | skyDocsMarkdown"
></sky-docs-safe-html>

<ng-container *ngIf="config.codeExample">
Expand All @@ -32,7 +32,7 @@ <h4 class="sky-docs-pipe-definition-heading">
[parameterType]="config.inputValue.type"
>
<sky-docs-safe-html
[innerHtml]="config.inputValue.description | skyDocsTypeAnchorLinks"
[innerHtml]="config.inputValue.description | skyDocsTypeAnchorLinks | skyDocsMarkdown"
></sky-docs-safe-html>
</sky-docs-parameter-definition>
</sky-docs-parameter-definitions>
Expand All @@ -49,7 +49,7 @@ <h4 class="sky-docs-pipe-definition-heading">
[parameterType]="parameter.type"
>
<sky-docs-safe-html
[innerHtml]="parameter.description | skyDocsTypeAnchorLinks"
[innerHtml]="parameter.description | skyDocsTypeAnchorLinks | skyDocsMarkdown"
></sky-docs-safe-html>
</sky-docs-parameter-definition>
</sky-docs-parameter-definitions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<sky-docs-safe-html
class="sky-docs-type-alias-definition-description"
[innerHtml]="config.description | skyDocsTypeAnchorLinks"
[innerHtml]="config.description | skyDocsTypeAnchorLinks | skyDocsMarkdown"
></sky-docs-safe-html>

<sky-code-block
Expand Down Expand Up @@ -44,7 +44,7 @@ <h4 class="sky-docs-type-alias-definition-heading">
[parameterType]="parameter.type"
>
<sky-docs-safe-html
[innerHtml]="parameter.description | skyDocsTypeAnchorLinks"
[innerHtml]="parameter.description | skyDocsTypeAnchorLinks | skyDocsMarkdown"
></sky-docs-safe-html>
</sky-docs-parameter-definition>
</sky-docs-parameter-definitions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import {
expect
} from '@skyux-sdk/testing';

import * as mockTypeDocJson from './fixtures/mock-documentation.json';

import {
SkyDocsTypeDefinitionsProvider
} from './type-definitions-provider';
Expand All @@ -10,7 +12,11 @@ import {
SkyDocsTypeDefinitionsService
} from './type-definitions.service';

import * as mockTypeDocJson from './fixtures/mock-documentation.json';
import {
SkyDocsTypeAliasFunctionDefinition,
SkyDocsTypeAliasIndexSignatureDefinition,
SkyDocsTypeAliasUnionDefinition
} from './type-alias-definition';

describe('Type definitions service', function () {

Expand Down Expand Up @@ -425,20 +431,20 @@ describe('Type definitions service', function () {
}
],
returnType: 'FooUser'
},
} as SkyDocsTypeAliasFunctionDefinition,
{
anchorId: 'type-alias-footypeindexsignature',
description: '',
name: 'FooTypeIndexSignature',
keyName: '_',
valueType: 'FooUser'
},
} as SkyDocsTypeAliasIndexSignatureDefinition,
{
anchorId: 'type-alias-footypeunioncomplex',
description: 'This is the description for FooTypeUnionComplex. It can be of type [[FooDate]].',
name: 'FooTypeUnionComplex',
types: [ 'string', 'FooDate', 'number', 'false', '1' ]
},
} as SkyDocsTypeAliasUnionDefinition,
{
anchorId: 'type-alias-footypeunionstring',
description: 'This is the description for FooTypeUnionString.',
Expand All @@ -465,6 +471,15 @@ describe('Type definitions service', function () {
});
});

it('should warn if the provider does not include types', () => {
(definitionsProvider as any).typeDefinitions = [];

const spy = spyOn(console, 'warn');
const service = new SkyDocsTypeDefinitionsService(definitionsProvider);
service.getTypeDefinitions('/src/app/public/modules/empty/');
expect(spy).toHaveBeenCalledWith('Type definitions were not found for location: modules/empty/');
});

it('should throw an error if the source code path does not end in a slash', () => {
const service = new SkyDocsTypeDefinitionsService(definitionsProvider);
expect(function () {
Expand Down
2 changes: 0 additions & 2 deletions src/app/public/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ export * from './modules/markdown/markdown.pipe';

export * from './modules/module-info/module-info.module';

export * from './modules/safe-html/safe-html.module';

export * from './modules/shared/docs-tools-component-info';
export * from './modules/shared/docs-tools-options';
export * from './modules/shared/docs-tools-supportal.service';
Expand Down

0 comments on commit cb676e4

Please sign in to comment.