Skip to content

Commit e580b9a

Browse files
authored
Merge pull request #321 from Peefy/file-abs-and-exists-documents
docs: add file.abs and file.exists documents
2 parents 1d91e72 + 2740c60 commit e580b9a

File tree

2 files changed

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

2 files changed

+26
-2
lines changed

docs/reference/model/file.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ weight: 100
88

99
## read
1010

11-
`read(filepath: string) -> str`
11+
`read(filepath: str) -> str`
1212

1313
Read the contents of the file `filepath` and return a string instance.
1414

@@ -29,3 +29,15 @@ Return the root path of the current KCL module (kcl.mod file path or single \*.k
2929
`workdir() -> str`
3030

3131
Return the path of the current working directory.
32+
33+
## exists
34+
35+
`exists(filepath: str) -> bool`
36+
37+
Whether this file path exists. Returns true if the path points at an existing entity. This function will traverse symbolic links to query information about the destination file.
38+
39+
## abs
40+
41+
`abs(filepath: str) -> str`
42+
43+
Returns the canonical, absolute form of the path with all intermediate components normalized and symbolic links resolved.

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ weight: 100
88

99
## read
1010

11-
`read(filepath: string) -> str`
11+
`read(filepath: str) -> str`
1212

1313
读取文件 `filepath` 中的内容,并返回一个字符串实例。
1414

@@ -29,3 +29,15 @@ weight: 100
2929
`workdir() -> str`
3030

3131
返回当前工作目录的路径。
32+
33+
## exists
34+
35+
`exists(filepath: str) -> bool`
36+
37+
判断文件路径是否存在。如果路径指向一个存在的实体,则返回 True。此函数会遍历符号链接以查询目标文件的信息。
38+
39+
## abs
40+
41+
`abs(filepath: str) -> str`
42+
43+
返回路径的规范化绝对形式,其中所有中间路径均已规范化并解析为符号链接。

0 commit comments

Comments
 (0)