Helm 读取生成器
- 基于值YAML文件元数据自动生成Helm Charts READMEs的表格.
- 自动生成一个符合 OpenAPI 的 JSON 计划, 定义
values.yamlhelm图的结构。 生成的文件将是一个 JSON 文件, 格式化为 打开APIv3 Schema 对象 定义.
如何运作
该工具期望在所提供数据中描述一些元数据 values.yaml 文档。 它将分析并检查元数据与真实值.
如果元数据与实际值一致,它将生成数值表并插入所提供的数值表 README.md 文档.
如果元数据不正确,它会打印出完整的出错列表. 它检查是否存在已存在的值的元数据,或者是否存在已存在的值的元数据缺失.
将插入 readme.md 将具有以下结构:
## Parameters
### Section 1 title
| Name | Description | Default |
|:----------|:------------------------|:---------------|
| `value_1` | Description for value 1 | `defaultValue` |
| `value_2` | Description for value 2 | `defaultValue` |
| `value_3` | Description for value 3 | `defaultValue` |
### Section 2 title
| Name | Description | Default |
|:----------|:------------------------|:---------------|
| `value_1` | Description for value 1 | `defaultValue` |
| `value_2` | Description for value 2 | `defaultValue` |
| `value_3` | Description for value 3 | `defaultValue` |
...
数目 # 区域标题所需的字符是动态计算,标题是 Parameters 区域可以通过 配置文件编辑 README.md 带有一个文件 ## Parameters 区域在运行工具前必须创建 Parameters 区应该有两个 # 或更多符号.
所需资源
该项目已经开发并测试了节点版本 22.x。 。 。 .
安装
执行以下安装工具的命令 :
git clone https://github.com/bitnami/readme-generator-for-helm
npm install ./readme-generator-for-helm
取决于您如何在您的系统中安装节点JS, 您可能需要修改您 PATH 能够执行该工具的环境变量.
单二进制
执行以下命令以创建工具的单一可执行二进制 :
git clone https://github.com/bitnami/readme-generator-for-helm
cd ./readme-generator-for-helm
npm install
npm install -g @yao-pkg/pkg
pkg . -o readme-generator-for-helm
测试
我们用 欢乐 实施测试。 为了测试您的更改, 请执行以下命令 :
npm run-script test
林特
修改代码后执行以下命令来通过linter:
npm run-script lint
基本用途
Usage: readme-generator [options]
Options:
-v, --values <path> Path to the values.yaml file
-r, --readme <path> Path to the README.md file
-c, --config <path> Path to the config file
-s, --schema <path> Path for the OpenAPI Schema output file
--version Show Readme Generator version
-h, --help display help for command
数值.yaml 元数据
要使用工具, 您需要添加一些元数据 values.yaml 文档.
默认情况下,我们使用类似于Javadoc的格式,使用 @xxx 标记结构.
以下是在此时刻支持的标记 :
- 参数:
## @param fullKeyPath [modifier?] Description。 。 。 . - 一节:
## @section Section Title"。 。 。 . - 跳过一个物体及其所有的孩子:
## @skip fullKeyPath Description?。 。 。 . - 添加中间对象的描述( 即在 YAML 树上不是最后的) :
## @extra fullkeyPath Description。 。 。 .
所有标记以及两个开头 # 注释样式的字符可以在 配置文件。 。 。 .
[大 标签在文件中的顺序或位置并不重要,除了@section tag 。 在找到新区域或文件结束之前, @ section 将包含其后的所有参数 .
这个 modifier 是可选的,它将改变参数的处理方式.
通过使用逗号将其相分离,可以应用几个修饰符(,) (中文(简体) ). 当影响值时,最后一个值优先.
目前支持的修改符 :
[array]表示参数的值必须设置为[]。 。 。 .[object]表示参数的值必须设置为{}。 。 。 .[string]表示参数的值必须设置为""。 。 。 .[nullable]表示参数值可以设定为null。 。 。 .[default: DEFAULT_VALUE]设定默认值为DEFAULT_VALUE。 。 。 .
修饰者也可以通过 配置文件。 。 。 .
如果你要加一个 custom modifier 到数值文件中没有值的参数
您必须添加一个 supported modifiers 作为最后一个修饰符.
示例
值文件
# @param noDefaultValue [number, nullable] Description
# noDefaultValue: 1
自定义配置片段 :
{
...
"modifiers": {
"array": "array",
"object": "object"
"string": "string"
"nullable": "nullable",
"number": "number"
},
...
}
配置文件
配置文件的结构如下:
{
"comments": {
"format": "##" <-- Which is the comments format in the values YAML
},
"tags": {
"param": "@param", <-- Tag that indicates a parameter
"section": "@section", <-- Tag that indicates a section
"descriptionStart": "@descriptionStart", <-- Tag that indicates the beginning of a section description
"descriptionEnd": "@descriptionEnd", <-- Tag that indicates the end of a section description
"skip": "@skip", <-- Tag that indicates the object must be skipped
"extra": "@extra" <-- Tag to add a description for an intermediate object
},
"modifiers": {
"array": "array", <-- Modifier that indicates an array type
"object": "object" <-- Modifier that indicates an object type
"string": "string" <-- Modifier that indicates a string type
"nullable": "nullable" <-- Modifier that indicates a parameter that can be set to null
},
"regexp": {
"paramsSectionTitle": "Parameters" <-- Title of the parameters section to replace in the README.md
}
}
承诺前
将此添加到您的 .pre-commit-config.yaml数字 :
- repo: https://github.com/bitnami/readme-generator-for-helm
rev: "main"
hooks:
- id: helm-readme-generator
# in order to run helm-readme-generator only once
pass_filenames: false
always_run: true
# default args are [--readme=chart/README.md, --values=chart/values.yaml]
args: [--readme=path/to/README.md, --values=path/to/values.yaml]
版本数
2.8.0 (中文(简体) )
描述现在只丢弃一个白色空间 。 这样,代码块可以使用适当的缩进.
2.4.0 (中文(简体) )
添加 descriptionStart 财务报告和审定财务报表 descriptionEnd 配置选项( 默认标签 : @descriptionStart 财务报告和审定财务报表 @descriptionEnd(中文(简体) )
在 README.md 中允许文本块前方的每个区块。 更改这些标记值时, 确保不发生冲突
与 section 配置选项 .
如果你使用定制的 配置文件,请添加新的默认标记,以防止任何错误的行为.
2.0.0 (韩语)
这个 -m (--metadata) 选项已更名为 -s (--schema) 以正确识别它产生的东西.
许可证
版权:"2025 Broadcom". "Broadcom"一词指Broadcom Inc.和/或其子公司.
根据Apache许可证第2.0版("License"); 您不得使用此文件,除非符合许可证. 您可在下列地点获得许可证副本:
http://www.apache.org/licenses/LICENSE-2.0 (中文(简体) )
除非适用的法律要求或书面同意,否则软件 根据许可证发放的是在“AS IS”BASIS上发放的, 没有任何明示或暗示的警告或条件. 有关许可的特定语言的许可证 许可证的限制.