Skip to content

Commit

Permalink
fixup! feat(compiler): copy dock block from component to generated types
Browse files Browse the repository at this point in the history
  • Loading branch information
jgroth authored and alicewriteswrongs committed Dec 1, 2022
1 parent cb0cc85 commit 04d7731
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
13 changes: 11 additions & 2 deletions src/utils/test/util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ describe('util', () => {
});
});

describe('addDockBlock', () => {
describe('addDocBlock', () => {
let str: string;
let docs: d.CompilerJsDoc;

Expand Down Expand Up @@ -235,8 +235,17 @@ interface Foo extends Components.Foo, HTMLStencilElement {`);
expect(util.addDocBlock(str, docs).includes('@internal')).toBeFalsy();
});

it('excludes empty lines', () => {
docs.text = '';
str = ' ' + str;
expect(util.addDocBlock(str, docs, 4)).toEqual(` /**
* @deprecated only for testing
*/
interface Foo extends Components.Foo, HTMLStencilElement {`);
});

it.each([[null], [undefined], [{ tags: [], text: '' }]])(
'does not add a dock block when docs are empty (%j)',
'does not add a doc block when docs are empty (%j)',
(docs) => {
expect(util.addDocBlock(str, docs)).toEqual(str);
}
Expand Down
4 changes: 3 additions & 1 deletion src/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ function getDocBlockLines(docs: d.CompilerJsDoc): string[] {
...docs.tags
.filter((tag) => !SUPPRESSED_JSDOC_TAGS.includes(tag.name))
.map((tag) => `@${tag.name} ${tag.text || ''}`.split(lineBreakRegex)),
].flat();
]
.flat()
.filter(Boolean);
}

/**
Expand Down
3 changes: 0 additions & 3 deletions test/karma/test-app/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ export namespace Components {
interface ShadowDomBasicRoot {
}
/**
*
* @virtualProp {string} colormode - The mode determines which platform styles to use.
*/
interface ShadowDomMode {
Expand Down Expand Up @@ -873,7 +872,6 @@ declare global {
new (): HTMLShadowDomBasicRootElement;
};
/**
*
* @virtualProp {string} colormode - The mode determines which platform styles to use.
*/
interface HTMLShadowDomModeElement extends Components.ShadowDomMode, HTMLStencilElement {
Expand Down Expand Up @@ -1826,7 +1824,6 @@ declare module "@stencil/core" {
"shadow-dom-basic": LocalJSX.ShadowDomBasic & JSXBase.HTMLAttributes<HTMLShadowDomBasicElement>;
"shadow-dom-basic-root": LocalJSX.ShadowDomBasicRoot & JSXBase.HTMLAttributes<HTMLShadowDomBasicRootElement>;
/**
*
* @virtualProp {string} colormode - The mode determines which platform styles to use.
*/
"shadow-dom-mode": LocalJSX.ShadowDomMode & JSXBase.HTMLAttributes<HTMLShadowDomModeElement>;
Expand Down

0 comments on commit 04d7731

Please sign in to comment.