compmark-vue 0.2.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,15 +11,88 @@ Auto-generate Markdown documentation from Vue 3 SFCs. Zero configuration require
11
11
 
12
12
  ## Quick Start
13
13
 
14
+ Document a single component:
15
+
14
16
  ```sh
15
17
  npx compmark-vue ./src/components/Button.vue
16
18
  ```
17
19
 
18
- This parses the component and creates `Button.md` in your current directory.
20
+ Document an entire directory:
21
+
22
+ ```sh
23
+ npx compmark-vue ./src/components --out ./docs/api
24
+ ```
25
+
26
+ Add to your `package.json`:
27
+
28
+ ```json
29
+ {
30
+ "scripts": {
31
+ "docs": "compmark ./src/components --out ./docs/api"
32
+ }
33
+ }
34
+ ```
35
+
36
+ ## CLI
37
+
38
+ ```
39
+ compmark <files/dirs/globs> [options]
40
+ ```
41
+
42
+ | Option | Description | Default |
43
+ | --------------------- | ------------------------------- | ------- |
44
+ | `--out <dir>` | Output directory | `.` |
45
+ | `--format <md\|json>` | Output format | `md` |
46
+ | `--join` | Combine into a single file | |
47
+ | `--ignore <patterns>` | Comma-separated ignore patterns | |
48
+ | `--watch` | Watch for changes and rebuild | |
49
+ | `--silent` | Suppress non-error output | |
50
+
51
+ ### Examples
52
+
53
+ ```sh
54
+ # Single file
55
+ compmark Button.vue
56
+
57
+ # Directory (recursive)
58
+ compmark src/components --out docs/api
59
+
60
+ # Glob pattern
61
+ compmark "src/**/components/*.vue" --out docs
62
+
63
+ # Monorepo
64
+ compmark "packages/*/src/components" --out docs/api
65
+
66
+ # Combined markdown with table of contents
67
+ compmark src/components --out docs --join
68
+
69
+ # JSON output
70
+ compmark src/components --out docs/api --format json
71
+
72
+ # JSON combined into single file
73
+ compmark src/components --format json --join --out docs
74
+
75
+ # Ignore patterns
76
+ compmark src/components --ignore "internal,*.test"
77
+
78
+ # Watch mode
79
+ compmark src/components --out docs --watch
80
+
81
+ # Multiple inputs
82
+ compmark src/components src/layouts --out docs
83
+ ```
84
+
85
+ The summary line shows what happened:
86
+
87
+ ```
88
+ ✓ 24 components documented, 2 skipped, 0 errors
89
+ ```
90
+
91
+ Exit code is `1` when errors occur (except in watch mode).
19
92
 
20
93
  ## Features
21
94
 
22
- - [Props](#props) — runtime and TypeScript generic syntax
95
+ - [Props](#props) — runtime and TypeScript generic syntax, including imported types
23
96
  - [Emits](#emits) — array, TypeScript property, and call signature syntax
24
97
  - [Slots](#slots) — `defineSlots` with typed bindings, template `<slot>` fallback
25
98
  - [Expose](#expose) — `defineExpose` with JSDoc descriptions
@@ -27,6 +100,7 @@ This parses the component and creates `Button.md` in your current directory.
27
100
  - [JSDoc tags](#jsdoc-tags) — `@deprecated`, `@since`, `@example`, `@see`, `@default`
28
101
  - [`@internal`](#internal-components) — exclude components from output
29
102
  - [Options API](#options-api) — `export default { props, emits }` support
103
+ - [Output formats](#output-formats) — Markdown (individual or joined), JSON
30
104
  - Empty sections are skipped cleanly — no placeholder noise
31
105
 
32
106
  ## Examples
@@ -83,6 +157,29 @@ defineProps({
83
157
  </script>
84
158
  ```
85
159
 
160
+ #### Imported types
161
+
162
+ `defineProps<ImportedType>()` with exported interfaces or type aliases is supported:
163
+
164
+ ```ts
165
+ // types.ts
166
+ export interface ButtonProps {
167
+ /** The label text */
168
+ label: string;
169
+ disabled?: boolean;
170
+ }
171
+ ```
172
+
173
+ ```vue
174
+ <script setup lang="ts">
175
+ import type { ButtonProps } from "./types";
176
+
177
+ defineProps<ButtonProps>();
178
+ </script>
179
+ ```
180
+
181
+ Interface `extends` is resolved (up to 5 levels deep). `withDefaults` works with imported types too.
182
+
86
183
  ### Emits
87
184
 
88
185
  TypeScript generic syntax with payloads:
@@ -186,15 +283,18 @@ Output:
186
283
 
187
284
  ### Composables
188
285
 
189
- Any `useX()` calls in `<script setup>` are automatically detected:
286
+ Any `useX()` calls in `<script setup>` are automatically detected. Variable bindings (simple assignment, object/array destructuring, rest elements) are extracted:
190
287
 
191
288
  ```vue
192
289
  <script setup lang="ts">
193
290
  import { useRouter } from "vue-router";
194
291
  import { useMouse } from "@vueuse/core";
292
+ import { useAuth } from "./composables/useAuth";
195
293
 
196
294
  const router = useRouter();
197
295
  const { x, y } = useMouse();
296
+ const { user, login, logout } = useAuth();
297
+ useHead({ title: "My App" });
198
298
  </script>
199
299
  ```
200
300
 
@@ -203,10 +303,31 @@ Output:
203
303
  ```md
204
304
  ## Composables Used
205
305
 
206
- - `useRouter`
207
- - `useMouse`
306
+ ### `useRouter`
307
+
308
+ **Returns:** `router`
309
+
310
+ ### `useMouse`
311
+
312
+ **Returns:** `x`, `y`
313
+
314
+ ### `useAuth`
315
+
316
+ _Source: `./composables/useAuth`_
317
+
318
+ | Variable | Type |
319
+ | -------- | ------------------------------------------- |
320
+ | user | Ref<User> |
321
+ | login | (credentials: Credentials) => Promise<void> |
322
+ | logout | () => void |
323
+
324
+ ### `useHead`
325
+
326
+ Called for side effects.
208
327
  ```
209
328
 
329
+ For local imports (`./` or `@/` paths), types are automatically resolved from the composable source file — `ref()`, `computed()`, `reactive()`, function signatures, and literals are all inferred. Source attribution is shown for local imports only.
330
+
210
331
  ### JSDoc Tags
211
332
 
212
333
  Props support `@deprecated`, `@since`, `@example`, and `@see`:
@@ -259,7 +380,8 @@ defineProps<{
259
380
 
260
381
  ```sh
261
382
  $ compmark InternalHelper.vue
262
- Skipped InternalHelper.vue (marked @internal)
383
+ Skipped InternalHelper.vue (marked @internal)
384
+ ✓ 0 components documented, 1 skipped, 0 errors
263
385
  ```
264
386
 
265
387
  ### Options API
@@ -303,6 +425,36 @@ Output:
303
425
  | update | - |
304
426
  ```
305
427
 
428
+ ### Output Formats
429
+
430
+ **Individual markdown** (default) — one `.md` file per component:
431
+
432
+ ```sh
433
+ compmark src/components --out docs
434
+ # Creates: docs/Button.md, docs/Dialog.md, ...
435
+ ```
436
+
437
+ **Joined markdown** — single file with table of contents:
438
+
439
+ ```sh
440
+ compmark src/components --out docs --join
441
+ # Creates: docs/components.md
442
+ ```
443
+
444
+ The joined file includes a generated timestamp, table of contents with anchor links, and all components with headings bumped one level.
445
+
446
+ **JSON** — machine-readable output:
447
+
448
+ ```sh
449
+ # Individual JSON files
450
+ compmark src/components --out docs --format json
451
+ # Creates: docs/Button.json, docs/Dialog.json, ...
452
+
453
+ # Combined JSON
454
+ compmark src/components --format json --join --out docs
455
+ # Creates: docs/components.json with { generated, components: [...] }
456
+ ```
457
+
306
458
  ## Programmatic API
307
459
 
308
460
  ```sh
@@ -325,6 +477,16 @@ const doc = parseSFC(source, "Button.vue");
325
477
  const md = generateMarkdown(doc);
326
478
  ```
327
479
 
480
+ Multi-file processing:
481
+
482
+ ```ts
483
+ import { discoverFiles, processFiles } from "compmark-vue";
484
+
485
+ const files = await discoverFiles(["src/components"], ["dist"]);
486
+ const summary = processFiles(files, { silent: false });
487
+ // summary.files, summary.documented, summary.skipped, summary.errors
488
+ ```
489
+
328
490
  ## Development
329
491
 
330
492
  <details>
@@ -332,7 +494,7 @@ const md = generateMarkdown(doc);
332
494
  <summary>local development</summary>
333
495
 
334
496
  - Clone this repository
335
- - Install latest LTS version of [Node.js](https://nodejs.org/en/)
497
+ - Install latest LTS version of [Node.js](https://nodejs.org/en/) (>= 20)
336
498
  - Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
337
499
  - Install dependencies using `pnpm install`
338
500
  - Run interactive tests using `pnpm dev`