@do11y/docs 0.0.2 → 0.0.4
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 +125 -0
- package/dist/cli.d.ts +1 -0
- package/dist/files.d.ts +4 -0
- package/dist/html/html.d.ts +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/plugin-options.d.ts +6 -0
- package/dist/plugins/markdown/markdown.d.ts +36 -0
- package/dist/plugins/plugins.d.ts +2 -0
- package/dist/plugins/routes/routes.d.ts +7 -0
- package/dist/plugins/sandbox/sandbox.d.ts +8 -0
- package/dist/plugins/site/site.d.ts +19 -0
- package/dist/plugins/ui/ui.d.ts +6 -0
- package/dist/vite-config.d.ts +2 -0
- package/package.json +7 -3
package/README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# @do11y/docs
|
|
2
|
+
|
|
3
|
+
A very bare-bones tool to help document Vue components.
|
|
4
|
+
|
|
5
|
+
- Write documentation in Markdown files that get treated as Vue components
|
|
6
|
+
- Import markdown files with a `title` and `slug` added through frontmatter as routes
|
|
7
|
+
- Sandbox components - e.g. `Button.sandbox.vue` will be available on the url `/sandbox?id=button`
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm i @do11y/docs
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Setup
|
|
16
|
+
|
|
17
|
+
### Allow markdown files in `vite.config.ts` file
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { fileURLToPath, URL } from 'node:url';
|
|
21
|
+
|
|
22
|
+
import { defineConfig } from 'vite';
|
|
23
|
+
|
|
24
|
+
import vue from '@vitejs/plugin-vue';
|
|
25
|
+
import vueDevTools from 'vite-plugin-vue-devtools';
|
|
26
|
+
|
|
27
|
+
export default defineConfig({
|
|
28
|
+
plugins: [vue({ include: [/\.vue$/, /\.md$/] }), vueDevTools()],
|
|
29
|
+
|
|
30
|
+
resolve: {
|
|
31
|
+
alias: {
|
|
32
|
+
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Add scripts to `package.json`
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"scripts": {
|
|
43
|
+
"docs:dev": "do11y",
|
|
44
|
+
"docs:build": "do11y build",
|
|
45
|
+
"docs:preview": "do11y preview"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Add the `docs` folder
|
|
51
|
+
|
|
52
|
+
#### Add `tsconfig.json` file
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"extends": "../tsconfig.json",
|
|
57
|
+
"include": ["site/**/*", "../src/**/*"],
|
|
58
|
+
|
|
59
|
+
"compilerOptions": {
|
|
60
|
+
"types": ["@do11y/docs/types"]
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Add a `site/index.ts` file
|
|
66
|
+
|
|
67
|
+
This file will be used to configure the documentation site. The configuration requires you to pass an import for the main `Site` component.
|
|
68
|
+
|
|
69
|
+
> [!WARNING]
|
|
70
|
+
> Both the documentation site and the sandbox uses the same `setup` function. This means importing styles or components directly in this file will also import them to the sandbox.
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import type { Site } from '@do11y/docs';
|
|
74
|
+
|
|
75
|
+
export default {
|
|
76
|
+
Site: () => import('./Site.vue'),
|
|
77
|
+
|
|
78
|
+
setup(app) {
|
|
79
|
+
// App setup
|
|
80
|
+
},
|
|
81
|
+
} satisfies Site;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### Add a `site/plugins.ts` file
|
|
85
|
+
|
|
86
|
+
This file will be used to configure the different plugins available.
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import type { PluginOptions } from '@do11y/docs';
|
|
90
|
+
|
|
91
|
+
export default {
|
|
92
|
+
metaRenderer(meta, title) {
|
|
93
|
+
return `
|
|
94
|
+
<h3>${title}</h3>
|
|
95
|
+
<pre><code>${JSON.stringify(meta, null, 2)}</code></pre>
|
|
96
|
+
`;
|
|
97
|
+
},
|
|
98
|
+
} satisfies PluginOptions;
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
#### Add a main `Site` component
|
|
102
|
+
|
|
103
|
+
Inside the app you can import the available routes from `dolly:routes`.
|
|
104
|
+
|
|
105
|
+
```vue
|
|
106
|
+
<template>
|
|
107
|
+
<nav>
|
|
108
|
+
<ul>
|
|
109
|
+
<template v-for="route of routes" :key="route.path">
|
|
110
|
+
<li>
|
|
111
|
+
<router-link :to="route.path">
|
|
112
|
+
{{ route.meta.title }}
|
|
113
|
+
</router-link>
|
|
114
|
+
</li>
|
|
115
|
+
</template>
|
|
116
|
+
</ul>
|
|
117
|
+
</nav>
|
|
118
|
+
|
|
119
|
+
<RouterView />
|
|
120
|
+
</template>
|
|
121
|
+
|
|
122
|
+
<script lang="ts" setup>
|
|
123
|
+
import routes from 'do11y:routes';
|
|
124
|
+
</script>
|
|
125
|
+
```
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/files.d.ts
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type MarkdownSfcBlocks } from '@mdit-vue/plugin-sfc';
|
|
2
|
+
import type { PluginOptions, MarkdownItEnv as Env } from 'markdown-it-vue-meta';
|
|
3
|
+
import type { PluginSimple } from 'markdown-it';
|
|
4
|
+
import type { Plugin } from 'vite';
|
|
5
|
+
import type MarkdownIt from 'markdown-it';
|
|
6
|
+
export interface MarkdownPluginOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Additional markdown-it setup.
|
|
9
|
+
*/
|
|
10
|
+
setup?: PluginSimple;
|
|
11
|
+
/**
|
|
12
|
+
* The highlight option for `markdown-it`.
|
|
13
|
+
*/
|
|
14
|
+
highlight?: (md: MarkdownIt, code: string, lang: string, attrs: string) => string;
|
|
15
|
+
/**
|
|
16
|
+
* The renderer option for `markdown-it-vue-meta`.
|
|
17
|
+
*/
|
|
18
|
+
metaRenderer?: PluginOptions['renderer'];
|
|
19
|
+
}
|
|
20
|
+
export interface MarkdownItEnv extends Env {
|
|
21
|
+
/**
|
|
22
|
+
* Blocks extracted by `@mdit-vue/plugin-sfc`.
|
|
23
|
+
*/
|
|
24
|
+
sfcBlocks?: MarkdownSfcBlocks;
|
|
25
|
+
/**
|
|
26
|
+
* Blocks extracted by `@mdit-vue/plugin-frontmatter`.
|
|
27
|
+
*/
|
|
28
|
+
frontmatter?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Processes blocks with the lang set to `md` into HTML,
|
|
32
|
+
* and turns `.md` files into single file vue components
|
|
33
|
+
* - using `markdown-it`.
|
|
34
|
+
*/
|
|
35
|
+
declare const _default: (options?: MarkdownPluginOptions) => Plugin;
|
|
36
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import type { App, Component } from 'vue';
|
|
3
|
+
import type { Router } from 'vue-router';
|
|
4
|
+
export type Site = {
|
|
5
|
+
/**
|
|
6
|
+
* The main component for the site.
|
|
7
|
+
*/
|
|
8
|
+
Site: () => Promise<Component>;
|
|
9
|
+
/**
|
|
10
|
+
* Additional setup for the app.
|
|
11
|
+
*/
|
|
12
|
+
setup?(app: App, router: Router): void | Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Add ability to access the site options (`docs/site/index.ts`)
|
|
16
|
+
* through `do11y:site`.
|
|
17
|
+
*/
|
|
18
|
+
declare const _default: () => Plugin;
|
|
19
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@do11y/docs",
|
|
3
|
-
"
|
|
3
|
+
"description": "A very bare-bones tool to help document Vue components.",
|
|
4
|
+
"version": "0.0.4",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
@@ -15,7 +16,10 @@
|
|
|
15
16
|
"do11y": "./bin/bin.js"
|
|
16
17
|
},
|
|
17
18
|
"exports": {
|
|
18
|
-
".":
|
|
19
|
+
".": {
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts"
|
|
22
|
+
},
|
|
19
23
|
"./types": "./routes.d.ts"
|
|
20
24
|
},
|
|
21
25
|
"peerDependencies": {
|
|
@@ -35,7 +39,7 @@
|
|
|
35
39
|
"markdown-it-mark": "^4.0.0",
|
|
36
40
|
"markdown-it-vue-meta": "^0.0.2",
|
|
37
41
|
"v-custom-block": "^1.0.67",
|
|
38
|
-
"@do11y/ui": "0.0.
|
|
42
|
+
"@do11y/ui": "0.0.2"
|
|
39
43
|
},
|
|
40
44
|
"devDependencies": {
|
|
41
45
|
"@tsconfig/node24": "^24.0.3",
|