Skip to content

Commit 7509a12

Browse files
committed
Add simple usage example to website
1 parent 561044f commit 7509a12

File tree

1 file changed

+39
-0
lines changed
  • packages/website/pages/docs/getting-started

1 file changed

+39
-0
lines changed

packages/website/pages/docs/getting-started/nodejs.mdx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,42 @@ yarn add react-docgen
2929

3030
</Tab>
3131
</Tabs>
32+
33+
## Usage
34+
35+
Here is an easy example
36+
37+
```ts filename="index.tsx" copy
38+
import { parse } from 'react-docgen';
39+
40+
const code = `
41+
/** My first component */
42+
export default ({ name }: { name: string }) => <div>{{name}}</div>;
43+
`;
44+
45+
const documentation = parse(code);
46+
47+
console.log(documentation);
48+
```
49+
50+
The documentation that this script is going to print will look like this. If you
51+
want to know more about the structure you can head over to the reference of the
52+
[Documentation](../reference/documentation)
53+
54+
```json
55+
[
56+
{
57+
"description": "My first component",
58+
"methods": [],
59+
"props": {
60+
"name": {
61+
"required": true,
62+
"tsType": {
63+
"name": "string"
64+
},
65+
"description": ""
66+
}
67+
}
68+
}
69+
]
70+
```

0 commit comments

Comments
 (0)