Skip to content

Commit

Permalink
fix: doc template type
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Nov 17, 2020
1 parent 0beb43a commit af326e7
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
"program": "${workspaceFolder}/node_modules/.bin/jest",
"cwd": "${workspaceFolder}/core/instrument",
"args": [
"mdx-template",
"esm-template",
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
Expand Down
2 changes: 1 addition & 1 deletion core/instrument/src/babel/esm-stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const extractCSFStories = (
if (template) {
doc.template = extractFunction(
path as NodePath,
{ init: template.value },
{ type: 'VariableDeclarator', init: template.value },
template.key.name,
) as Document['template'];
}
Expand Down
95 changes: 93 additions & 2 deletions core/instrument/test/__snapshots__/esm-template.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,51 @@ export const Button: FC<ButtonProps> = props => (
"dateModified": 2020-11-16T21:16:17.737Z,
"package": "f4ca1c7bc1501c3fcaf51e85d24145e2",
"smartControls": false,
"template": undefined,
"template": Object {
"arguments": Array [
Object {
"loc": Object {
"end": Object {
"column": 5,
"line": 0,
},
"start": Object {
"column": 0,
"line": 0,
},
},
"name": "props",
"usage": Array [
Object {
"loc": Object {
"end": Object {
"column": 26,
"line": 0,
},
"start": Object {
"column": 21,
"line": 0,
},
},
"shorthand": undefined,
},
],
"value": "props",
},
],
"id": "template",
"loc": Object {
"end": Object {
"column": 42,
"line": 10,
},
"start": Object {
"column": 12,
"line": 10,
},
},
"name": "template",
},
"title": "Introduction/Template doc",
},
"packages": Object {
Expand Down Expand Up @@ -143,7 +187,54 @@ export const Button: FC<ButtonProps> = props => (
"version": "1.40.5",
},
},
"stories": Object {},
"stories": Object {
"John": Object {
"arguments": Array [
Object {
"loc": Object {
"end": Object {
"column": 5,
"line": 0,
},
"start": Object {
"column": 0,
"line": 0,
},
},
"name": "props",
"usage": Array [
Object {
"loc": Object {
"end": Object {
"column": 26,
"line": 0,
},
"start": Object {
"column": 21,
"line": 0,
},
},
"shorthand": undefined,
},
],
"value": "props",
},
],
"id": "John",
"loc": Object {
"end": Object {
"column": 42,
"line": 10,
},
"start": Object {
"column": 12,
"line": 10,
},
},
"name": "John",
"source": "props => <Button {...props} />",
},
},
"transformed": "import React from 'react';
import { Document } from '@component-controls/core';
import { ButtonProps, Button } from '../../components/button-props';
Expand Down

0 comments on commit af326e7

Please sign in to comment.