Skip to content
This repository was archived by the owner on Jan 23, 2024. It is now read-only.

Commit 319acba

Browse files
committed
chore: add plop command to generate component docs
1 parent 336a6ab commit 319acba

File tree

7 files changed

+2998
-2324
lines changed

7 files changed

+2998
-2324
lines changed

.prettierignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
dist
22
node_modules
33
.next
4-
build
4+
build
5+
*.hbs

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"build": "next build",
77
"lint": "next lint",
88
"prepare": "husky install",
9-
"postinstall": "pnpm-deduplicate",
109
"gen:theme-typings": "chakra-cli tokens theme.ts",
1110
"avatars:gen": "tsx scripts/avatars.ts",
1211
"members:gen": "tsx scripts/all-members.ts",
@@ -18,6 +17,7 @@
1817
"clean": "rm -rf pnpm-lock.yaml node_modules",
1918
"reinstall": "pnpm clean && pnpm i",
2019
"deps": "pnpm up '@chakra-ui/*' --latest",
20+
"create:docs": "plop component",
2121
"content": "contentlayer build --clearCache"
2222
},
2323
"dependencies": {
@@ -54,6 +54,7 @@
5454
"next-contentlayer": "0.3.0",
5555
"next-seo": "^5.4.0",
5656
"octokit": "^2.0.4",
57+
"plop": "^3.1.2",
5758
"prism-react-renderer": "^1.3.5",
5859
"react": "^18.1.0",
5960
"react-dom": "^18.1.0",

plop/component/props.mdx.hbs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
id: {{componentName}}
3+
scope: props
4+
---
5+
6+
## Props
7+
8+
### {{component}} Props
9+
10+
<PropsTable of='{{component}}' />

plop/component/theming.mdx.hbs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
id: accordion
3+
scope: theming
4+
---
5+
6+
## Theming
7+
8+
The `${{component}}` component is a multipart component. The styling needs to be
9+
applied to each part specifically.
10+
11+
> To learn more about styling multipart components, visit the
12+
> [Component Style](/docs/styled-system/component-style#styling-multipart-components)
13+
> page.
14+
15+
### Anatomy
16+

plop/component/usage.mdx.hbs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
id: accordion
3+
title: {{component}}
4+
category: 'disclosure'
5+
package: '@chakra-ui/{{componentName}}'
6+
description: TODO
7+
---
8+
9+
## Import
10+
11+
Chakra UI exports the followings components:
12+
13+
- `{{component}}`: Add description
14+
15+
```js
16+
import { {{component}} } from '@chakra-ui/react'
17+
```
18+
19+
## Usage

plopfile.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const dashCase = (str) => {
2+
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()
3+
}
4+
5+
/**
6+
* @param {import("plop").NodePlopAPI} plop
7+
*/
8+
module.exports = function main(plop) {
9+
plop.setGenerator('component', {
10+
description: 'Document a component',
11+
prompts: [
12+
{
13+
type: 'input',
14+
name: 'component',
15+
message: 'Enter component name:',
16+
},
17+
],
18+
actions(answers) {
19+
const actions = []
20+
if (!answers) return actions
21+
22+
const { component } = answers
23+
24+
actions.push({
25+
type: 'addMany',
26+
templateFiles: 'plop/component/**',
27+
destination: `./content/docs/components/{{dashCase component}}`,
28+
base: 'plop/component',
29+
data: { component, componentName: dashCase(component) },
30+
abortOnFail: true,
31+
})
32+
33+
return actions
34+
},
35+
})
36+
}

0 commit comments

Comments
 (0)