@forsakringskassan/docs-generator

中文文档
3.24.2发布于 2026/11/12MITTypeScriptES Module构建来源已验证近 30 天下载 2.8万

文档生成器

中文使用文档
文档目录14 节
  1. 设置
  2. 监视( 开发模式)
  3. 供应商别名
  4. 使用量
  5. 使用 Vue 2
  6. 使用 Vue 3
  7. 样式
  8. 标记
  9. 前题
  10. 内置标签
  11. 温和
  12. 环境变量
  13. 处理器
  14. 马多莫

@forsakringskassan/docs-generator

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

设置

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

监视( 开发模式)

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

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".

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 需要安装额外的依赖:

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

创建 setup 调用 docs/src/setup.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数字 :

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])数字 :

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 包含:

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

标记

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

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

将作为:

<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 用于手动设置当代码是否作为活例运行时.

```html static
<p>This is displayed as syntax highlighted code only</p>
```
```js live
alert("This is run in the browser");
```

实例可以使用 import 指令 :

```import
MyAwesomeFile.vue
```

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

导入一个使用 生活实例 您还需要使用 live-example 标签.

```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。 。 。 .

内置标签

隐含标题 :

Use the {@@link MyAwesomeComponent} component.

明确标题:

Use the {@@link MyAwesomeComponent awesome component}.

{@@optional}

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

输入 :

{@@optional}

输出 :

[可选]

温和

这个 纳尼亚克人 调温引擎用于向 HTML 渲染文档. 见 临时文件 寻求帮助.

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

container

{% container "awesome-name" %}

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

环境变量

DOCS_ICON_LIB

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

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

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

处理器

马多莫

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

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

 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 共发布 199 个版本,首次发布于 2024/04/12;过去 12 个月发布了 85 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.24.2latest2026/11/123 天前
3.24.12026/11/114 天前
3.24.02026/11/114 天前
3.23.12026/11/069 天前
3.23.02026/11/0115 天前
3.22.32026/10/3016 天前

关于 @forsakringskassan/docs-generator 的常见问题

@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 和提交记录判断。