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 committed Nov 17, 2022
1 parent a09773a commit a21588d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/compiler/types/generate-app-types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addDockBlock, normalizePath } from '@utils';
import { addDocBlock, normalizePath } from '@utils';
import { isAbsolute, relative, resolve } from 'path';

import type * as d from '../../declarations';
Expand Down Expand Up @@ -150,7 +150,7 @@ const generateComponentTypesFile = (config: d.Config, buildCtx: d.BuildCtx, areT
...modules.map((m) => {
const docs = components.find((c) => c.tagName === m.tagName).docs;

return addDockBlock(
return addDocBlock(
` "${m.tagName}": LocalJSX.${m.tagNameAsPascal} & JSXBase.HTMLAttributes<${m.htmlElementName}>;`,
docs,
12
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/types/generate-component-types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addDockBlock, dashToPascalCase, sortBy } from '@utils';
import { addDocBlock, dashToPascalCase, sortBy } from '@utils';

import type * as d from '../../declarations';
import { generateEventTypes } from './generate-event-types';
Expand Down Expand Up @@ -34,7 +34,7 @@ export const generateComponentTypes = (
const jsxAttributes = attributesToMultiLineString([...propAttributes, ...eventAttributes], true, areTypesInternal);

const element = [
addDockBlock(
addDocBlock(
` interface ${htmlElementName} extends Components.${tagNameAsPascal}, HTMLStencilElement {`,
cmp.docs,
4
Expand All @@ -50,8 +50,8 @@ export const generateComponentTypes = (
tagName,
tagNameAsPascal,
htmlElementName,
component: addDockBlock(` interface ${tagNameAsPascal} {\n${componentAttributes} }`, cmp.docs, 4),
jsx: addDockBlock(` interface ${tagNameAsPascal} {\n${jsxAttributes} }`, cmp.docs, 2),
component: addDocBlock(` interface ${tagNameAsPascal} {\n${componentAttributes} }`, cmp.docs, 4),
jsx: addDocBlock(` interface ${tagNameAsPascal} {\n${jsxAttributes} }`, cmp.docs, 2),
element: element.join(`\n`),
};
};
Expand Down
8 changes: 4 additions & 4 deletions src/utils/test/util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ describe('util', () => {
});

it('adds a doc block to the string', () => {
expect(util.addDockBlock(str, docs)).toEqual(`/**
expect(util.addDocBlock(str, docs)).toEqual(`/**
* Lorem ipsum
* @deprecated only for testing
*/
Expand All @@ -223,7 +223,7 @@ interface Foo extends Components.Foo, HTMLStencilElement {`);

it('indents the doc block correctly', () => {
str = ' ' + str;
expect(util.addDockBlock(str, docs, 4)).toEqual(` /**
expect(util.addDocBlock(str, docs, 4)).toEqual(` /**
* Lorem ipsum
* @deprecated only for testing
*/
Expand All @@ -232,13 +232,13 @@ interface Foo extends Components.Foo, HTMLStencilElement {`);

it('excludes the @internal tag', () => {
docs.tags.push({ name: 'internal' });
expect(util.addDockBlock(str, docs).includes('@internal')).toBeFalsy();
expect(util.addDocBlock(str, docs).includes('@internal')).toBeFalsy();
});

it.each([[null], [undefined], [{ tags: [], text: '' }]])(
'does not add a dock block when docs are empty (%j)',
(docs) => {
expect(util.addDockBlock(str, docs)).toEqual(str);
expect(util.addDocBlock(str, docs)).toEqual(str);
}
);
});
Expand Down
2 changes: 1 addition & 1 deletion src/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ ${docs.tags
* @param indentation number of spaces to indent the block with
* @returns the doc block
*/
export function addDockBlock(str: string, docs?: d.CompilerJsDoc, indentation: number = 0): string {
export function addDocBlock(str: string, docs?: d.CompilerJsDoc, indentation: number = 0): string {
if (!docs) {
return str;
}
Expand Down

0 comments on commit a21588d

Please sign in to comment.