@do11y/docs 0.0.6 → 0.0.9

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
@@ -2,15 +2,9 @@
2
2
 
3
3
  A very bare-bones tool to help document Vue components.
4
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
- ```
5
+ - Write documentation in Markdown files that get treated as Vue components.
6
+ - Import markdown files as routes.
7
+ - Add sandbox components - e.g. `Button.sandbox.vue` will be available on the url `/sandbox?id=button`.
14
8
 
15
9
  ## Setup
16
10
 
@@ -35,6 +29,18 @@ export default defineConfig({
35
29
  });
36
30
  ```
37
31
 
32
+ ### Initiate and scaffold
33
+
34
+ The scaffold makes the assumption that you have a `src` folder and a `tsconfig.json` file it can extend.
35
+
36
+ ```sh
37
+ // Install
38
+ npm i @do11y/docs
39
+
40
+ // Scaffold the `docs` folder
41
+ npm do11y-scaffold
42
+ ```
43
+
38
44
  ### Add scripts to `package.json`
39
45
 
40
46
  ```json
@@ -47,24 +53,18 @@ export default defineConfig({
47
53
  }
48
54
  ```
49
55
 
50
- ### Add the `docs` folder
56
+ ### Run the dev environment
51
57
 
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
- }
58
+ ```sh
59
+ // Install
60
+ npm docs:dev
63
61
  ```
64
62
 
65
- #### Add a `site/index.ts` file
63
+ ## Files
64
+
65
+ ### `site/index.ts`
66
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.
67
+ This file will be used to configure the documentation site.
68
68
 
69
69
  > [!WARNING]
70
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.
@@ -81,7 +81,7 @@ export default {
81
81
  } satisfies Site;
82
82
  ```
83
83
 
84
- #### Add a `site/plugins.ts` file
84
+ ### `site/plugins.ts`
85
85
 
86
86
  This file will be used to configure the different plugins available.
87
87
 
@@ -97,29 +97,3 @@ export default {
97
97
  },
98
98
  } satisfies PluginOptions;
99
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
- ```
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ import '../dist/scaffold.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import { cp } from 'fs/promises';
2
+ import { join } from 'path';
3
+ import { searchForWorkspaceRoot } from 'vite';
4
+ const target = join(searchForWorkspaceRoot(process.cwd()), 'docs');
5
+ await cp(join(import.meta.dirname, '../template'), target, { recursive: true });
package/package.json CHANGED
@@ -1,7 +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.6",
4
+ "version": "0.0.9",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -10,10 +10,12 @@
10
10
  "files": [
11
11
  "bin",
12
12
  "dist",
13
+ "template",
13
14
  "routes.d.ts"
14
15
  ],
15
16
  "bin": {
16
- "do11y": "./bin/bin.js"
17
+ "do11y": "./bin/cli.js",
18
+ "do11y-scaffold": "./bin/scaffold.js"
17
19
  },
18
20
  "exports": {
19
21
  ".": {
@@ -40,7 +42,7 @@
40
42
  "markdown-it-mark": "^4.0.0",
41
43
  "markdown-it-vue-meta": "^0.0.2",
42
44
  "v-custom-block": "^1.0.67",
43
- "@do11y/ui": "0.0.4"
45
+ "@do11y/ui": "0.0.5"
44
46
  },
45
47
  "devDependencies": {
46
48
  "@tsconfig/node24": "^24.0.3",
@@ -0,0 +1,17 @@
1
+ ---
2
+ title: 'Example'
3
+ slug: '/example'
4
+ ---
5
+
6
+ <script setup>
7
+ import { useRoute } from 'vue-router';
8
+
9
+ const route = useRoute();
10
+ </script>
11
+
12
+ # {{ route.meta.title }}
13
+
14
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Asperiores, harum itaque consequatur vel
15
+ voluptatem vero labore aliquam fuga veritatis, voluptatum architecto. Obcaecati, vitae delectus
16
+ aperiam deleniti quod, ducimus vero quas, adipisci molestias placeat neque? Sapiente sint nam
17
+ tempora commodi! Adipisci iure unde alias ab quasi maxime enim porro cum vero.
Binary file
@@ -0,0 +1,27 @@
1
+ <template>
2
+ <div class="iframe-wrapper">
3
+ <iframe ref="iframe" :title="`Sandbox for ${title}`" :src="url" />
4
+ </div>
5
+
6
+ <a :href="url" target="_blank" rel="noopener noreferrer">Open in a new tab</a>
7
+ </template>
8
+
9
+ <script lang="ts" setup>
10
+ import { computed, ref } from 'vue';
11
+
12
+ const props = defineProps<{
13
+ title: string;
14
+ id: string;
15
+ }>();
16
+
17
+ const iframe = ref<HTMLIFrameElement>();
18
+
19
+ const url = computed(() => `${window.location.origin}/sandbox?id=${props.id}`);
20
+ </script>
21
+
22
+ <style scoped>
23
+ iframe {
24
+ border: none;
25
+ width: 100%;
26
+ }
27
+ </style>
@@ -0,0 +1,26 @@
1
+ <template>
2
+ <nav>
3
+ <ul>
4
+ <template v-for="route of routes" :key="route.path">
5
+ <li>
6
+ <router-link :to="route.path">
7
+ {{ route.meta.title }}
8
+ </router-link>
9
+ </li>
10
+ </template>
11
+ </ul>
12
+ </nav>
13
+
14
+ <RouterView />
15
+ </template>
16
+
17
+ <script lang="ts" setup>
18
+ import routes from 'do11y:routes';
19
+ import './style.css';
20
+ </script>
21
+
22
+ <style>
23
+ button {
24
+ width: max-content;
25
+ }
26
+ </style>
@@ -0,0 +1,10 @@
1
+ import type { Site } from '@do11y/docs';
2
+
3
+ export default {
4
+ Site: () => import('./Site.vue'),
5
+
6
+ async setup(app) {
7
+ const SandboxPlaygroundComponent = (await import('./SandboxPlayground.vue')).default;
8
+ app.component('SandboxPlayground', SandboxPlaygroundComponent);
9
+ },
10
+ } satisfies Site;
@@ -0,0 +1,10 @@
1
+ import type { PluginOptions } from '@do11y/docs';
2
+
3
+ export default {
4
+ metaRenderer(meta, title) {
5
+ return `
6
+ <h3>${title}</h3>
7
+ <pre><code>${JSON.stringify(meta, null, 2)}</code></pre>
8
+ `;
9
+ },
10
+ } satisfies PluginOptions;
@@ -0,0 +1,77 @@
1
+ html {
2
+ scrollbar-gutter: stable;
3
+ scrollbar-width: thin;
4
+ }
5
+
6
+ *,
7
+ *::before,
8
+ *::after,
9
+ *::details-content {
10
+ box-sizing: border-box;
11
+ padding: 0;
12
+ }
13
+
14
+ *:not(dialog) {
15
+ margin: 0;
16
+ }
17
+
18
+ :target {
19
+ scroll-margin-block: 2em;
20
+ }
21
+
22
+ a,
23
+ button {
24
+ cursor: pointer;
25
+ }
26
+
27
+ button {
28
+ color: inherit;
29
+ }
30
+
31
+ button:disabled,
32
+ button[aria-disabled='true'] {
33
+ cursor: default;
34
+ }
35
+
36
+ button,
37
+ input,
38
+ textarea,
39
+ select {
40
+ font: inherit;
41
+ letter-spacing: inherit;
42
+ word-spacing: inherit;
43
+ }
44
+
45
+ textarea {
46
+ field-sizing: content;
47
+ }
48
+
49
+ a {
50
+ text-underline-position: from-font;
51
+ }
52
+
53
+ pre {
54
+ white-space: pre-wrap;
55
+ }
56
+
57
+ code {
58
+ word-break: break-all;
59
+ }
60
+
61
+ pre,
62
+ table,
63
+ img,
64
+ svg,
65
+ picture,
66
+ video,
67
+ canvas,
68
+ iframe {
69
+ max-inline-size: 100%;
70
+ min-inline-size: 0;
71
+
72
+ display: block;
73
+ }
74
+
75
+ [id] {
76
+ scroll-margin-top: 2rem;
77
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "include": ["site/**/*", "../src/**/*"],
4
+
5
+ "compilerOptions": {
6
+ "types": ["@do11y/docs/types"]
7
+ }
8
+ }
File without changes