|
9 | 9 |
|
10 | 10 | Your automated markdown maintainer! |
11 | 11 |
|
12 | | -> [!NOTE] |
13 | | -> This project is in the early stages and under development. |
| 12 | +📚 Read more in the [Documentation](https://automd.unjs.io) |
14 | 13 |
|
15 | 14 | ## 🦴 Used by |
16 | 15 |
|
17 | 16 | - [unjs/ufo](https://github.com/unjs/ufo) |
18 | 17 | - [unjs/omark](https://github.com/unjs/omark) |
19 | 18 | - [unjs/nypm](https://github.com/unjs/nypm) |
20 | 19 |
|
21 | | -## Usage |
22 | | - |
23 | | -Automd scans for the annotation comments within the markdown document and updates their contents using built-in generators. |
24 | | - |
25 | | -The syntax is like this: |
26 | | - |
27 | | - <!-- automd:generator [...args] --> |
28 | | - <!-- /automd --> |
29 | | - |
30 | | -### Using CLI |
31 | | - |
32 | | -The easiest way to use automd is to use the CLI. You can install automd and add it to the `build` or `release` command in `package.json` or directly run `npx automd` in your project. |
33 | | - |
34 | | -```sh |
35 | | -npx automd@latest |
36 | | -``` |
37 | | - |
38 | | -By default, the `README.md` file in the current working directory will be used as the target. |
39 | | - |
40 | | -You can use `--dir` and `--file` arguments to customize the default behavior to operate on any other markdown file. |
41 | | - |
42 | | -### Configuration |
43 | | - |
44 | | -You can specify configuration in `.automdrc` or `automd.config` (`js`, `ts`, `mjs`, `cjs` or `json` format) (powered by [unjs/c12](https://c12.unjs.io)). |
45 | | - |
46 | | -Example: `automd.config.js` |
47 | | - |
48 | | -```ts |
49 | | -/** @type {import("automd").Config} */ |
50 | | -export default { |
51 | | - file: "DOCS.md", |
52 | | -}; |
53 | | -``` |
54 | | - |
55 | | -#### Config |
56 | | - |
57 | | -- `dir`: Working directory (defaults to the current working directory). |
58 | | - - You can use `--dir` to override with CLI. |
59 | | -- `file`: The markdown file name or path (relative to `dir`). |
60 | | - - You can use `--file` to override with CLI. |
61 | | -- `generators`: A map of generator names to custom generators. |
62 | | - - You can use `automd.config` to specify them. |
63 | | - |
64 | | -### Programmatic API |
65 | | - |
66 | | -[WIP] |
67 | | - |
68 | | -## Generators |
69 | | - |
70 | | -There are several available generators for automd each supporting different arguments. |
71 | | - |
72 | | -See [open issues](https://github.com/unjs/automd/issues?q=is%3Aopen+is%3Aissue+label%3Agenerator) for proposed generators and feel free to suggest any generator ideas to be included! |
73 | | - |
74 | | -### `jsdocs` |
75 | | - |
76 | | -The `jsdocs` generator can automatically read through your code and extract and sync documentation of function exports leveraging JSDocs and TypeScript hints. |
77 | | - |
78 | | -Internally it uses [untyped](https://untyped.unjs.io/) and [jiti](https://github.com/unjs/jiti) loader for JSDocs parsing and TypeScript support. |
79 | | - |
80 | | -#### Usage |
81 | | - |
82 | | - <!-- automd:jsdocs src="./src/index" --> |
83 | | - <!-- /automd --> |
84 | | - |
85 | | -> [!NOTE] |
86 | | -> Make sure you have some utility exports in `src/index.ts` annotated with JSDocs. |
87 | | -
|
88 | | -**Updated Result:** |
89 | | - |
90 | | - <!-- automd:jsdocs src="./src/index" --> |
91 | | - |
92 | | - ### `add(a, b)` |
93 | | - |
94 | | - Adds two numbers together. |
95 | | - |
96 | | - **Example:** |
97 | | - ```js |
98 | | - add(1, 2); // 3 |
99 | | - ``` |
100 | | - |
101 | | - <!-- /automd --> |
102 | | - |
103 | | -#### Arguments |
104 | | - |
105 | | -- `src`: Path to the source file. The default is `./src/index` and can be omitted. |
106 | | -- `headingLevel`: Nested level for markdown group headings (default is `2` => `##`). Note: Each function uses `headingLevel+1` for the title in nested levels. |
107 | | -- `group`: Only render function exports annotated with `@group name`. By default, there is no group filter. Value can be a string or an array of strings. |
108 | | - |
109 | | -### `pm-install|pm-i` |
110 | | - |
111 | | -The `pm-install|pm-i` generator generates installation commands for several JavaScript package managers. |
112 | | - |
113 | | -#### Usage |
114 | | - |
115 | | - <!-- automd:pm-install name=package-name dev --> |
116 | | - <!-- /automd --> |
117 | | - |
118 | | -**Updated Result:** |
119 | | - |
120 | | - <!-- automd:pm-install name=package-name dev --> |
121 | | - |
122 | | - ```sh |
123 | | - # ✨ Auto-detect |
124 | | - npx nypm i -D package-name |
125 | | - |
126 | | - # npm |
127 | | - npm install -D package-name |
128 | | - |
129 | | - # yarn |
130 | | - yarn add -D package-name |
131 | | - |
132 | | - # pnpm |
133 | | - pnpm install -D package-name |
134 | | - |
135 | | - # bun |
136 | | - bun install -D package-name |
137 | | - ``` |
138 | | - |
139 | | - <!-- /automd --> |
140 | | - |
141 | | -#### Arguments |
142 | | - |
143 | | -- `name`: The package name (by default tries to read from the `name` field in `package.json`). |
144 | | -- `dev`: Install as a dev dependency (defaults to `false`). |
145 | | -- `separate`: Separate code blocks for each package manager (defaults to `false`). |
146 | | -- `auto`: Auto-detect package manager using [unjs/nypm](https://github.com/unjs/nypm#-nypm) (defaults to `true`). |
147 | | - |
148 | | -### `pm-x` |
149 | | - |
150 | | -The `pm-x` generator generates commands for running/executing a package through JavaScript package managers. |
151 | | - |
152 | | -#### Usage |
153 | | - |
154 | | - <!-- automd:pm-x name="package-name" args="[files] <flags>" --> |
155 | | - <!-- /automd --> |
156 | | - |
157 | | -**Updated Result:** |
158 | | - |
159 | | - <!-- automd:pm-x name="package-name" args="[files] <flags>" --> |
160 | | - |
161 | | - ```sh |
162 | | - # npm |
163 | | - npx package-name@latest [files] <flags> |
164 | | - |
165 | | - # pnpm |
166 | | - pnpm dlx package-name@latest [files] <flags> |
167 | | - |
168 | | - # bun |
169 | | - bunx package-name@latest [files] <flags> |
170 | | - ``` |
171 | | - |
172 | | - <!-- /automd --> |
173 | | - |
174 | | -#### Arguments |
175 | | - |
176 | | -- `name`: The package name (by default tries to read from the `name` field in `package.json`). |
177 | | -- `separate`: Separate code blocks for each package manager (defaults to `false`). |
178 | | -- `args`: An additional string appended at the end of each command suggesting arguments to be used with the program. (defaults to `""`). |
179 | | - |
180 | | -### `badges` |
181 | | - |
182 | | -The `badges` generator generates badges for the latest npm version, npm download statistics, code coverage, and bundle size. |
183 | | - |
184 | | -#### Usage |
185 | | - |
186 | | - <!-- automd:badges color=yellow name=defu codecov bundlephobia --> |
187 | | - <!-- /automd --> |
188 | | - |
189 | | -**Updated Result:** |
190 | | - |
191 | | - <!-- automd:badges color=yellow name=defu codecov bundlephobia --> |
192 | | - |
193 | | - [](https://npmjs.com/package/defu) |
194 | | - [](https://npmjs.com/package/defu) |
195 | | - [](https://bundlephobia.com/package/defu) |
196 | | - [](https://codecov.io/gh/unjs/automd) |
197 | | - |
198 | | - <!-- /automd --> |
199 | | - |
200 | | -#### Arguments |
201 | | - |
202 | | -- `name`: The npm package name. By default tries to infer from `package.json`. |
203 | | -- `github`: Github repository name. By default tries to infer from `package.json`. |
204 | | -- `bundlephobia`: Show [Bundlephobia](https://bundlephobia.com/) badge (requires `name`). |
205 | | -- `codecov`: Enable [Codecov](https://codecov.io) badge (requires `github`). |
206 | | -- `no-npmDownloads`: Hide npm downloads badge. |
207 | | -- `no-npmVersion`: Hide npm version badge. |
208 | | -- `provider`: Can be one of `shields` (for [shields.io](https://shields.io/)) or `badgen` / `badgenClassic` (for [badgen.net](https://badgen.net/)). Default is `badgen`. |
209 | | - |
210 | | -> [!TIP] |
211 | | -> You can use additional args `color`, `labelColor` to customize style. For provider specific params, use `styleParams`. |
212 | | -
|
213 | 20 | ## Development |
214 | 21 |
|
215 | 22 | - Clone this repository |
|
0 commit comments