do11y 0.2.3 → 0.2.5
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 +5 -2
- package/dist/docs/plugins/highlight/highlight-css.d.ts +7 -0
- package/dist/docs/plugins/highlight/highlight-css.js +33 -0
- package/dist/docs/plugins/{highlight.js → highlight/highlight.js} +5 -25
- package/dist/docs/plugins/markdown.js +1 -1
- package/dist/docs/plugins/plugins.js +3 -1
- package/package.json +2 -2
- /package/dist/docs/plugins/{highlight.d.ts → highlight/highlight.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
A bare-bones tool to document Vue components.
|
|
4
4
|
|
|
5
|
+
> [!WARNING]
|
|
6
|
+
> This is a small personal project! I make a lot of component libraries for personal projects and I absolutely love, love, love writing documentation for components, and I intend for this to be a mix of some of the features I love from [VitePress](https://vitepress.dev) and [Histoire](https://histoire.dev). Issues and thoughts and contributions are very welcome! But it is, again, a _personal_ project 😊
|
|
7
|
+
|
|
5
8
|
## Features
|
|
6
9
|
|
|
7
10
|
### Markdown components with [@mdit-vue](https://github.com/mdit-vue/mdit-vue).
|
|
@@ -44,10 +47,10 @@ Document components through meta imports (`Button.vue?meta`) which give a simpli
|
|
|
44
47
|
|
|
45
48
|
## Options
|
|
46
49
|
|
|
47
|
-
Expected
|
|
50
|
+
Expected as the default export in `docs/do11y/do11y.ts`.
|
|
48
51
|
|
|
49
52
|
```ts
|
|
50
|
-
|
|
53
|
+
interface Options {
|
|
51
54
|
/**
|
|
52
55
|
* The home page.
|
|
53
56
|
*/
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { do11yOptions } from "../../options.js";
|
|
2
|
+
/**
|
|
3
|
+
* Adds the necessary styles for using
|
|
4
|
+
* dual themes with the `highlighter`.
|
|
5
|
+
*/
|
|
6
|
+
export default () => ({
|
|
7
|
+
name: "do11y:highlight-css",
|
|
8
|
+
async resolveId(id) {
|
|
9
|
+
if (id === "do11y:css") {
|
|
10
|
+
return "\0dolly:css.css";
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
load: {
|
|
14
|
+
order: "post",
|
|
15
|
+
handler(id) {
|
|
16
|
+
if (id === "\0dolly:css.css") {
|
|
17
|
+
const generateThemeCss = (theme) => `
|
|
18
|
+
[data-theme="${theme}"] .shiki {
|
|
19
|
+
background-color: var(--shiki-${theme}-bg) !important;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
[data-theme="${theme}"] .shiki span {
|
|
23
|
+
color: var(--shiki-${theme}) !important;
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
return Object.keys(do11yOptions.highlighter.themesInput)
|
|
27
|
+
.filter((theme) => do11yOptions.highlighter.defaultTheme !== theme)
|
|
28
|
+
.map((theme) => generateThemeCss(theme))
|
|
29
|
+
.join("\n");
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
@@ -3,7 +3,7 @@ import { parse as parseVue } from "vue/compiler-sfc";
|
|
|
3
3
|
import { format } from "oxfmt";
|
|
4
4
|
import { createHighlighter, bundledLanguages, bundledThemes } from "shiki";
|
|
5
5
|
import { JSDOM } from "jsdom";
|
|
6
|
-
import { do11yOptions } from "
|
|
6
|
+
import { do11yOptions } from "../../options.js";
|
|
7
7
|
import { transformerNotationDiff, transformerNotationErrorLevel, transformerNotationHighlight, } from "@shikijs/transformers";
|
|
8
8
|
const shiki = await createHighlighter({
|
|
9
9
|
langs: Object.keys(bundledLanguages),
|
|
@@ -41,32 +41,12 @@ export const highlightAndFormatCode = async (path, code) => {
|
|
|
41
41
|
export default () => {
|
|
42
42
|
let viteDevServer;
|
|
43
43
|
return {
|
|
44
|
-
name: "do11y:
|
|
44
|
+
name: "do11y:highlight",
|
|
45
45
|
configureServer(server) {
|
|
46
46
|
viteDevServer = server;
|
|
47
47
|
},
|
|
48
|
-
async resolveId(id) {
|
|
49
|
-
if (id === "do11y:css") {
|
|
50
|
-
return "\0dolly:css.css";
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
48
|
async load(id) {
|
|
54
|
-
if (id
|
|
55
|
-
const generateThemeCss = (theme) => `
|
|
56
|
-
[data-theme="${theme}"] .shiki {
|
|
57
|
-
background-color: var(--shiki-${theme}-bg) !important;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
[data-theme="${theme}"] .shiki span {
|
|
61
|
-
color: var(--shiki-${theme}) !important;
|
|
62
|
-
}
|
|
63
|
-
`;
|
|
64
|
-
return Object.keys(do11yOptions.highlighter.themesInput)
|
|
65
|
-
.filter((theme) => do11yOptions.highlighter.defaultTheme !== theme)
|
|
66
|
-
.map((theme) => generateThemeCss(theme))
|
|
67
|
-
.join("\n");
|
|
68
|
-
}
|
|
69
|
-
else if (id.endsWith(".vue?highlight") || id.endsWith(".vue?highlight&lang=css")) {
|
|
49
|
+
if (id.endsWith(".vue?highlight") || id.endsWith(".vue?highlight&lang=css")) {
|
|
70
50
|
const path = id.replace("?highlight", "").replace("&lang=css", "");
|
|
71
51
|
const source = readFileSync(path, "utf-8");
|
|
72
52
|
/**
|
|
@@ -77,7 +57,7 @@ export default () => {
|
|
|
77
57
|
* to compile the style tags to CSS.
|
|
78
58
|
*/
|
|
79
59
|
if (viteDevServer?.config.command === "serve" || !id.endsWith("lang=css")) {
|
|
80
|
-
return `export default
|
|
60
|
+
return `export default \`${await highlightAndFormatCode(path, source)}\`;`;
|
|
81
61
|
}
|
|
82
62
|
const loadCss = async (index, lang) => {
|
|
83
63
|
const { code } = await this.load({
|
|
@@ -96,7 +76,7 @@ export default () => {
|
|
|
96
76
|
.filter((stylesheet) => !!stylesheet)
|
|
97
77
|
.map((stylesheet) => `<style>${stylesheet}</style>`)
|
|
98
78
|
.join("\n");
|
|
99
|
-
return `export default
|
|
79
|
+
return `export default \`${await highlightAndFormatCode(path, sourceWithoutStyles + css)}\`;`;
|
|
100
80
|
}
|
|
101
81
|
},
|
|
102
82
|
};
|
|
@@ -3,7 +3,7 @@ import { sfcPlugin } from "@mdit-vue/plugin-sfc";
|
|
|
3
3
|
import { frontmatterPlugin } from "@mdit-vue/plugin-frontmatter";
|
|
4
4
|
import attrsPlugin from "markdown-it-attrs";
|
|
5
5
|
import markdown from "markdown-it";
|
|
6
|
-
import { highlightCode } from "./highlight.js";
|
|
6
|
+
import { highlightCode } from "./highlight/highlight.js";
|
|
7
7
|
/**
|
|
8
8
|
* Processes blocks with the lang set to `md` into HTML,
|
|
9
9
|
* and turns `.md` files into single file vue components
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import ui from "./ui.js";
|
|
2
2
|
import sandbox from "./sandbox.js";
|
|
3
|
-
import
|
|
3
|
+
import highlightCss from "./highlight/highlight-css.js";
|
|
4
|
+
import highlight from "./highlight/highlight.js";
|
|
4
5
|
import meta from "./meta/meta.js";
|
|
5
6
|
import markdown from "./markdown.js";
|
|
6
7
|
import block from "v-custom-block";
|
|
@@ -10,6 +11,7 @@ import { do11yOptions } from "../options.js";
|
|
|
10
11
|
export const plugins = () => [
|
|
11
12
|
ui(),
|
|
12
13
|
sandbox(),
|
|
14
|
+
highlightCss(),
|
|
13
15
|
highlight(),
|
|
14
16
|
meta(),
|
|
15
17
|
markdown(do11yOptions),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "do11y",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "A bare-bones tool to document Vue components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs-generator",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@shikijs/langs": "^3.22.0",
|
|
34
34
|
"@shikijs/themes": "^3.22.0",
|
|
35
35
|
"@shikijs/transformers": "^3.22.0",
|
|
36
|
+
"@types/markdown-it": "^14.1.2",
|
|
36
37
|
"front-matter": "^4.0.2",
|
|
37
38
|
"jsdom": "^28.1.0",
|
|
38
39
|
"markdown-it": "^14.1.1",
|
|
@@ -46,7 +47,6 @@
|
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@tsconfig/node24": "^24.0.4",
|
|
48
49
|
"@types/jsdom": "^27.0.0",
|
|
49
|
-
"@types/markdown-it": "^14.1.2",
|
|
50
50
|
"@types/markdown-it-attrs": "^4.1.3",
|
|
51
51
|
"@types/node": "24.10.3",
|
|
52
52
|
"@vue/tsconfig": "^0.8.1",
|
|
File without changes
|