vitepress-plugin-field 0.1.1 → 0.2.0
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/node/index.d.ts +1 -83
- package/dist/node/index.js +4 -2
- package/package.json +6 -5
package/dist/node/index.d.ts
CHANGED
|
@@ -1,91 +1,9 @@
|
|
|
1
1
|
import { PluginSimple } from "markdown-it";
|
|
2
2
|
|
|
3
3
|
//#region src/node/fieldPlugin.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Parsed result from a `::: field` container block.
|
|
6
|
-
*
|
|
7
|
-
* 字段对象 — 解析自 `::: field` 容器块的结构化结果
|
|
8
|
-
*/
|
|
9
|
-
interface FieldObject {
|
|
10
|
-
/**
|
|
11
|
-
* Field name — defaults to `info`, overridable via `@name`
|
|
12
|
-
*
|
|
13
|
-
* 字段名称 — 默认从 `info` 中获取,可通过 `@name` 覆盖
|
|
14
|
-
*/
|
|
15
|
-
name: string;
|
|
16
|
-
/**
|
|
17
|
-
* `@type` value, undefined if not set
|
|
18
|
-
*
|
|
19
|
-
* 类型注解 — 如果未设置则为 `undefined`
|
|
20
|
-
*/
|
|
21
|
-
type?: string;
|
|
22
|
-
/**
|
|
23
|
-
* `@default` value, preserved as-is
|
|
24
|
-
*
|
|
25
|
-
* 默认值 — 保持原样
|
|
26
|
-
*/
|
|
27
|
-
default?: string;
|
|
28
|
-
/**
|
|
29
|
-
* Whether `@required` is present
|
|
30
|
-
*
|
|
31
|
-
* 是否为必填项 — 是否在 `@required` 标签中
|
|
32
|
-
*/
|
|
33
|
-
required?: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Whether `@deprecated` is present
|
|
36
|
-
*
|
|
37
|
-
* 是否为已弃用项 — 是否在 `@deprecated` 标签中
|
|
38
|
-
*/
|
|
39
|
-
deprecated?: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Whether `@optional` is present
|
|
42
|
-
*
|
|
43
|
-
* 是否为可选项 — 是否在 `@optional` 标签中
|
|
44
|
-
*/
|
|
45
|
-
optional?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Description text, may span multiple lines joined by `\n`
|
|
48
|
-
*
|
|
49
|
-
* 描述文本 — 可跨多行,以 `\n` 连接
|
|
50
|
-
*/
|
|
51
|
-
description?: string;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Parse the body of a `::: field` container into a structured `FieldObject`.
|
|
55
|
-
*
|
|
56
|
-
* Supports a JSDoc-style tag syntax:
|
|
57
|
-
* - `@name` — override the field name (derived from `info` by default)
|
|
58
|
-
* - `@type` — type annotation
|
|
59
|
-
* - `@default` — default value
|
|
60
|
-
* - `@required` — mark as required (boolean flag)
|
|
61
|
-
* - `@deprecated` — mark as deprecated (boolean flag)
|
|
62
|
-
* - `@optional` — mark as optional (boolean flag)
|
|
63
|
-
* - `@description` — explicit description; any non-tag line also feeds into description
|
|
64
|
-
*
|
|
65
|
-
* Unknown `@`-prefixed tags are treated as description text.
|
|
66
|
-
* Empty lines are ignored and never interrupt a description paragraph.
|
|
67
|
-
*
|
|
68
|
-
* 将 `::: field` 容器的正文解析为结构化的 `FieldObject`。
|
|
69
|
-
*
|
|
70
|
-
* 支持类 JSDoc 的标签语法:
|
|
71
|
-
* - `@name` — 覆盖字段名称(默认从 `info` 派生)
|
|
72
|
-
* - `@type` — 类型注解
|
|
73
|
-
* - `@default` — 默认值
|
|
74
|
-
* - `@required` — 标记为必需(布尔标志)
|
|
75
|
-
* - `@deprecated` — 标记为已弃用(布尔标志)
|
|
76
|
-
* - `@optional` — 标记为可选(布尔标志)
|
|
77
|
-
* - `@description` — 显式描述;任何非标签行也会被纳入描述
|
|
78
|
-
*
|
|
79
|
-
* 未知的以 `@` 开头的标签将被视为描述文本。
|
|
80
|
-
* 空行会被忽略,且不会中断描述段落。
|
|
81
|
-
*
|
|
82
|
-
* @param content Raw text inside the `:::` container
|
|
83
|
-
* @param info Text after `::: field` on the opening line (the field name)
|
|
84
|
-
*/
|
|
85
|
-
declare function parseFieldContent(content: string, info: string): FieldObject;
|
|
86
4
|
declare const fieldMarkdownPlugin: PluginSimple;
|
|
87
5
|
//#endregion
|
|
88
6
|
//#region src/node/index.d.ts
|
|
89
7
|
declare const _default: (option?: unknown) => import("vitepress-tuck").VitepressPlugin;
|
|
90
8
|
//#endregion
|
|
91
|
-
export {
|
|
9
|
+
export { _default as default, fieldMarkdownPlugin };
|
package/dist/node/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { definePlugin } from "vitepress-tuck";
|
|
2
2
|
import { isUndefined } from "@pengzhanbo/utils";
|
|
3
3
|
import { createContainerPlugin, createContainerSyntaxPlugin, stringifyAttrs } from "vitepress-plugin-toolkit";
|
|
4
|
-
//#region src/node/
|
|
4
|
+
//#region src/node/parseFieldContent.ts
|
|
5
5
|
/** Tags that carry structured meaning; everything else is description text. */
|
|
6
6
|
const KNOWN_TAGS = new Set([
|
|
7
7
|
"name",
|
|
@@ -103,6 +103,8 @@ function parseFieldContent(content, info) {
|
|
|
103
103
|
result.description = descriptions.join("\n");
|
|
104
104
|
return result;
|
|
105
105
|
}
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/node/fieldPlugin.ts
|
|
106
108
|
const fieldMarkdownPlugin = (md) => {
|
|
107
109
|
createContainerPlugin(md, "field-group", { before: () => "<div class=\"vp-field-group\">" });
|
|
108
110
|
createContainerSyntaxPlugin(md, "field", (tokens, idx, _, env) => {
|
|
@@ -121,4 +123,4 @@ var node_default = definePlugin(() => ({
|
|
|
121
123
|
} }
|
|
122
124
|
}));
|
|
123
125
|
//#endregion
|
|
124
|
-
export { node_default as default, fieldMarkdownPlugin
|
|
126
|
+
export { node_default as default, fieldMarkdownPlugin };
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitepress-plugin-field",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"description": "Render
|
|
4
|
+
"version": "0.2.0",
|
|
5
|
+
"description": "Render structured API fields and properties documentation in your VitePress site.",
|
|
6
6
|
"author": "pengzhanbo <q942450674@outlook.com> (https://github.com/pengzhanbo/)",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
@@ -34,11 +34,12 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@pengzhanbo/utils": "^3.7.3",
|
|
37
|
-
"vitepress-plugin-toolkit": "0.
|
|
38
|
-
"vitepress-tuck": "0.
|
|
37
|
+
"vitepress-plugin-toolkit": "0.2.0",
|
|
38
|
+
"vitepress-tuck": "0.2.0"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
|
-
"access": "public"
|
|
41
|
+
"access": "public",
|
|
42
|
+
"provenance": true
|
|
42
43
|
},
|
|
43
44
|
"scripts": {
|
|
44
45
|
"clean": "rimraf --glob ./dist",
|