# @forsakringskassan/docs-generator 中文文档

规范地址：https://npmcn.com/package/%40forsakringskassan/docs-generator/

版本：3\.24\.2
npm 元数据更新时间：2026-11-12T14:53:33.151Z
中文译文更新时间：2026-11-15T09:29:16.796Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40forsakringskassan/docs-generator
原文对照：https://npmcn.com/package/%40forsakringskassan/docs-generator/?lang=original
项目主页：https://github.com/Forsakringskassan/docs-generator
源码仓库：https://github.com/Forsakringskassan/docs-generator

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：32.1 MB，77 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- Node.js 要求：^22\.22 \|\| ^24\.11 \|\| \>= 26
- 运行依赖：10 个
- peer 依赖：he ^1\.2，vue ^3\.0\.0，sass ^1\.71，esbuild 0\.x，express ^4 \|\| ^5\.0\.0
- 首次发布：2024-04-12T00:06:45.979Z
- 最新版本发布：2026-11-12T14:53:32.551Z
- 近 30 天下载量：28224（2026-10-16 至 2026-11-14，npm 官方下载统计）
- 已发布版本数：199（近 12 个月 85 个）

## 中文简介

文档生成器

## 安装

```sh
npm install @forsakringskassan/docs-generator
```

也可以使用：`pnpm add @forsakringskassan/docs-generator`、`yarn add @forsakringskassan/docs-generator`、`bun add @forsakringskassan/docs-generator`

## README

# `@forsakringskassan/docs-generator`

```bash
npm install --save-dev --save-exact @forsakringskassan/docs-generator
```

## 设置

过 `import.meta.dirname` 作为第一个参数 `Generator` 以配置文件的目录作为工作目录. 生成器选项中的路径相对于此目录解决 .

### 监视( 开发模式)

您可以使用 : `.serve()`。 。 。 .

```ts
import {
    Generator,
    livereloadProcessor,
} from "@forsakringskassan/docs-generator";

const docs = new Generator(import.meta.dirname, {
    site: {
        name: "My Awesome Site",
    },
    setupPath: "docs/src/setup.ts",
    processors: [livereloadProcessor({ enabled: true })],
    sourceFiles: [/* ... */],
});

docs.build();
docs.serve();
```

### 供应商别名

销售者别名是可选的,它允许您在捆绑时将一个包替换为另一个包. 下面的例子可以替代软件包 `vue` 用软件包 `vue/dist/esm.bundle.js`。当给定一个别名时,可以使用给定的别名以及原包名导入该包。 例如,当使用以下配置"vue"时,可以导入并解析为"vue/dist/esm.bundle.js".

```ts
import {
    Generator,
    livereloadProcessor,
} from "@forsakringskassan/docs-generator";

const docs = new Generator(import.meta.dirname, {
    site: {
        name: "My Awesome Site",
    },
    setupPath: "docs/src/setup.ts",

    vendor: [
        {
            package: "vue",
            alias: "vue/dist/esm.bundle.js",
        },
    ],
});
```

## 使用量

### 使用 Vue 2

Vue 2 需要安装额外的依赖:

```bash
npm install --save-dev --save-exact @vue/component-compiler
```

创建 `setup` 调用 `docs/src/setup.ts`数字 :

```ts
import Vue from "vue";
import { type SetupOptions } from "@forsakringskassan/docs-generator";

/* optionally add global plugins or configuration */
//Vue.use(MyAwesomePlugin);

export function setup(options: SetupOptions): void {
    const { rootComponent, selector } = options;
    const vm = new Vue(rootComponent);
    vm.$mount(selector);
}
```

### 使用 Vue 3

创建 `setup` 调用 `docs/src/setup.ts`数字 :

```ts
import { createApp } from "vue";
import { type SetupOptions } from "@forsakringskassan/docs-generator";

export function setup(options: SetupOptions): void {
    const { rootComponent, selector } = options;
    const app = createApp(rootComponent);

    /* optionally add global plugins or configuration */
    //app.use(MyAwesomePlugin);

    app.mount(selector);
}
```

### 样式

提供了三个CSS文件:

-   `@forsakringskassan/docs-generator/style/index.css` (别名: `@forsakringskassan/docs-generator/style`(中文(简体) )
-   `@forsakringskassan/docs-generator/style/core.css`
-   `@forsakringskassan/docs-generator/style/site.css`

`core` 包含组件和元素的必要样式,以及 `site` 包含文档站点工作所需的布局、打字等. `index` 是两者的结合,在大多数情况下应当使用.

样式可以编译为 `compileStyle(name, src, [options])`数字 :

```ts
import { Generator } from "@forsakringskassan/docs-generator";

const docs = new Generator(import.meta.dirname, {
    site: {
        name: "My Awesome Site",
    },
    setupPath: "docs/src/setup.ts",
});

docs.compileStyle("docs", "./docs/src/style.scss", {
    appendTo: "head",
});
```

何处 `docs/src/style.scss` 包含:

```scss
@use "~@forsakringskassan/docs-generator/style";
```

### 标记

#### 链接 `{@link ...}`

创建不同文档使用的链接 `{@link ID [TITLE]}`,例如:

```md
See {@link MyAwesomeComponent} for details or the {@link getting-started getting started guide}.
```

将作为:

```html
<p>
    See
    <a href="./components/my-awesome-component.html">MyAwesomeComponent</a> for
    details or the
    <a href="../guides/getting-started.html">getting started guide</a>.
</p>
```

ID可以是文档标识符,名称,也可以是其中一个别名. 链接目的地将始终相对于当前文档.

#### 代码围栏

对于已配置的语言( 默认) `html` 财务报告和审定财务报表 `vue`) 代码栅栏作为浏览器中的活例运行,可选择显示源代码. 下列标记可以使用:

-   `borderless` - 将边框从示例中删除.
-   `fullscreen` - 支持在全屏中查看示例.
-   `static` - 强制代码在不进行活预览的情况下提供(只有语法突现).
-   `live-example` - 将示例标为: `LiveExample` 组件.
-   `nomarkup` - 对于活的示例,它隐藏了语法突出的代码,只显示运行代码的结果.
-   `test-id=STRING` - 设定 `data-test` 属性.

`static` 财务报告和审定财务报表 `live` 用于手动设置当代码是否作为活例运行时.

````md
```html static
<p>This is displayed as syntax highlighted code only</p>
```
````

````md
```js live
alert("This is run in the browser");
```
````

实例可以使用 `import` 指令 :

````md
```import
MyAwesomeFile.vue
```
````

这将搜索 `MyAwesomeFile.vue` 在配置中 `exampleFolders`。 。 。 . HTML 注释可以放在文件名之前或之后.

导入一个使用 [生活实例](https://github.com/Forsakringskassan/docs-live-example) 您还需要使用 `live-example` 标签.

````md
```import live-example
MyAwesomeLiveExampleFile.vue
```
````

### 前题

#### `status`

为组件设置状态徽章 .

承认以下地位:

-   `Produktionsklar`
-   `Deprekerad`
-   `Experimentell`
-   `Preliminär`
-   `Draft` (折旧的别名用于: `Preliminär`(中文(简体) )
-   `Beta` (折旧的别名用于: `Preliminär`(中文(简体) )

#### `title`

使用的文档标题 `<title>` 财务报告和审定财务报表 `<nav>`

#### `short-title`

需要缩短标题时使用的文档标题,例如站点导航.

#### `visible`

设定为 `false` 从导航菜单中隐藏文档. 默认 `true`。 。 。 .

#### `include`

设定为 `false` 不将文档写入文件或包含为页面. 默认 `true`。 。 。 .

### 内置标签

#### `{@@link ...}`

隐含标题 :

```md
Use the {@@link MyAwesomeComponent} component.
```

明确标题:

```md
Use the {@@link MyAwesomeComponent awesome component}.
```

#### `{@@optional}`

创建标记( badge) 标记某物为可选 .

**输入 :**

```md
{@@optional}
```

**输出 :**

\[可选\]

### 温和

这个 [纳尼亚克人](https://mozilla.github.io/nunjucks/) 调温引擎用于向 HTML 渲染文档. 见 [临时文件](https://mozilla.github.io/nunjucks/templating.html) 寻求帮助.

这些自定义过滤器和标签可供使用 :

#### `container`

```
{% container "awesome-name" %}
```

创建处理器可注入内容的容器.

### 环境变量

#### `DOCS_ICON_LIB`

首选图标库包名 . 默认为 `@fkui/icon-lib-default`。 。 。 . 使得可以动态地加载图标并获取图标元数据. 图书馆一定是用 `@fkui/icon-lib-builder`。 。 。 .

```js
const icons = await import(process.env.DOCS_ICON_LIB);

for (const entry of Object.values(icons)) {
    entry.injectSpritesheet();
}
```

## 处理器

### 马多莫

```diff
 const docs = new Generator(import.meta.dirname, {
     processors: [
+        matomoProcessor({
+            siteId: "1",
+            apiUrl: "https://matomo.example.net/",
+            trackerUrl: "https://matomo.example.net/",
+        }),
     ],
 });
```

可选设置 `hostname` 以限制哪些主机名可以运行 Matomo 分析器 :

```diff
 const docs = new Generator(import.meta.dirname, {
     processors: [
         matomoProcessor({
             siteId: "1",
             apiUrl: "https://matomo.example.net/",
             trackerUrl: "https://matomo.example.net/",
+            hostname: "docs.example.net",
         }),
     ],
 });
```

只有域必须指定,例如它不应包括 `https://` 或路径 `/path/to/docs`。 。 。 . 多个主机名可以指定为数组.

## 常见问题

### @forsakringskassan/docs-generator 是什么？

文档生成器

### 如何安装 @forsakringskassan/docs-generator？

在项目目录运行 npm install @forsakringskassan/docs-generator，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：he（^1\.2）、vue（^3\.0\.0）、sass（^1\.71）、esbuild（0\.x）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @forsakringskassan/docs-generator 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @forsakringskassan/docs-generator 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @forsakringskassan/docs-generator 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js ^22\.22 \|\| ^24\.11 \|\| \>= 26。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @forsakringskassan/docs-generator 可以商用吗？

@forsakringskassan/docs-generator 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @forsakringskassan/docs-generator 的下载量有多少？

根据 npm 官方下载统计，@forsakringskassan/docs-generator 在 2026/10/16 – 2026/11/14 这 30 天内被下载 28,224 次，日均约 941 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @forsakringskassan/docs-generator 还在维护吗？

最新版本 3\.24\.2 发布于 2026/11/12（3 天前）；至今共发布 199 个版本，其中过去 12 个月发布了 85 个；首次发布于 2024/04/12。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

