Skip to content

Commit

Permalink
feat: add yaml.dump_all_to_file documents and format all documents
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Sep 4, 2024
1 parent d8b13b0 commit 54561a2
Show file tree
Hide file tree
Showing 22 changed files with 86 additions and 24 deletions.
13 changes: 13 additions & 0 deletions docs/reference/model/yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ dump_to_file(

Serialize a KCL object `data` to a YAML formatted str and write it into the file `filename`.

## dump_to_file

```python
dump_all_to_file(
data: [any],
filename: str,
ignore_private: bool = False,
ignore_none: bool = False
) -> None
```

Serialize a sequence of KCL objects into a YAML stream str and write it into the file `filename`.

## validate

```python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ More Details - [Download Private Repository Using Git](https://docs.github.com/e

## Add a Git Repository as a Dependency

You can use `kcl mod add` to add a Git repository as a dependency to the KCL package.
You can use `kcl mod add` to add a Git repository as a dependency to the KCL package.

Take `https://github.com/kcl-lang/konfig` as an example. The command is as follows:

Expand All @@ -26,13 +26,11 @@ kcl mod add git://github.com/kcl-lang/konfig --commit 78ba6e9 # Add a Git reposi
kcl mod add git://github.com/kcl-lang/konfig --branch main # Add a Git repository with a branch
```

The way shown above is to add a Git repository as a dependency with Https protocol.
The way shown above is to add a Git repository as a dependency with Https protocol.
You can also use the `ssh` protocol or some other protocols to add a Git repository as a dependency as follows:

```shell
kcl mod add --git https://github.com/kcl-lang/konfig --tag v0.4.0 # Add a Git repository with a tag and Https protocol
kcl mod add --git https://github.com/kcl-lang/konfig --branch main # Add a Git repository with a branch and Https protocol
kcl mod add --git ssh://github.com/kcl-lang/konfig --commit 78ba6e9 # Add a Git repository with a commit and ssh protocol
```


Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The default content of the configuration file is as follows:
```json
{
"DefaultOciRegistry": "ghcr.io",
"DefaultOciRepo": "kcl-lang",
"DefaultOciRepo": "kcl-lang"
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ KCL 和 kusionstack 社区也同 crossplane 社区的同时进行了令人开心
- [Kusion Github 仓库](https://github.com/KusionStack/kusion)
- [Konfig Github 仓库](https://github.com/KusionStack/konfig)

欢迎加入我们的社区进行交流 👏👏👏:[https://github.com/kcl-lang/community](https://github.com/kcl-lang/community)
欢迎加入我们的社区进行交流 👏👏👏:[https://github.com/kcl-lang/community](https://github.com/kcl-lang/community)
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ dump_to_file(

将 KCL 对象 `data` 序列化为 YAML 格式的字符串,并将其写入文件 `filename` 中。

## dump_to_file

```python
dump_all_to_file(
data: [any],
filename: str,
ignore_private: bool = False,
ignore_none: bool = False
) -> None
```

将 KCL 对象列表序列化为 YAML Stream 格式,并将其写入文件 `filename` 中。

## validate

```python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ KCL 包管理工具的配置文件位于 `$KCL_PKG_PATH/.kpm/config/kpm.json`,
```json
{
"DefaultOciRegistry": "ghcr.io",
"DefaultOciRepo": "kcl-lang",
"DefaultOciRepo": "kcl-lang"
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ weight: 100

## decode

`decode(value: str, encoding: str = "utf-8") -> str`
`decode(value: str) -> str`

使用注册的编码器对字符串 `value` 进行解码
使用注册的编码器对字符串 `value` 进行解码,解码的结果是一个 utf8 字符串
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ weight: 100

使用注册编码器和 `SHA512` 算法对字符串 `value` 进行加密。

## blake3

`sha512(value: str, encoding: str = "utf-8") -> str`

使用注册编码器和 `BLAKE3` 算法对字符串 `value` 进行加密。

## uuid

`uuid() -> str`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ dump_to_file(

将 KCL 对象 `data` 序列化为 YAML 格式的字符串,并将其写入文件 `filename` 中。

## dump_to_file

```python
dump_all_to_file(
data: [any],
filename: str,
ignore_private: bool = False,
ignore_none: bool = False
) -> None
```

将 KCL 对象列表序列化为 YAML Stream 格式,并将其写入文件 `filename` 中。

## validate

```python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ KCL 包管理工具的配置文件位于 `$KCL_PKG_PATH/.kpm/config/kpm.json`,
```json
{
"DefaultOciRegistry": "ghcr.io",
"DefaultOciRepo": "kcl-lang",
"DefaultOciRepo": "kcl-lang"
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ KCL 包管理工具的配置文件位于 `$KCL_PKG_PATH/.kpm/config/kpm.json`,
```json
{
"DefaultOciRegistry": "ghcr.io",
"DefaultOciRepo": "kcl-lang",
"DefaultOciRepo": "kcl-lang"
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ KCL 包管理工具的配置文件位于 `$KCL_PKG_PATH/.kpm/config/kpm.json`,
```json
{
"DefaultOciRegistry": "ghcr.io",
"DefaultOciRepo": "kcl-lang",
"DefaultOciRepo": "kcl-lang"
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ KCL 包管理工具的配置文件位于 `$KCL_PKG_PATH/.kpm/config/kpm.json`,
```json
{
"DefaultOciRegistry": "ghcr.io",
"DefaultOciRepo": "kcl-lang",
"DefaultOciRepo": "kcl-lang"
}
```

Expand Down
4 changes: 2 additions & 2 deletions versioned_docs/version-0.10/reference/model/base64.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ Encode the string `value` using the codec registered for encoding.

## decode

`decode(value: str, encoding: str = "utf-8") -> str`
`decode(value: str) -> str`

Decode the string `value` using the codec registered for encoding.
Decode the string `value` using the codec registered to the utf8 string for encoding.
6 changes: 6 additions & 0 deletions versioned_docs/version-0.10/reference/model/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ Encrypt the string `value` using `SHA384` and the codec registered for encoding.

Encrypt the string `value` using `SHA512` and the codec registered for encoding.

## blake3

`blake3(value: str, encoding: str = "utf-8") -> str`

Encrypt the string `value` using `BLAKE3` and the codec registered for encoding.

## uuid

`uuid() -> str`
Expand Down
13 changes: 13 additions & 0 deletions versioned_docs/version-0.10/reference/model/yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ dump_to_file(

Serialize a KCL object `data` to a YAML formatted str and write it into the file `filename`.

## dump_to_file

```python
dump_all_to_file(
data: [any],
filename: str,
ignore_private: bool = False,
ignore_none: bool = False
) -> None
```

Serialize a sequence of KCL objects into a YAML stream str and write it into the file `filename`.

## validate

```python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ More Details - [Download Private Repository Using Git](https://docs.github.com/e

## Add a Git Repository as a Dependency

You can use `kcl mod add` to add a Git repository as a dependency to the KCL package.
You can use `kcl mod add` to add a Git repository as a dependency to the KCL package.

Take `https://github.com/kcl-lang/konfig` as an example. The command is as follows:

Expand All @@ -26,7 +26,7 @@ kcl mod add git://github.com/kcl-lang/konfig --commit 78ba6e9 # Add a Git reposi
kcl mod add git://github.com/kcl-lang/konfig --branch main # Add a Git repository with a branch
```

The way shown above is to add a Git repository as a dependency with Https protocol.
The way shown above is to add a Git repository as a dependency with Https protocol.
You can also use the `ssh` protocol or some other protocols to add a Git repository as a dependency as follows:

```shell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ You can adjust the registry and repository name of the OCI registry by the follo

### By environment variable

You can adjust the configuration of OCI Registry by setting the three environment variables `KPM_REG`, `KPM_REGO`, and `OCI_REG_PLAIN_HTTP`.
You can adjust the configuration of OCI Registry by setting the three environment variables `KPM_REG`, `KPM_REGO`.

```shell
# set default registry
Expand All @@ -43,7 +43,7 @@ The default content of the configuration file is as follows:
```json
{
"DefaultOciRegistry": "ghcr.io",
"DefaultOciRepo": "kcl-lang",
"DefaultOciRepo": "kcl-lang"
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The default content of the configuration file is as follows:
```json
{
"DefaultOciRegistry": "ghcr.io",
"DefaultOciRepo": "kcl-lang",
"DefaultOciRepo": "kcl-lang"
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ More Details - [Download Private Repository Using Git](https://docs.github.com/e

## Add a Git Repository as a Dependency

You can use `kcl mod add` to add a Git repository as a dependency to the KCL package.
You can use `kcl mod add` to add a Git repository as a dependency to the KCL package.

Take `https://github.com/kcl-lang/konfig` as an example. The command is as follows:

Expand All @@ -26,7 +26,7 @@ kcl mod add git://github.com/kcl-lang/konfig --commit 78ba6e9 # Add a Git reposi
kcl mod add git://github.com/kcl-lang/konfig --branch main # Add a Git repository with a branch
```

The way shown above is to add a Git repository as a dependency with Https protocol.
The way shown above is to add a Git repository as a dependency with Https protocol.
You can also use the `ssh` protocol or some other protocols to add a Git repository as a dependency as follows:

```shell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The default content of the configuration file is as follows:
```json
{
"DefaultOciRegistry": "ghcr.io",
"DefaultOciRepo": "kcl-lang",
"DefaultOciRepo": "kcl-lang"
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The default content of the configuration file is as follows:
```json
{
"DefaultOciRegistry": "ghcr.io",
"DefaultOciRepo": "kcl-lang",
"DefaultOciRepo": "kcl-lang"
}
```

Expand Down

0 comments on commit 54561a2

Please sign in to comment.