Skip to content

Commit baee848

Browse files
committed
feat: add docs for filesystem builtin functions
Signed-off-by: zongz <zongzhe1024@163.com>
1 parent 501d8e0 commit baee848

File tree

2 files changed

+63
-0
lines changed
  • docs/reference/model
  • i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/model

2 files changed

+63
-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.
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+
返回当前工作目录的路径。

0 commit comments

Comments
 (0)