Skip to content

Commit 4047eb7

Browse files
authored
Merge pull request #288 from zong-zhe/file-builtin-doc
feat: add docs for filesystem builtin functions
2 parents 1dd261b + 590853f commit 4047eb7

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

docs/reference/model/file.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: "file"
3+
linkTitle: "file"
4+
type: "docs"
5+
description: file system functions
6+
weight: 100
7+
---
8+
9+
## read
10+
11+
`read(filepath: string) -> str`
12+
13+
Read the contents of the file `filepath` and return a string instance.
14+
15+
## glob
16+
17+
`glob(pattern: str) -> str`
18+
19+
Return a list containing all file names that match `pattern`.
20+
21+
## modpath
22+
23+
`modpath() -> str`
24+
25+
Return the root path of the current KCL module (kcl.mod file path or single *.k file path).
26+
27+
## workdir
28+
29+
`workdir() -> str`
30+
31+
Return the path of the current working directory.

docs/reference/model/overview.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,7 @@ For relatively complex general logic, it is provided through the system modules.
5151
<DocsCard header="yaml" href="yaml">
5252
<p>Provides YAML related encoding/decoding functions.</p>
5353
</DocsCard>
54+
<DocsCard header="file" href="file">
55+
<p>Provides filesystem functions.</p>
56+
</DocsCard>
5457
</DocsCards>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: "file"
3+
linkTitle: "file"
4+
type: "docs"
5+
description: 文件系统操作
6+
weight: 100
7+
---
8+
9+
## read
10+
11+
12+
`read(filepath: string) -> str`
13+
14+
读取文件 `filepath` 中的内容,并返回一个字符串实例。
15+
16+
## glob
17+
18+
`glob(pattern: str) -> str`
19+
20+
返回一个包含所有匹配 `pattern` 的文件名的列表。
21+
22+
## modpath
23+
24+
`modpath() -> str`
25+
26+
返回当前模块的根路径(kcl.mod 文件路径或单个 *.k 文件路径)。
27+
28+
## workdir
29+
30+
`workdir() -> str`
31+
32+
返回当前工作目录的路径。

i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/model/overview.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,7 @@ KCL 通过内置模块、系统库模块和插件模块提供工程化的扩展
5151
<DocsCard header="yaml" href="yaml">
5252
<p>提供了与 YAML 相关的编码/解码函数。</p>
5353
</DocsCard>
54+
<DocsCard header="file" href="yaml">
55+
<p>提供了与文件系统相关的函数。</p>
56+
</DocsCard>
5457
</DocsCards>

0 commit comments

Comments
 (0)