Skip to content

Commit 9fe1930

Browse files
committed
feat: rename flowTypeHandler to codeTypeHandler
1 parent 98fa11f commit 9fe1930

File tree

5 files changed

+35
-37
lines changed

5 files changed

+35
-37
lines changed

src/handlers/__tests__/__snapshots__/flowTypeHandler-test.ts.snap renamed to src/handlers/__tests__/__snapshots__/codeTypeHandler-test.ts.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`flowTypeHandler TypeAlias class definition for flow <0.53 ignores hash map entry 1`] = `
3+
exports[`codeTypeHandler TypeAlias class definition for flow <0.53 ignores hash map entry 1`] = `
44
Object {
55
"bar": Object {
66
"description": "",
@@ -10,7 +10,7 @@ Object {
1010
}
1111
`;
1212

13-
exports[`flowTypeHandler TypeAlias class definition for flow >=0.53 with State ignores hash map entry 1`] = `
13+
exports[`codeTypeHandler TypeAlias class definition for flow >=0.53 with State ignores hash map entry 1`] = `
1414
Object {
1515
"bar": Object {
1616
"description": "",
@@ -20,7 +20,7 @@ Object {
2020
}
2121
`;
2222

23-
exports[`flowTypeHandler TypeAlias class definition for flow >=0.53 without State ignores hash map entry 1`] = `
23+
exports[`codeTypeHandler TypeAlias class definition for flow >=0.53 without State ignores hash map entry 1`] = `
2424
Object {
2525
"bar": Object {
2626
"description": "",
@@ -30,7 +30,7 @@ Object {
3030
}
3131
`;
3232

33-
exports[`flowTypeHandler TypeAlias class definition with inline props ignores hash map entry 1`] = `
33+
exports[`codeTypeHandler TypeAlias class definition with inline props ignores hash map entry 1`] = `
3434
Object {
3535
"bar": Object {
3636
"description": "",
@@ -40,7 +40,7 @@ Object {
4040
}
4141
`;
4242

43-
exports[`flowTypeHandler TypeAlias stateless component ignores hash map entry 1`] = `
43+
exports[`codeTypeHandler TypeAlias stateless component ignores hash map entry 1`] = `
4444
Object {
4545
"bar": Object {
4646
"description": "",
@@ -50,7 +50,7 @@ Object {
5050
}
5151
`;
5252

53-
exports[`flowTypeHandler does support utility types inline 1`] = `
53+
exports[`codeTypeHandler does support utility types inline 1`] = `
5454
Object {
5555
"foo": Object {
5656
"description": "",
@@ -60,7 +60,7 @@ Object {
6060
}
6161
`;
6262

63-
exports[`flowTypeHandler imported prop types imported 1`] = `
63+
exports[`codeTypeHandler imported prop types imported 1`] = `
6464
Object {
6565
"abc": Object {
6666
"description": "",
@@ -95,7 +95,7 @@ Object {
9595
}
9696
`;
9797

98-
exports[`flowTypeHandler imported prop types type imported 1`] = `
98+
exports[`codeTypeHandler imported prop types type imported 1`] = `
9999
Object {
100100
"abc": Object {
101101
"description": "",

src/handlers/__tests__/flowTypeHandler-test.ts renamed to src/handlers/__tests__/codeTypeHandler-test.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { parse, makeMockImporter } from '../../../tests/utils';
22
import Documentation from '../../Documentation';
3-
import flowTypeHandler from '../flowTypeHandler';
3+
import codeTypeHandler from '../codeTypeHandler';
44
import type DocumentationMock from '../../__mocks__/Documentation';
55
import type {
66
ArrowFunctionExpression,
@@ -18,7 +18,7 @@ jest.mock('../../utils/getFlowType', () => ({
1818
__esModule: true,
1919
}));
2020

21-
describe('flowTypeHandler', () => {
21+
describe('codeTypeHandler', () => {
2222
let documentation: Documentation & DocumentationMock;
2323

2424
beforeEach(() => {
@@ -61,7 +61,7 @@ describe('flowTypeHandler', () => {
6161
`;
6262
const definition = getSrc(flowTypesSrc);
6363

64-
flowTypeHandler(documentation, definition);
64+
codeTypeHandler(documentation, definition);
6565

6666
expect(documentation.descriptors).toEqual({
6767
foo: {
@@ -91,7 +91,7 @@ describe('flowTypeHandler', () => {
9191
`;
9292
const definition = getSrc(flowTypesSrc);
9393

94-
flowTypeHandler(documentation, definition);
94+
codeTypeHandler(documentation, definition);
9595

9696
expect(documentation.descriptors).toEqual({
9797
foo: {
@@ -116,7 +116,7 @@ describe('flowTypeHandler', () => {
116116
`;
117117
const definition = getSrc(flowTypesSrc);
118118

119-
flowTypeHandler(documentation, definition);
119+
codeTypeHandler(documentation, definition);
120120

121121
expect(documentation.descriptors).toMatchSnapshot();
122122
});
@@ -130,7 +130,7 @@ describe('flowTypeHandler', () => {
130130
`;
131131
const definition = getSrc(flowTypesSrc);
132132

133-
flowTypeHandler(documentation, definition);
133+
codeTypeHandler(documentation, definition);
134134

135135
expect(documentation.descriptors).toEqual({
136136
foo: {
@@ -154,7 +154,7 @@ describe('flowTypeHandler', () => {
154154
`;
155155
const definition = getSrc(flowTypesSrc);
156156

157-
flowTypeHandler(documentation, definition);
157+
codeTypeHandler(documentation, definition);
158158

159159
expect(documentation.descriptors).toEqual({
160160
foo: {
@@ -176,7 +176,7 @@ describe('flowTypeHandler', () => {
176176

177177
const definition = getSrc(flowTypesSrc);
178178

179-
flowTypeHandler(documentation, definition);
179+
codeTypeHandler(documentation, definition);
180180

181181
expect(documentation.descriptors).toEqual({
182182
foo: {
@@ -246,22 +246,22 @@ describe('flowTypeHandler', () => {
246246
it('ObjectExpression', () => {
247247
const definition = parse.expression<ObjectExpression>('{fooBar: 42}');
248248

249-
expect(() => flowTypeHandler(documentation, definition)).not.toThrow();
249+
expect(() => codeTypeHandler(documentation, definition)).not.toThrow();
250250
});
251251

252252
it('ClassDeclaration', () => {
253253
const definition = parse.statement<ClassDeclaration>(
254254
'class Foo extends Component {}',
255255
);
256256

257-
expect(() => flowTypeHandler(documentation, definition)).not.toThrow();
257+
expect(() => codeTypeHandler(documentation, definition)).not.toThrow();
258258
});
259259

260260
it('ArrowFunctionExpression', () => {
261261
const definition =
262262
parse.statement<ArrowFunctionExpression>('() => <div />');
263263

264-
expect(() => flowTypeHandler(documentation, definition)).not.toThrow();
264+
expect(() => codeTypeHandler(documentation, definition)).not.toThrow();
265265
});
266266
});
267267

@@ -275,7 +275,7 @@ describe('flowTypeHandler', () => {
275275
)
276276
.get('expression') as NodePath<ArrowFunctionExpression>;
277277

278-
flowTypeHandler(documentation, definition);
278+
codeTypeHandler(documentation, definition);
279279

280280
expect(documentation.descriptors).toEqual({
281281
foo: {
@@ -295,7 +295,7 @@ describe('flowTypeHandler', () => {
295295
)
296296
.get('expression') as NodePath<ArrowFunctionExpression>;
297297

298-
expect(() => flowTypeHandler(documentation, definition)).not.toThrow();
298+
expect(() => codeTypeHandler(documentation, definition)).not.toThrow();
299299
expect(documentation.descriptors).toMatchSnapshot();
300300
});
301301

@@ -310,7 +310,7 @@ describe('flowTypeHandler', () => {
310310
)
311311
.get('expression') as NodePath<ArrowFunctionExpression>;
312312

313-
expect(() => flowTypeHandler(documentation, definition)).not.toThrow();
313+
expect(() => codeTypeHandler(documentation, definition)).not.toThrow();
314314
expect(documentation.descriptors).toEqual({});
315315
});
316316

@@ -326,7 +326,7 @@ describe('flowTypeHandler', () => {
326326
)
327327
.get('expression') as NodePath<ArrowFunctionExpression>;
328328

329-
expect(() => flowTypeHandler(documentation, definition)).not.toThrow();
329+
expect(() => codeTypeHandler(documentation, definition)).not.toThrow();
330330
expect(documentation.descriptors).toEqual({});
331331
});
332332

@@ -341,7 +341,7 @@ describe('flowTypeHandler', () => {
341341
)
342342
.get('expression') as NodePath<ArrowFunctionExpression>;
343343

344-
expect(() => flowTypeHandler(documentation, definition)).not.toThrow();
344+
expect(() => codeTypeHandler(documentation, definition)).not.toThrow();
345345
expect(documentation.descriptors).toMatchSnapshot();
346346
});
347347

@@ -355,7 +355,7 @@ describe('flowTypeHandler', () => {
355355
)
356356
.get('expression') as NodePath<ArrowFunctionExpression>;
357357

358-
expect(() => flowTypeHandler(documentation, definition)).not.toThrow();
358+
expect(() => codeTypeHandler(documentation, definition)).not.toThrow();
359359
expect(documentation.descriptors).toEqual({});
360360
});
361361

@@ -370,7 +370,7 @@ describe('flowTypeHandler', () => {
370370
)
371371
.get('expression') as NodePath<ArrowFunctionExpression>;
372372

373-
expect(() => flowTypeHandler(documentation, definition)).not.toThrow();
373+
expect(() => codeTypeHandler(documentation, definition)).not.toThrow();
374374
expect(documentation.descriptors).toMatchSnapshot();
375375
});
376376

@@ -384,7 +384,7 @@ describe('flowTypeHandler', () => {
384384
)
385385
.get('expression') as NodePath<ArrowFunctionExpression>;
386386

387-
expect(() => flowTypeHandler(documentation, definition)).not.toThrow();
387+
expect(() => codeTypeHandler(documentation, definition)).not.toThrow();
388388
expect(documentation.descriptors).toEqual({});
389389
});
390390

@@ -398,7 +398,7 @@ describe('flowTypeHandler', () => {
398398
)
399399
.get('expression') as NodePath<ArrowFunctionExpression>;
400400

401-
expect(() => flowTypeHandler(documentation, definition)).not.toThrow();
401+
expect(() => codeTypeHandler(documentation, definition)).not.toThrow();
402402
expect(documentation.descriptors).toEqual({});
403403
});
404404
});
@@ -410,7 +410,7 @@ describe('flowTypeHandler', () => {
410410
type Props = { foo: string };
411411
React.forwardRef((props: Props, ref) => <div ref={ref}>{props.foo}</div>);
412412
`;
413-
flowTypeHandler(documentation, parse.expressionLast<CallExpression>(src));
413+
codeTypeHandler(documentation, parse.expressionLast<CallExpression>(src));
414414
expect(documentation.descriptors).toEqual({
415415
foo: {
416416
flowType: {},
@@ -427,7 +427,7 @@ describe('flowTypeHandler', () => {
427427
const ComponentImpl = (props: Props, ref) => <div ref={ref}>{props.foo}</div>;
428428
React.forwardRef(ComponentImpl);
429429
`;
430-
flowTypeHandler(documentation, parse.expressionLast<CallExpression>(src));
430+
codeTypeHandler(documentation, parse.expressionLast<CallExpression>(src));
431431
expect(documentation.descriptors).toEqual({
432432
foo: {
433433
flowType: {},
@@ -444,7 +444,7 @@ describe('flowTypeHandler', () => {
444444
let Component = (props: Props, ref) => <div ref={ref}>{props.foo}</div>;
445445
Component = React.forwardRef(Component);
446446
`;
447-
flowTypeHandler(
447+
codeTypeHandler(
448448
documentation,
449449
parse.expressionLast(src).get('right') as NodePath<CallExpression>,
450450
);

src/handlers/flowTypeHandler.ts renamed to src/handlers/codeTypeHandler.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,8 @@ function setPropDescriptor(
9494
* This handler tries to find flow Type annotated react components and extract
9595
* its types to the documentation. It also extracts docblock comments which are
9696
* inlined in the type definition.
97-
*
98-
* TODO either rename this handler or split in flow vs ts
9997
*/
100-
const flowTypeHandler: Handler = function (
98+
const codeTypeHandler: Handler = function (
10199
documentation: Documentation,
102100
componentDefinition: NodePath<ComponentNode>,
103101
): void {
@@ -117,4 +115,4 @@ const flowTypeHandler: Handler = function (
117115
);
118116
};
119117

120-
export default flowTypeHandler;
118+
export default codeTypeHandler;

src/handlers/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export { default as componentMethodsHandler } from './componentMethodsHandler';
77
export { default as componentMethodsJsDocHandler } from './componentMethodsJsDocHandler';
88
export { default as defaultPropsHandler } from './defaultPropsHandler';
99
export { default as displayNameHandler } from './displayNameHandler';
10-
export { default as flowTypeHandler } from './flowTypeHandler';
10+
export { default as codeTypeHandler } from './codeTypeHandler';
1111
export { default as propDocBlockHandler } from './propDocBlockHandler';
1212
export { default as propTypeCompositionHandler } from './propTypeCompositionHandler';
1313
export {

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const defaultHandlers: Handler[] = [
1717
allHandlers.childContextTypeHandler,
1818
allHandlers.propTypeCompositionHandler,
1919
allHandlers.propDocBlockHandler,
20-
allHandlers.flowTypeHandler,
20+
allHandlers.codeTypeHandler,
2121
allHandlers.defaultPropsHandler,
2222
allHandlers.componentDocblockHandler,
2323
allHandlers.displayNameHandler,

0 commit comments

Comments
 (0)