do11y 0.5.3 → 0.5.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.
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { ComponentMeta } from "vue-component-meta";
|
|
2
|
+
import type { ComponentDoc } from "vue-docgen-api";
|
|
2
3
|
import type { Meta } from "./meta-types";
|
|
3
|
-
export declare const mapMeta: (meta: ComponentMeta, render: (input: string) => string) => Meta;
|
|
4
|
+
export declare const mapMeta: (docs: ComponentDoc, meta: ComponentMeta, render: (input: string) => string) => Meta;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const mapMeta = (meta, render) => {
|
|
1
|
+
export const mapMeta = (docs, meta, render) => {
|
|
2
2
|
const nonGlobalProps = meta.props.filter((prop) => !prop.global);
|
|
3
3
|
const getDeprecated = (tags) => {
|
|
4
4
|
const deprecated = getTag(tags, "deprecated");
|
|
@@ -11,13 +11,18 @@ export const mapMeta = (meta, render) => {
|
|
|
11
11
|
text: tag.text ? render(tag.text) : undefined,
|
|
12
12
|
}));
|
|
13
13
|
};
|
|
14
|
-
const mapEvent = (prop) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
const mapEvent = (prop) => {
|
|
15
|
+
if (!prop.description) {
|
|
16
|
+
prop.description = docs.events?.find((event) => event.name === prop.name)?.description || "";
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
name: prop.name,
|
|
20
|
+
type: prop.type,
|
|
21
|
+
description: prop.description ? render(prop.description) : undefined,
|
|
22
|
+
deprecated: getDeprecated(prop.tags),
|
|
23
|
+
tags: getFilteredTags(prop.tags),
|
|
24
|
+
};
|
|
25
|
+
};
|
|
21
26
|
const mapSlotAndExposed = (se) => ({
|
|
22
27
|
name: se.name,
|
|
23
28
|
type: se.type,
|
|
@@ -2,6 +2,7 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { createChecker } from "vue-component-meta";
|
|
4
4
|
import { parse as parseVue } from "vue/compiler-sfc";
|
|
5
|
+
import { parse as parseDocs } from "vue-docgen-api";
|
|
5
6
|
import markdown from "markdown-it";
|
|
6
7
|
import { root } from "../../files.js";
|
|
7
8
|
import { mapMeta } from "./meta-mapper.js";
|
|
@@ -31,7 +32,7 @@ export default () => {
|
|
|
31
32
|
});
|
|
32
33
|
return {
|
|
33
34
|
name: "do11y:meta",
|
|
34
|
-
transform(_, id) {
|
|
35
|
+
async transform(_, id) {
|
|
35
36
|
if (id.endsWith(".vue?meta")) {
|
|
36
37
|
const file = id.replace("?meta", "");
|
|
37
38
|
const content = readFileSync(file, "utf-8");
|
|
@@ -39,8 +40,9 @@ export default () => {
|
|
|
39
40
|
const block = descriptor.customBlocks.find((b) => b.type === "docs" && b.lang === "md");
|
|
40
41
|
const description = block ? md.render(block.content) || undefined : undefined;
|
|
41
42
|
const meta = checker.getComponentMeta(file);
|
|
43
|
+
const docs = await parseDocs(file);
|
|
42
44
|
const mappedMeta = {
|
|
43
|
-
...mapMeta(meta, (content) => md.render(content)),
|
|
45
|
+
...mapMeta(docs, meta, (content) => md.render(content)),
|
|
44
46
|
description: description || meta.description,
|
|
45
47
|
};
|
|
46
48
|
const code = `export default ${JSON.stringify(mappedMeta)}`;
|
package/dist/docs/vite-config.js
CHANGED
|
@@ -33,11 +33,11 @@ const getPlugin = async (plugin) => {
|
|
|
33
33
|
const getUserPlugins = async (userViteConfig) => {
|
|
34
34
|
const userPlugins = userViteConfig.plugins?.map(async (p) => await getPlugin(p)) ?? [];
|
|
35
35
|
const resolvedUserPlugins = (await Promise.all(userPlugins)).flat();
|
|
36
|
-
const vuePluginApi = resolvedUserPlugins.find((p) => p.name === "vite:vue")
|
|
36
|
+
const vuePluginApi = resolvedUserPlugins.find((p) => p.name === "vite:vue")?.api;
|
|
37
37
|
const VuePlugin = (await import("@vitejs/plugin-vue")).default;
|
|
38
38
|
return [
|
|
39
39
|
VuePlugin({
|
|
40
|
-
...vuePluginApi
|
|
40
|
+
...vuePluginApi?.options,
|
|
41
41
|
include: [/\.vue$/, /\.md$/],
|
|
42
42
|
exclude: [
|
|
43
43
|
/\.vue\?meta$/,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "do11y",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "A bare-bones tool to document Vue components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs-generator",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"shiki": "^4.0.2",
|
|
38
38
|
"tinyglobby": "^0.2.16",
|
|
39
39
|
"v-custom-block": "^1.0.67",
|
|
40
|
-
"vue-component-meta": "^3.2.8"
|
|
40
|
+
"vue-component-meta": "^3.2.8",
|
|
41
|
+
"vue-docgen-api": "^4.79.2"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@tsconfig/node24": "^24.0.4",
|