do11y 0.5.12 → 0.5.14
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/dist/docs/cli.js +1 -1
- package/dist/docs/html/plugin.d.ts +1 -1
- package/dist/docs/html/plugin.js +1 -4
- package/dist/docs/html/render.js +1 -1
- package/dist/docs/plugins/meta/meta.d.ts +1 -1
- package/dist/docs/plugins/meta/meta.js +23 -1
- package/dist/docs/plugins/plugins.d.ts +1 -1
- package/dist/docs/plugins/plugins.js +4 -4
- package/dist/docs/plugins/sandbox.d.ts +1 -1
- package/dist/docs/plugins/sandbox.js +2 -2
- package/dist/docs/plugins/ui.d.ts +1 -1
- package/dist/docs/plugins/ui.js +1 -1
- package/dist/docs/vite-config.d.ts +1 -1
- package/dist/docs/vite-config.js +3 -3
- package/package.json +2 -1
package/dist/docs/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ if (command !== "dev" && command !== "build" && command !== "preview") {
|
|
|
5
5
|
throw new Error();
|
|
6
6
|
}
|
|
7
7
|
const userViteConfig = await getUserViteConfig(command);
|
|
8
|
-
const mergedViteConfig = mergeConfig(userViteConfig, viteConfig);
|
|
8
|
+
const mergedViteConfig = mergeConfig(userViteConfig, viteConfig(userViteConfig.base));
|
|
9
9
|
if (command === "dev") {
|
|
10
10
|
const server = await createServer(mergedViteConfig);
|
|
11
11
|
await server.listen();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
|
-
export declare const indexHtml: (folder: string, key: "index" | "sandbox") => Omit<Plugin, "name">;
|
|
2
|
+
export declare const indexHtml: (folder: string, key: "index" | "sandbox", base?: string) => Omit<Plugin, "name">;
|
package/dist/docs/html/plugin.js
CHANGED
|
@@ -2,8 +2,7 @@ import { join } from "node:path";
|
|
|
2
2
|
import { writeFileSync } from "node:fs";
|
|
3
3
|
import { output } from "../files.js";
|
|
4
4
|
import { render } from "./render.js";
|
|
5
|
-
|
|
6
|
-
export const indexHtml = (folder, key) => ({
|
|
5
|
+
export const indexHtml = (folder, key, base) => ({
|
|
7
6
|
async writeBundle(_, bundle) {
|
|
8
7
|
const chunk = Object.values(bundle).find((chunk) => {
|
|
9
8
|
return chunk.type === "chunk" && chunk.isEntry && chunk.facadeModuleId?.endsWith(`${key}.js`);
|
|
@@ -12,7 +11,6 @@ export const indexHtml = (folder, key) => ({
|
|
|
12
11
|
throw new Error(`Failed to create HTML file for ${key}.`);
|
|
13
12
|
}
|
|
14
13
|
const stylesheets = Array.from(chunk.viteMetadata?.importedCss || []);
|
|
15
|
-
const { base } = await getUserViteConfig("build");
|
|
16
14
|
const html = render(base, chunk.fileName, stylesheets);
|
|
17
15
|
writeFileSync(join(output, `${key}.html`), html);
|
|
18
16
|
if (key === "index") {
|
|
@@ -26,7 +24,6 @@ export const indexHtml = (folder, key) => ({
|
|
|
26
24
|
if (!req.url || req.method !== "GET" || !req.headers.accept?.includes("text/html")) {
|
|
27
25
|
return next();
|
|
28
26
|
}
|
|
29
|
-
const { base } = await getUserViteConfig("build");
|
|
30
27
|
const html = render(base, `/@fs/${req.url?.startsWith("/sandbox") ? sandboxBundle : bundle}`);
|
|
31
28
|
const transformedHtml = await server.transformIndexHtml(req.url, html);
|
|
32
29
|
res.statusCode = 200;
|
package/dist/docs/html/render.js
CHANGED
|
@@ -7,7 +7,7 @@ export const render = (base = "", script, stylesheets = []) => {
|
|
|
7
7
|
const faviconElement = jsdom.window.document.createElement("link");
|
|
8
8
|
faviconElement.setAttribute("rel", "icon");
|
|
9
9
|
faviconElement.setAttribute("href", `${base}favicon.ico`);
|
|
10
|
-
jsdom.window.document.
|
|
10
|
+
jsdom.window.document.head.appendChild(faviconElement);
|
|
11
11
|
const scriptElement = jsdom.window.document.createElement("script");
|
|
12
12
|
scriptElement.setAttribute("type", "module");
|
|
13
13
|
scriptElement.setAttribute("src", `${base}${script}`);
|
|
@@ -3,5 +3,5 @@ import type { Plugin } from "vite";
|
|
|
3
3
|
* Adds `.vue?meta` imports which returns a simplified result
|
|
4
4
|
* of running the component through `vue-component-meta`.
|
|
5
5
|
*/
|
|
6
|
-
declare const _default: () => Plugin;
|
|
6
|
+
declare const _default: (base?: string) => Plugin;
|
|
7
7
|
export default _default;
|
|
@@ -4,8 +4,21 @@ import { createChecker } from "vue-component-meta";
|
|
|
4
4
|
import { parse as parseVue } from "vue/compiler-sfc";
|
|
5
5
|
import { parse as parseDocs } from "vue-docgen-api";
|
|
6
6
|
import markdown from "markdown-it";
|
|
7
|
+
import replaceLinkPlugin from "markdown-it-replace-link";
|
|
7
8
|
import { root } from "../../files.js";
|
|
8
9
|
import { mapMeta } from "./meta-mapper.js";
|
|
10
|
+
const getLinkType = (url) => {
|
|
11
|
+
if (url.startsWith("#")) {
|
|
12
|
+
return "anchor";
|
|
13
|
+
}
|
|
14
|
+
if (URL.canParse(url)) {
|
|
15
|
+
return "absolute";
|
|
16
|
+
}
|
|
17
|
+
if (URL.canParse(url, "https://github.com/sq11y/do11y")) {
|
|
18
|
+
return "relative";
|
|
19
|
+
}
|
|
20
|
+
return "invalid";
|
|
21
|
+
};
|
|
9
22
|
const getFirstExistingFile = (...paths) => {
|
|
10
23
|
for (const path of paths) {
|
|
11
24
|
if (existsSync(path)) {
|
|
@@ -17,7 +30,7 @@ const getFirstExistingFile = (...paths) => {
|
|
|
17
30
|
* Adds `.vue?meta` imports which returns a simplified result
|
|
18
31
|
* of running the component through `vue-component-meta`.
|
|
19
32
|
*/
|
|
20
|
-
export default () => {
|
|
33
|
+
export default (base) => {
|
|
21
34
|
const tsconfig = getFirstExistingFile(join(root, "tsconfig.app.json"), join(root, "tsconfig.json"));
|
|
22
35
|
if (!tsconfig) {
|
|
23
36
|
return {
|
|
@@ -30,6 +43,15 @@ export default () => {
|
|
|
30
43
|
const md = markdown({
|
|
31
44
|
html: true,
|
|
32
45
|
});
|
|
46
|
+
if (base) {
|
|
47
|
+
md.use(replaceLinkPlugin, {
|
|
48
|
+
processHTML: true,
|
|
49
|
+
replaceLink: (link) => {
|
|
50
|
+
const url = base.startsWith("/") ? link.replace(/^\//, "") : link;
|
|
51
|
+
return ["anchor", "relative"].includes(getLinkType(link)) ? `${base}${url}` : link;
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
33
55
|
return {
|
|
34
56
|
name: "do11y:meta",
|
|
35
57
|
async transform(_, id) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
|
-
export declare const plugins: () => Plugin[];
|
|
2
|
+
export declare const plugins: (base?: string) => Plugin[];
|
|
@@ -8,12 +8,12 @@ import block from "v-custom-block";
|
|
|
8
8
|
import options from "./options.js";
|
|
9
9
|
import routes from "./routes.js";
|
|
10
10
|
import { do11yOptions } from "../options.js";
|
|
11
|
-
export const plugins = () => [
|
|
12
|
-
ui(),
|
|
13
|
-
sandbox(),
|
|
11
|
+
export const plugins = (base) => [
|
|
12
|
+
ui(base),
|
|
13
|
+
sandbox(base),
|
|
14
14
|
highlightCss(),
|
|
15
15
|
highlight(),
|
|
16
|
-
meta(),
|
|
16
|
+
meta(base),
|
|
17
17
|
markdown(do11yOptions),
|
|
18
18
|
block("docs"),
|
|
19
19
|
options(),
|
|
@@ -4,5 +4,5 @@ export declare const toParamId: (path: string) => string;
|
|
|
4
4
|
* Creates a seprate sandbox app, and
|
|
5
5
|
* adds access to sandbox components through `do11y:sandboxes`.
|
|
6
6
|
*/
|
|
7
|
-
declare const _default: () => Plugin;
|
|
7
|
+
declare const _default: (base?: string) => Plugin;
|
|
8
8
|
export default _default;
|
|
@@ -7,7 +7,7 @@ export const toParamId = (path) => parse(path).name.toLowerCase().replace(".sand
|
|
|
7
7
|
* Creates a seprate sandbox app, and
|
|
8
8
|
* adds access to sandbox components through `do11y:sandboxes`.
|
|
9
9
|
*/
|
|
10
|
-
export default () => {
|
|
10
|
+
export default (base) => {
|
|
11
11
|
const moduleId = "do11y:sandboxes";
|
|
12
12
|
const resolvedModuleId = "\0" + moduleId;
|
|
13
13
|
const sandboxFiles = globSync(["(docs|src|packages)/**/*.sandbox.vue"], {
|
|
@@ -18,7 +18,7 @@ export default () => {
|
|
|
18
18
|
});
|
|
19
19
|
return {
|
|
20
20
|
name: "do11y:sandboxes",
|
|
21
|
-
...indexHtml(ui, "sandbox"),
|
|
21
|
+
...indexHtml(ui, "sandbox", base),
|
|
22
22
|
resolveId(id) {
|
|
23
23
|
if (id === moduleId) {
|
|
24
24
|
return resolvedModuleId;
|
package/dist/docs/plugins/ui.js
CHANGED
|
@@ -6,7 +6,7 @@ export declare const getUserViteConfig: (command: "dev" | "build" | "preview") =
|
|
|
6
6
|
alias?: import("vite").AliasOptions;
|
|
7
7
|
}) | undefined;
|
|
8
8
|
}>;
|
|
9
|
-
export declare const viteConfig: {
|
|
9
|
+
export declare const viteConfig: (base?: string) => {
|
|
10
10
|
root: string;
|
|
11
11
|
plugins: Plugin<any>[];
|
|
12
12
|
server: {
|
package/dist/docs/vite-config.js
CHANGED
|
@@ -59,9 +59,9 @@ const getUserPlugins = async (userViteConfig) => {
|
|
|
59
59
|
...resolvedUserPlugins.filter((i) => i.name !== "vite:vue"),
|
|
60
60
|
];
|
|
61
61
|
};
|
|
62
|
-
export const viteConfig = {
|
|
62
|
+
export const viteConfig = (base) => ({
|
|
63
63
|
root: docs,
|
|
64
|
-
plugins: plugins(),
|
|
64
|
+
plugins: plugins(base),
|
|
65
65
|
server: {
|
|
66
66
|
port: 1998,
|
|
67
67
|
fs: {
|
|
@@ -84,4 +84,4 @@ export const viteConfig = {
|
|
|
84
84
|
},
|
|
85
85
|
},
|
|
86
86
|
},
|
|
87
|
-
};
|
|
87
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "do11y",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.14",
|
|
4
4
|
"description": "A bare-bones tool to document Vue components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs-generator",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"jsdom": "^29.1.1",
|
|
35
35
|
"markdown-it": "^14.1.1",
|
|
36
36
|
"markdown-it-attrs": "^4.3.1",
|
|
37
|
+
"markdown-it-replace-link": "^1.2.2",
|
|
37
38
|
"shiki": "^4.0.2",
|
|
38
39
|
"tinyglobby": "^0.2.16",
|
|
39
40
|
"v-custom-block": "^1.0.67",
|