-
-When the pkgpath is '__main__', it can be omitted.
-```
-
-importPaths. List of import statements that need to be added
-
-## func [Validate](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L198)
+## func [Validate](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L219)
```go
func Validate(dataFile, schemaFile string, opts *ValidateOptions) (ok bool, err error)
@@ -352,7 +365,7 @@ func Validate(dataFile, schemaFile string, opts *ValidateOptions) (ok bool, err
Validate validates the given data file against the specified schema file with the provided options.
-## func [ValidateCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L192)
+## func [ValidateCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L213)
```go
func ValidateCode(data, code string, opts *ValidateOptions) (ok bool, err error)
@@ -360,7 +373,7 @@ func ValidateCode(data, code string, opts *ValidateOptions) (ok bool, err error)
ValidateCode validate data string match code string
-## type [KCLResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L54)
+## type [KCLResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L57)
```go
type KCLResult = kcl.KCLResult
@@ -409,7 +422,7 @@ x1.age: 101
-Example ('et_struct)
+Example (Get)
```go
@@ -454,13 +467,13 @@ person: {Name:kcl Age:101}
-## type [KCLResultList](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L55)
+## type [KCLResultList](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L58)
```go
type KCLResultList = kcl.KCLResultList
```
-### func [MustRun](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L71)
+### func [MustRun](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L85)
```go
func MustRun(path string, opts ...Option) *KCLResultList
@@ -587,7 +600,7 @@ func main() {
-### func [Run](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L76)
+### func [Run](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L90)
```go
func Run(path string, opts ...Option) (*KCLResultList, error)
@@ -595,7 +608,15 @@ func Run(path string, opts ...Option) (*KCLResultList, error)
Run evaluates the KCL program with path and opts, then returns the object list.
-Example (Get Field)
+### func [RunFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L95)
+
+```go
+func RunFiles(paths []string, opts ...Option) (*KCLResultList, error)
+```
+
+RunFiles evaluates the KCL program with multi file path and opts, then returns the object list.
+
+Example
```go
@@ -603,43 +624,134 @@ package main
import (
"fmt"
- "log"
kcl "kcl-lang.io/kcl-go"
)
-func assert(v bool, a ...interface{}) {
- if !v {
- a = append([]interface{}{"assert failed"}, a...)
- log.Panic(a...)
- }
+func main() {
+ result, _ := kcl.RunFiles([]string{"./testdata/app0/kcl.yaml"})
+ fmt.Println(result.First().YAMLString())
}
+```
-func main() {
- // run kcl.yaml
- x, err := kcl.Run("./testdata/app0/kcl.yaml")
- assert(err == nil, err)
+
+
+
+## type [KclType](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L60)
+
+```go
+type KclType = kcl.KclType
+```
+
+### func [GetSchemaType](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L241)
+
+```go
+func GetSchemaType(filename string, src any, schemaName string) ([]*KclType, error)
+```
+
+GetSchemaType returns schema types from a kcl file or code.
+
+file: string
- // print deploy_topology[1].zone
- fmt.Println(x.First().Get("deploy_topology.1.zone"))
+```
+The kcl filename
+```
+
+code: string
+
+```
+The kcl code string
+```
+
+schema_name: string
+
+```
+The schema name got, when the schema name is empty, all schemas are returned.
+```
+
+## type [ListDepFilesOption](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L52)
+
+```go
+type ListDepFilesOption = list.Option
+```
+
+## type [ListDepsOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L51)
+
+```go
+type ListDepsOptions = list.DepOptions
+```
+
+## type [ListOptionsArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L68)
+
+```go
+type ListOptionsArgs = loader.ListOptionsArgs
+```
+
+## type [ListOptionsResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L69)
+
+```go
+type ListOptionsResult = loader.ListOptionsResult
+```
+
+### func [ListOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L280)
+
+```go
+func ListOptions(args *ListOptionsArgs) (*ListOptionsResult, error)
+```
+
+ListOptions provides users with the ability to parse kcl program and get all option calling information.
+
+Example
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+)
+
+func main() {
+ result, err := kcl.ListOptions(&kcl.ListOptionsArgs{
+ Paths: []string{"testdata/option/main.k"},
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(result)
}
```
```
-R000A
+options:{name:"key1"} options:{name:"key2" required:true} options:{name:"metadata-key"}
```
-### func [RunFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L81)
+## type [ListVariablesArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L66)
```go
-func RunFiles(paths []string, opts ...Option) (*KCLResultList, error)
+type ListVariablesArgs = loader.ListVariablesArgs
```
-RunFiles evaluates the KCL program with multi file path and opts, then returns the object list.
+## type [ListVariablesResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L67)
+
+```go
+type ListVariablesResult = loader.ListVariablesResult
+```
+
+### func [ListVariables](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L274)
+
+```go
+func ListVariables(args *ListVariablesArgs) (*ListVariablesResult, error)
+```
+
+ListVariables provides users with the ability to parse KCL program and get all variables by specs.
Example
@@ -649,44 +761,95 @@ package main
import (
"fmt"
+ "log"
kcl "kcl-lang.io/kcl-go"
)
func main() {
- result, _ := kcl.RunFiles([]string{"./testdata/app0/kcl.yaml"})
- fmt.Println(result.First().YAMLString())
+ result, err := kcl.ListVariables(&kcl.ListVariablesArgs{
+ Files: []string{"testdata/main.k"},
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(result)
+
}
```
+```
+variables:{key:"age" value:{variables:{value:"2" op_sym:"="}}} variables:{key:"four" value:{variables:{value:"4" op_sym:"="}}} variables:{key:"name" value:{variables:{value:"\"kcl-go\"" op_sym:"="}}} variables:{key:"x0" value:{variables:{value:"Person {}" type_name:"Person" op_sym:"="}}} variables:{key:"x1" value:{variables:{value:"Person {age = 101}" type_name:"Person" op_sym:"=" dict_entries:{key:"age" value:{value:"101" op_sym:"="}}}}}
+```
+
-## type [KclType](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L57)
+## type [LoadPackageArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L64)
```go
-type KclType = kcl.KclType
+type LoadPackageArgs = loader.LoadPackageArgs
```
-## type [ListDepFilesOption](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L49)
+## type [LoadPackageResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L65)
```go
-type ListDepFilesOption = list.Option
+type LoadPackageResult = loader.LoadPackageResult
```
-## type [ListDepsOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L48)
+### func [LoadPackage](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L269)
```go
-type ListDepsOptions = list.DepOptions
+func LoadPackage(args *LoadPackageArgs) (*LoadPackageResult, error)
```
-## type [Option](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L47)
+LoadPackage provides users with the ability to parse KCL program and semantic model information including symbols, types, definitions, etc.
+
+Example
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+)
+
+func main() {
+ result, err := kcl.LoadPackage(&kcl.LoadPackageArgs{
+ ParseArgs: &kcl.ParseProgramArgs{
+ Paths: []string{"testdata/main.k"},
+ },
+ ResolveAst: true,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(result)
+}
+```
+
+
+
+
+## type [Option](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L50)
```go
type Option = kcl.Option
```
-### func [WithCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L86)
+### func [NewOption](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L100)
+
+```go
+func NewOption() *Option
+```
+
+NewOption returns a new Option.
+
+### func [WithCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L105)
```go
func WithCode(codes ...string) Option
@@ -694,7 +857,7 @@ func WithCode(codes ...string) Option
WithCode returns a Option which hold a kcl source code list.
-### func [WithDisableNone](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L110)
+### func [WithDisableNone](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L134)
```go
func WithDisableNone(disableNone bool) Option
@@ -702,7 +865,15 @@ func WithDisableNone(disableNone bool) Option
WithDisableNone returns a Option which hold a disable none switch.
-### func [WithExternalPkgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L89)
+### func [WithExternalPkgAndPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L111)
+
+```go
+func WithExternalPkgAndPath(name, path string) Option
+```
+
+WithExternalPkgAndPath returns a Option which hold a external package.
+
+### func [WithExternalPkgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L108)
```go
func WithExternalPkgs(externalPkgs ...string) Option
@@ -710,7 +881,7 @@ func WithExternalPkgs(externalPkgs ...string) Option
WithExternalPkgs returns a Option which hold a external package list.
-### func [WithFullTypePath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L118)
+### func [WithFullTypePath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L142)
```go
func WithFullTypePath(fullTypePath bool) Option
@@ -718,7 +889,7 @@ func WithFullTypePath(fullTypePath bool) Option
WithFullTypePath returns a Option which hold a include full type string in the \`\_type\` attribute.
-### func [WithIncludeSchemaTypePath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L113)
+### func [WithIncludeSchemaTypePath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L137)
```go
func WithIncludeSchemaTypePath(includeSchemaTypePath bool) Option
@@ -726,7 +897,7 @@ func WithIncludeSchemaTypePath(includeSchemaTypePath bool) Option
WithIncludeSchemaTypePath returns a Option which hold a include schema type path switch.
-### func [WithKFilenames](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L92)
+### func [WithKFilenames](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L116)
```go
func WithKFilenames(filenames ...string) Option
@@ -734,7 +905,7 @@ func WithKFilenames(filenames ...string) Option
WithKFilenames returns a Option which hold a filenames list.
-### func [WithLogger](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L138)
+### func [WithLogger](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L162)
```go
func WithLogger(l io.Writer) Option
@@ -742,7 +913,7 @@ func WithLogger(l io.Writer) Option
WithLogger returns a Option which hold a logger.
-### func [WithOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L95)
+### func [WithOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L119)
```go
func WithOptions(key_value_list ...string) Option
@@ -788,7 +959,7 @@ name: kcl
-### func [WithOverrides](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L98)
+### func [WithOverrides](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L122)
```go
func WithOverrides(override_list ...string) Option
@@ -796,7 +967,7 @@ func WithOverrides(override_list ...string) Option
WithOverrides returns a Option which hold a override list.
-### func [WithPrintOverridesAST](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L123)
+### func [WithPrintOverridesAST](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L147)
```go
func WithPrintOverridesAST(printOverridesAST bool) Option
@@ -804,7 +975,7 @@ func WithPrintOverridesAST(printOverridesAST bool) Option
WithPrintOverridesAST returns a Option which hold a printOverridesAST switch.
-### func [WithSelectors](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L101)
+### func [WithSelectors](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L125)
```go
func WithSelectors(selectors ...string) Option
@@ -812,7 +983,7 @@ func WithSelectors(selectors ...string) Option
WithSelectors returns a Option which hold a path selector list.
-### func [WithSettings](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L104)
+### func [WithSettings](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L128)
```go
func WithSettings(filename string) Option
@@ -820,7 +991,7 @@ func WithSettings(filename string) Option
WithSettings returns a Option which hold a settings file.
-### func [WithShowHidden](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L133)
+### func [WithShowHidden](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L157)
```go
func WithShowHidden(showHidden bool) Option
@@ -828,7 +999,7 @@ func WithShowHidden(showHidden bool) Option
WithShowHidden returns a Option which holds a showHidden switch.
-### func [WithSortKeys](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L128)
+### func [WithSortKeys](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L152)
```go
func WithSortKeys(sortKeys bool) Option
@@ -836,7 +1007,7 @@ func WithSortKeys(sortKeys bool) Option
WithSortKeys returns a Option which holds a sortKeys switch.
-### func [WithWorkDir](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L107)
+### func [WithWorkDir](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L131)
```go
func WithWorkDir(workDir string) Option
@@ -844,25 +1015,72 @@ func WithWorkDir(workDir string) Option
WithWorkDir returns a Option which hold a work dir.
-## type [TestCaseInfo](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L52)
+## type [ParseProgramArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L70)
+
+```go
+type ParseProgramArgs = parser.ParseProgramArgs
+```
+
+## type [ParseProgramResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L71)
+
+```go
+type ParseProgramResult = parser.ParseProgramResult
+```
+
+### func [ParseProgram](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L263)
+
+```go
+func ParseProgram(args *ParseProgramArgs) (*ParseProgramResult, error)
+```
+
+Parse KCL program with entry files and return the AST JSON string.
+
+Example
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+)
+
+func main() {
+ result, err := kcl.ParseProgram(&kcl.ParseProgramArgs{
+ Paths: []string{"testdata/main.k"},
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(result)
+}
+```
+
+
+
+
+## type [TestCaseInfo](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L55)
```go
type TestCaseInfo = testing.TestCaseInfo
```
-## type [TestOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L51)
+## type [TestOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L54)
```go
type TestOptions = testing.TestOptions
```
-## type [TestResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L53)
+## type [TestResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L56)
```go
type TestResult = testing.TestResult
```
-### func [Test](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L203)
+### func [Test](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L224)
```go
func Test(testOpts *TestOptions, opts ...Option) (TestResult, error)
@@ -870,8 +1088,136 @@ func Test(testOpts *TestOptions, opts ...Option) (TestResult, error)
Test calls the test tool to run uni tests in packages.
-## type [ValidateOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L50)
+## type [UpdateDependenciesArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L62)
+
+```go
+type UpdateDependenciesArgs = module.UpdateDependenciesArgs
+```
+
+## type [UpdateDependenciesResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L63)
+
+```go
+type UpdateDependenciesResult = module.UpdateDependenciesResult
+```
+
+### func [UpdateDependencies](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L285)
+
+```go
+func UpdateDependencies(args *UpdateDependenciesArgs) (*UpdateDependenciesResult, error)
+```
+
+Download and update dependencies defined in the kcl.mod file and return the external package name and location list.
+
+Example
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+ "kcl-lang.io/kcl-go/pkg/spec/gpyrpc"
+)
+
+func main() {
+ // [package]
+ // name = "mod_update"
+ // edition = "0.0.1"
+ // version = "0.0.1"
+ //
+ // [dependencies]
+ // helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
+ // flask = { git = "https://github.com/kcl-lang/flask-demo-kcl-manifests", commit = "ade147b" }
+
+ result, err := kcl.UpdateDependencies(&gpyrpc.UpdateDependencies_Args{
+ ManifestPath: "testdata/update_dependencies",
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ fmt.Println(result)
+}
+```
+
+
+
+
+Example (Exec Program)
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+ "kcl-lang.io/kcl-go/pkg/spec/gpyrpc"
+)
+
+func main() {
+ // [package]
+ // name = "mod_update"
+ // edition = "0.0.1"
+ // version = "0.0.1"
+ //
+ // [dependencies]
+ // helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
+ // flask = { git = "https://github.com/kcl-lang/flask-demo-kcl-manifests", commit = "ade147b" }
+
+ result, err := kcl.UpdateDependencies(&gpyrpc.UpdateDependencies_Args{
+ ManifestPath: "testdata/update_dependencies",
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ // import helloworld
+ // import flask
+ // a = helloworld.The_first_kcl_program
+ // fmt.Println(result.ExternalPkgs)
+
+ opt := kcl.NewOption()
+ opt.ExternalPkgs = result.ExternalPkgs
+
+ runResult, err := kcl.Run("testdata/update_dependencies/main.k", *opt)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ fmt.Println(runResult.GetRawYamlResult())
+
+}
+```
+
+```
+a: Hello World!
+```
+
+
+
+
+## type [ValidateOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L53)
```go
type ValidateOptions = validate.ValidateOptions
```
+
+## type [VersionResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L61)
+
+```go
+type VersionResult = kcl.VersionResult
+```
+
+### func [GetVersion](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L290)
+
+```go
+func GetVersion() (*VersionResult, error)
+```
+
+GetVersion returns the KCL service version information.
diff --git a/docs/reference/xlang-api/java-api.md b/docs/reference/xlang-api/java-api.md
index fee90323..d72d32a9 100644
--- a/docs/reference/xlang-api/java-api.md
+++ b/docs/reference/xlang-api/java-api.md
@@ -84,42 +84,6 @@ ExecProgram_Result result = apiInstance.execProgram(args);
-### parseProgram
-
-Parse KCL program with entry files and return the AST JSON string.
-
-Example
-
-
-The content of `schema.k` is
-
-```python
-schema AppConfig:
- replicas: int
-
-app: AppConfig {
- replicas: 2
-}
-```
-
-Java Code
-
-```java
-import com.kcl.api.*;
-import com.kcl.ast.*;
-import com.kcl.util.JsonUtil;
-
-API api = new API();
-ParseProgram_Result result = api.parseProgram(
- ParseProgram_Args.newBuilder().addPaths("schema.k").build()
-);
-System.out.println(result.getAstJson());
-Program program = JsonUtil.deserializeProgram(result.getAstJson());
-```
-
-
-
-
### parseFile
Parse KCL single file to Module AST JSON string with import dependencies and parse errors.
diff --git a/docs/reference/xlang-api/nodejs-api.md b/docs/reference/xlang-api/nodejs-api.md
index 400f39f4..9c507d00 100644
--- a/docs/reference/xlang-api/nodejs-api.md
+++ b/docs/reference/xlang-api/nodejs-api.md
@@ -72,35 +72,6 @@ try {
-### parseProgram
-
-Parse KCL program with entry files and return the AST JSON string.
-
-Example
-
-
-The content of `schema.k` is
-
-```python
-schema AppConfig:
- replicas: int
-
-app: AppConfig {
- replicas: 2
-}
-```
-
-Node.js Code
-
-```ts
-import { parseProgram, ParseProgramArgs } from "kcl-lib";
-
-const result = parseProgram(new ParseProgramArgs(["schema.k"]));
-```
-
-
-
-
### parseFile
Parse KCL single file to Module AST JSON string with import dependencies and parse errors.
@@ -296,7 +267,7 @@ Node.js Code
import { overrideFile, OverrideFileArgs } from "kcl-lib";
const result = overrideFile(
- new OverrideFileArgs("main.k", ["app.replicas=4"], [])
+ new OverrideFileArgs("main.k", ["app.replicas=4"], []),
);
```
@@ -407,7 +378,7 @@ schema Person:
`;
const data = '{"name": "Alice", "age": 10}';
const result = validateCode(
- new ValidateCodeArgs(undefined, data, undefined, code)
+ new ValidateCodeArgs(undefined, data, undefined, code),
);
```
@@ -456,7 +427,7 @@ const args = RenameCodeArgs(
"/mock/path",
"a",
{ "/mock/path/main.k": "a = 1\nb = a" },
- "a2"
+ "a2",
);
const result = renameCode(args);
```
@@ -591,8 +562,8 @@ const execResult = execProgram(
undefined,
undefined,
undefined,
- result.externalPkgs
- )
+ result.externalPkgs,
+ ),
);
```
diff --git a/docs/reference/xlang-api/python-api.md b/docs/reference/xlang-api/python-api.md
index 49e3bfdf..589f73c3 100644
--- a/docs/reference/xlang-api/python-api.md
+++ b/docs/reference/xlang-api/python-api.md
@@ -75,26 +75,6 @@ except Exception as err:
-### parse_program
-
-Parse KCL program with entry files and return the AST JSON string.
-
-Example
-
-
-```python
-import kcl_lib.api as api
-
-args = api.ParseProgram_Args(paths=["schema.k"])
-api = api.API()
-result = api.parse_program(args)
-assert len(result.paths) == 1
-assert len(result.errors) == 0
-```
-
-
-
-
### parse_file
Parse KCL single file to Module AST JSON string with import dependencies and parse errors.
@@ -118,10 +98,9 @@ Python Code
```python
import kcl_lib.api as api
-args = api.ParseProgram_Args(paths=[TEST_FILE])
+args = api.ParseFile_Args(path=TEST_FILE)
api = api.API()
-result = api.parse_program(args)
-assert len(result.paths) == 1
+result = api.parse_file(args)
assert len(result.errors) == 0
```
diff --git a/docs/reference/xlang-api/rest-api.md b/docs/reference/xlang-api/rest-api.md
index 7d0cf97e..b9a9ab73 100644
--- a/docs/reference/xlang-api/rest-api.md
+++ b/docs/reference/xlang-api/rest-api.md
@@ -113,7 +113,7 @@ $ curl -X POST \
Cross-language APIs defined via Protobuf([https://github.com/kcl-lang/kcl/blob/main/kclvm/spec/gpyrpc/gpyrpc.proto](https://github.com/kcl-lang/kcl/blob/main/kclvm/spec/gpyrpc/gpyrpc.proto)):
-```protobuf
+````protobuf
// Copyright The KCL Authors. All rights reserved.
//
// This file defines the request parameters and return structure of the KCL RPC server.
@@ -734,7 +734,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -776,7 +776,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -805,7 +805,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -838,7 +838,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -867,7 +867,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -1424,7 +1424,7 @@ message KeyValuePair {
// ---------------------------------------------------------------------------------
// Rename API
-// Find all the occurrences of the target symbol and rename them.
+// Find all the occurrences of the target symbol and rename them.
// This API will rewrite files if they contain symbols to be renamed.
// ---------------------------------------------------------------------------------
@@ -1587,4 +1587,4 @@ message Example {
// ----------------------------------------------------------------------------
// END
// ----------------------------------------------------------------------------
-```
+````
diff --git a/docs/reference/xlang-api/wasm-api.md b/docs/reference/xlang-api/wasm-api.md
index 1fd3e308..bb5301a7 100644
--- a/docs/reference/xlang-api/wasm-api.md
+++ b/docs/reference/xlang-api/wasm-api.md
@@ -86,7 +86,7 @@ a: 1
In Go, we use `wasmtime` as an example, and of course, you can also use other runtime that supports WASI to accomplish this.
-Write the code, and the code of package `github.com/kcl-lang/wasm-lib/pkg/module` can be found [here](https://github.com/kcl-lang/lib/blob/main/wasm/examples/go/pkg/module/module.go)
+Write the code, and the code of package `github.com/kcl-lang/wasm-lib/pkg/module` can be found [here](https://github.com/kcl-lang/lib/blob/main/wasm/examples/go/pkg/module/module.go)
```go
package main
diff --git a/docs/tools/cli/kcl/test.md b/docs/tools/cli/kcl/test.md
index 55330c3a..e5e9bdbf 100644
--- a/docs/tools/cli/kcl/test.md
+++ b/docs/tools/cli/kcl/test.md
@@ -128,7 +128,7 @@ import runtime
test_person_age_check_error_message = lambda {
msg = runtime.catch(lambda {
a = Person {age = 123}
- })
+ })
assert msg == "age must be in [0, 120]"
}
```
diff --git a/docs/user_docs/guides/package-management/4-how-to/10-private_mod_repo.md b/docs/user_docs/guides/package-management/4-how-to/10-private_mod_repo.md
index 5a789b98..b1d004e5 100644
--- a/docs/user_docs/guides/package-management/4-how-to/10-private_mod_repo.md
+++ b/docs/user_docs/guides/package-management/4-how-to/10-private_mod_repo.md
@@ -18,48 +18,47 @@ The KCL package management tool supports saving and sharing KCL packages through
1. Login to the private OCI Registry using the `kcl registry login` command.
- More Details - [kcl registry login Login OCI Registry](https://www.kcl-lang.io/docs/tools/cli/package-management/command-reference/login)
+ More Details - [kcl registry login Login OCI Registry](https://www.kcl-lang.io/docs/tools/cli/package-management/command-reference/login)
2. Replace the OCI Registry used by the KCL package management tool. The KCL package management tool supports specifying the OCI registry used to download KCL packages in three ways.
- - Use the OCI Url to specify the OCI registry in the command line or `kcl.mod`.
+ - Use the OCI Url to specify the OCI registry in the command line or `kcl.mod`.
- You can specify the OCI Registry as `ghcr.io` by the following command.
+ You can specify the OCI Registry as `ghcr.io` by the following command.
- ```shell
- kcl mod add oci://ghcr.io/kcl-lang/helloworld --tag 0.1.0
- ```
+ ```shell
+ kcl mod add oci://ghcr.io/kcl-lang/helloworld --tag 0.1.0
+ ```
- Or add the following content to the `kcl.mod` file to specify the OCI Registry as `ghcr.io`.
+ Or add the following content to the `kcl.mod` file to specify the OCI Registry as `ghcr.io`.
- ```toml
- helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
- ```
+ ```toml
+ helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
+ ```
- - By environment variable
+ - By environment variable
- You can adjust the configuration of the OCI Registry by setting the three environment variables `KPM_REG`, `KPM_REGO`, and `OCI_REG_PLAIN_HTTP`.
+ You can adjust the configuration of the OCI Registry by setting the three environment variables `KPM_REG`, `KPM_REGO`, and `OCI_REG_PLAIN_HTTP`.
- ```shell
- # set default registry
- export KPM_REG="ghcr.io"
- # set default repository
- export KPM_REPO="kcl-lang"
- # set support for 'http'
- export OCI_REG_PLAIN_HTTP=off
- ```
+ ```shell
+ # set default registry
+ export KPM_REG="ghcr.io"
+ # set default repository
+ export KPM_REPO="kcl-lang"
+ # set support for 'http'
+ export OCI_REG_PLAIN_HTTP=off
+ ```
- - By configuration file
+ - By configuration file
- The configuration file of the KCL package management tool is located at `$KCL_PKG_PATH/.kpm/config/kpm.json`, if the environment variable `KCL_PKG_PATH` is not set, it is saved by default in `$HOME/.kcl/kpm/.kpm/config/kpm.json`.
+ The configuration file of the KCL package management tool is located at `$KCL_PKG_PATH/.kpm/config/kpm.json`, if the environment variable `KCL_PKG_PATH` is not set, it is saved by default in `$HOME/.kcl/kpm/.kpm/config/kpm.json`.
- The default content of the configuration file is as follows:
-
- ```json
- {
- "DefaultOciRegistry": "ghcr.io",
- "DefaultOciRepo": "kcl-lang",
- "DefaultOciPlainHttp": true
- }
- ```
+ The default content of the configuration file is as follows:
+ ```json
+ {
+ "DefaultOciRegistry": "ghcr.io",
+ "DefaultOciRepo": "kcl-lang",
+ "DefaultOciPlainHttp": true
+ }
+ ```
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/c-api.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/c-api.md
index 5bfe4678..0081421e 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/c-api.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/c-api.md
@@ -8,9 +8,9 @@ KCL [C API](https://github.com/kcl-lang/lib/tree/main/c) 正在开发中,欢
## 前置依赖
-+ Make
-+ C Compiler
-+ Cargo
+- Make
+- C Compiler
+- Cargo
## API 参考
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/cpp-api.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/cpp-api.md
index 8ab052f0..57f1cda1 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/cpp-api.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/cpp-api.md
@@ -8,9 +8,9 @@ KCL [C++ API](https://github.com/kcl-lang/lib/tree/main/cpp) 正在开发中,
## 前置依赖
-+ CMake >= 3.10
-+ C++ Compiler with C++17 Support
-+ Cargo
+- CMake >= 3.10
+- C++ Compiler with C++17 Support
+- Cargo
## 安装
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/dotnet-api.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/dotnet-api.md
index 6dea5eed..7e6fb092 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/dotnet-api.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/dotnet-api.md
@@ -57,38 +57,6 @@ var result = new API().ExecProgram(execArgs);
-### ParseProgram
-
-Parse KCL program with entry files and return the AST JSON string.
-
-Example
-
-
-The content of `schema.k` is
-
-```python
-schema AppConfig:
- replicas: int
-
-app: AppConfig {
- replicas: 2
-}
-```
-
-C# Code
-
-```csharp
-using KclLib.API;
-
-var path = "schema.k"
-var args = new ParseProgram_Args();
-args.Paths.Add(path);
-var result = new API().ParseProgram(args);
-```
-
-
-
-
### ParseFile
Parse KCL single file to Module AST JSON string with import dependencies and parse errors.
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/go-api.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/go-api.md
index 39f2777a..d495d555 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/go-api.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/go-api.md
@@ -93,49 +93,69 @@ x1 = Person {
## Index
- [Go API](#go-api)
- - [Index](#index)
- - [Constants](#constants)
- - [func FormatCode](#func-formatcode)
- - [func FormatPath](#func-formatpath)
- - [func GetSchemaTypeMapping](#func-getschematypemapping)
- - [func InitKclvmPath](#func-initkclvmpath)
- - [func InitKclvmRuntime](#func-initkclvmruntime)
- - [func LintPath](#func-lintpath)
- - [func ListDepFiles](#func-listdepfiles)
- - [func ListDownStreamFiles](#func-listdownstreamfiles)
- - [func ListUpStreamFiles](#func-listupstreamfiles)
- - [func OverrideFile](#func-overridefile)
- - [func Validate](#func-validate)
- - [func ValidateCode](#func-validatecode)
- - [type KCLResult](#type-kclresult)
- - [type KCLResultList](#type-kclresultlist)
- - [func MustRun](#func-mustrun)
- - [func Run](#func-run)
- - [func RunFiles](#func-runfiles)
- - [type KclType](#type-kcltype)
- - [type ListDepFilesOption](#type-listdepfilesoption)
- - [type ListDepsOptions](#type-listdepsoptions)
- - [type Option](#type-option)
- - [func WithCode](#func-withcode)
- - [func WithDisableNone](#func-withdisablenone)
- - [func WithExternalPkgs](#func-withexternalpkgs)
- - [func WithFullTypePath](#func-withfulltypepath)
- - [func WithIncludeSchemaTypePath](#func-withincludeschematypepath)
- - [func WithKFilenames](#func-withkfilenames)
- - [func WithLogger](#func-withlogger)
- - [func WithOptions](#func-withoptions)
- - [func WithOverrides](#func-withoverrides)
- - [func WithPrintOverridesAST](#func-withprintoverridesast)
- - [func WithSelectors](#func-withselectors)
- - [func WithSettings](#func-withsettings)
- - [func WithShowHidden](#func-withshowhidden)
- - [func WithSortKeys](#func-withsortkeys)
- - [func WithWorkDir](#func-withworkdir)
- - [type TestCaseInfo](#type-testcaseinfo)
- - [type TestOptions](#type-testoptions)
- - [type TestResult](#type-testresult)
- - [func Test](#func-test)
- - [type ValidateOptions](#type-validateoptions)
+ - [Index](#index)
+ - [Constants](#constants)
+ - [func FormatCode](#func-formatcode)
+ - [func FormatPath](#func-formatpath)
+ - [func GetSchemaTypeMapping](#func-getschematypemapping)
+ - [func InitKclvmPath](#func-initkclvmpath)
+ - [func InitKclvmRuntime](#func-initkclvmruntime)
+ - [func LintPath](#func-lintpath)
+ - [func ListDepFiles](#func-listdepfiles)
+ - [func ListDownStreamFiles](#func-listdownstreamfiles)
+ - [func ListUpStreamFiles](#func-listupstreamfiles)
+ - [func OverrideFile](#func-overridefile)
+ - [func Validate](#func-validate)
+ - [func ValidateCode](#func-validatecode)
+ - [type KCLResult](#type-kclresult)
+ - [type KCLResultList](#type-kclresultlist)
+ - [func MustRun](#func-mustrun)
+ - [func Run](#func-run)
+ - [func RunFiles](#func-runfiles)
+ - [type KclType](#type-kcltype)
+ - [func GetSchemaType](#func-getschematype)
+ - [type ListDepFilesOption](#type-listdepfilesoption)
+ - [type ListDepsOptions](#type-listdepsoptions)
+ - [type ListOptionsArgs](#type-listoptionsargs)
+ - [type ListOptionsResult](#type-listoptionsresult)
+ - [func ListOptions](#func-listoptions)
+ - [type ListVariablesArgs](#type-listvariablesargs)
+ - [type ListVariablesResult](#type-listvariablesresult)
+ - [func ListVariables](#func-listvariables)
+ - [type LoadPackageArgs](#type-loadpackageargs)
+ - [type LoadPackageResult](#type-loadpackageresult)
+ - [func LoadPackage](#func-loadpackage)
+ - [type Option](#type-option)
+ - [func NewOption](#func-newoption)
+ - [func WithCode](#func-withcode)
+ - [func WithDisableNone](#func-withdisablenone)
+ - [func WithExternalPkgAndPath](#func-withexternalpkgandpath)
+ - [func WithExternalPkgs](#func-withexternalpkgs)
+ - [func WithFullTypePath](#func-withfulltypepath)
+ - [func WithIncludeSchemaTypePath](#func-withincludeschematypepath)
+ - [func WithKFilenames](#func-withkfilenames)
+ - [func WithLogger](#func-withlogger)
+ - [func WithOptions](#func-withoptions)
+ - [func WithOverrides](#func-withoverrides)
+ - [func WithPrintOverridesAST](#func-withprintoverridesast)
+ - [func WithSelectors](#func-withselectors)
+ - [func WithSettings](#func-withsettings)
+ - [func WithShowHidden](#func-withshowhidden)
+ - [func WithSortKeys](#func-withsortkeys)
+ - [func WithWorkDir](#func-withworkdir)
+ - [type ParseProgramArgs](#type-parseprogramargs)
+ - [type ParseProgramResult](#type-parseprogramresult)
+ - [func ParseProgram](#func-parseprogram)
+ - [type TestCaseInfo](#type-testcaseinfo)
+ - [type TestOptions](#type-testoptions)
+ - [type TestResult](#type-testresult)
+ - [func Test](#func-test)
+ - [type UpdateDependenciesArgs](#type-updatedependenciesargs)
+ - [type UpdateDependenciesResult](#type-updatedependenciesresult)
+ - [func UpdateDependencies](#func-updatedependencies)
+ - [type ValidateOptions](#type-validateoptions)
+ - [type VersionResult](#type-versionresult)
+ - [func GetVersion](#func-getversion)
## Constants
@@ -145,7 +165,7 @@ KclvmAbiVersion is the current kclvm ABI version.
const KclvmAbiVersion = scripts.KclvmAbiVersion
```
-## func [FormatCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L143)
+## func [FormatCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L167)
```go
func FormatCode(code interface{}) ([]byte, error)
@@ -183,7 +203,7 @@ a = 1 + 2
-## func [FormatPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L155)
+## func [FormatPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L179)
```go
func FormatPath(path string) (changedPaths []string, err error)
@@ -218,7 +238,7 @@ func main() {
-## func [GetSchemaTypeMapping](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L237)
+## func [GetSchemaTypeMapping](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L258)
```go
func GetSchemaTypeMapping(filename string, src any, schemaName string) (map[string]*KclType, error)
@@ -244,7 +264,7 @@ schema_name: string
The schema name got, when the schema name is empty, all schemas are returned.
```
-## func [InitKclvmPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L61)
+## func [InitKclvmPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L75)
```go
func InitKclvmPath(kclvmRoot string)
@@ -252,7 +272,7 @@ func InitKclvmPath(kclvmRoot string)
InitKclvmPath init kclvm path.
-## func [InitKclvmRuntime](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L66)
+## func [InitKclvmRuntime](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L80)
```go
func InitKclvmRuntime(n int)
@@ -260,7 +280,7 @@ func InitKclvmRuntime(n int)
InitKclvmRuntime init kclvm process.
-## func [LintPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L175)
+## func [LintPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L199)
```go
func LintPath(paths []string) (results []string, err error)
@@ -305,7 +325,7 @@ Module 'a' imported but unused
-## func [ListDepFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L160)
+## func [ListDepFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L184)
```go
func ListDepFiles(workDir string, opt *ListDepFilesOption) (files []string, err error)
@@ -313,7 +333,7 @@ func ListDepFiles(workDir string, opt *ListDepFilesOption) (files []string, err
ListDepFiles return the depend files from the given path
-## func [ListDownStreamFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L170)
+## func [ListDownStreamFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L194)
```go
func ListDownStreamFiles(workDir string, opt *ListDepsOptions) ([]string, error)
@@ -321,7 +341,7 @@ func ListDownStreamFiles(workDir string, opt *ListDepsOptions) ([]string, error)
ListDownStreamFiles return a list of downstream depend files from the given changed path list.
-## func [ListUpStreamFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L165)
+## func [ListUpStreamFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L189)
```go
func ListUpStreamFiles(workDir string, opt *ListDepsOptions) (deps []string, err error)
@@ -329,22 +349,15 @@ func ListUpStreamFiles(workDir string, opt *ListDepsOptions) (deps []string, err
ListUpStreamFiles return a list of upstream depend files from the given path list
-## func [OverrideFile](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L187)
+## func [OverrideFile](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L208)
```go
func OverrideFile(file string, specs, importPaths []string) (bool, error)
```
-OverrideFile rewrites a file with override spec file: string. The File that need to be overridden specs: \[\]string. List of specs that need to be overridden.
+OverrideFile rewrites a file with override spec file: string. The File that need to be overridden specs: \[\]string. List of specs that need to be overridden. importPaths. List of import statements that need to be added. See https://www.kcl-lang.io/docs/user_docs/guides/automation for more override spec guide.
-```
-Each spec string satisfies the form: := or :-
-When the pkgpath is '__main__', it can be omitted.
-```
-
-importPaths. List of import statements that need to be added
-
-## func [Validate](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L198)
+## func [Validate](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L219)
```go
func Validate(dataFile, schemaFile string, opts *ValidateOptions) (ok bool, err error)
@@ -352,7 +365,7 @@ func Validate(dataFile, schemaFile string, opts *ValidateOptions) (ok bool, err
Validate validates the given data file against the specified schema file with the provided options.
-## func [ValidateCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L192)
+## func [ValidateCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L213)
```go
func ValidateCode(data, code string, opts *ValidateOptions) (ok bool, err error)
@@ -360,7 +373,7 @@ func ValidateCode(data, code string, opts *ValidateOptions) (ok bool, err error)
ValidateCode validate data string match code string
-## type [KCLResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L54)
+## type [KCLResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L57)
```go
type KCLResult = kcl.KCLResult
@@ -409,7 +422,7 @@ x1.age: 101
-Example ('et_struct)
+Example (Get)
```go
@@ -454,13 +467,13 @@ person: {Name:kcl Age:101}
-## type [KCLResultList](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L55)
+## type [KCLResultList](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L58)
```go
type KCLResultList = kcl.KCLResultList
```
-### func [MustRun](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L71)
+### func [MustRun](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L85)
```go
func MustRun(path string, opts ...Option) *KCLResultList
@@ -587,7 +600,7 @@ func main() {
-### func [Run](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L76)
+### func [Run](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L90)
```go
func Run(path string, opts ...Option) (*KCLResultList, error)
@@ -595,7 +608,15 @@ func Run(path string, opts ...Option) (*KCLResultList, error)
Run evaluates the KCL program with path and opts, then returns the object list.
-Example (Get Field)
+### func [RunFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L95)
+
+```go
+func RunFiles(paths []string, opts ...Option) (*KCLResultList, error)
+```
+
+RunFiles evaluates the KCL program with multi file path and opts, then returns the object list.
+
+Example
```go
@@ -603,43 +624,134 @@ package main
import (
"fmt"
- "log"
kcl "kcl-lang.io/kcl-go"
)
-func assert(v bool, a ...interface{}) {
- if !v {
- a = append([]interface{}{"assert failed"}, a...)
- log.Panic(a...)
- }
+func main() {
+ result, _ := kcl.RunFiles([]string{"./testdata/app0/kcl.yaml"})
+ fmt.Println(result.First().YAMLString())
}
+```
-func main() {
- // run kcl.yaml
- x, err := kcl.Run("./testdata/app0/kcl.yaml")
- assert(err == nil, err)
+
+
+
+## type [KclType](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L60)
+
+```go
+type KclType = kcl.KclType
+```
+
+### func [GetSchemaType](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L241)
+
+```go
+func GetSchemaType(filename string, src any, schemaName string) ([]*KclType, error)
+```
+
+GetSchemaType returns schema types from a kcl file or code.
+
+file: string
- // print deploy_topology[1].zone
- fmt.Println(x.First().Get("deploy_topology.1.zone"))
+```
+The kcl filename
+```
+
+code: string
+
+```
+The kcl code string
+```
+
+schema_name: string
+
+```
+The schema name got, when the schema name is empty, all schemas are returned.
+```
+
+## type [ListDepFilesOption](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L52)
+
+```go
+type ListDepFilesOption = list.Option
+```
+
+## type [ListDepsOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L51)
+
+```go
+type ListDepsOptions = list.DepOptions
+```
+
+## type [ListOptionsArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L68)
+
+```go
+type ListOptionsArgs = loader.ListOptionsArgs
+```
+
+## type [ListOptionsResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L69)
+
+```go
+type ListOptionsResult = loader.ListOptionsResult
+```
+
+### func [ListOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L280)
+
+```go
+func ListOptions(args *ListOptionsArgs) (*ListOptionsResult, error)
+```
+
+ListOptions provides users with the ability to parse kcl program and get all option calling information.
+
+Example
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+)
+
+func main() {
+ result, err := kcl.ListOptions(&kcl.ListOptionsArgs{
+ Paths: []string{"testdata/option/main.k"},
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(result)
}
```
```
-R000A
+options:{name:"key1"} options:{name:"key2" required:true} options:{name:"metadata-key"}
```
-### func [RunFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L81)
+## type [ListVariablesArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L66)
```go
-func RunFiles(paths []string, opts ...Option) (*KCLResultList, error)
+type ListVariablesArgs = loader.ListVariablesArgs
```
-RunFiles evaluates the KCL program with multi file path and opts, then returns the object list.
+## type [ListVariablesResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L67)
+
+```go
+type ListVariablesResult = loader.ListVariablesResult
+```
+
+### func [ListVariables](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L274)
+
+```go
+func ListVariables(args *ListVariablesArgs) (*ListVariablesResult, error)
+```
+
+ListVariables provides users with the ability to parse KCL program and get all variables by specs.
Example
@@ -649,44 +761,95 @@ package main
import (
"fmt"
+ "log"
kcl "kcl-lang.io/kcl-go"
)
func main() {
- result, _ := kcl.RunFiles([]string{"./testdata/app0/kcl.yaml"})
- fmt.Println(result.First().YAMLString())
+ result, err := kcl.ListVariables(&kcl.ListVariablesArgs{
+ Files: []string{"testdata/main.k"},
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(result)
+
}
```
+```
+variables:{key:"age" value:{variables:{value:"2" op_sym:"="}}} variables:{key:"four" value:{variables:{value:"4" op_sym:"="}}} variables:{key:"name" value:{variables:{value:"\"kcl-go\"" op_sym:"="}}} variables:{key:"x0" value:{variables:{value:"Person {}" type_name:"Person" op_sym:"="}}} variables:{key:"x1" value:{variables:{value:"Person {age = 101}" type_name:"Person" op_sym:"=" dict_entries:{key:"age" value:{value:"101" op_sym:"="}}}}}
+```
+
-## type [KclType](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L57)
+## type [LoadPackageArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L64)
```go
-type KclType = kcl.KclType
+type LoadPackageArgs = loader.LoadPackageArgs
```
-## type [ListDepFilesOption](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L49)
+## type [LoadPackageResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L65)
```go
-type ListDepFilesOption = list.Option
+type LoadPackageResult = loader.LoadPackageResult
```
-## type [ListDepsOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L48)
+### func [LoadPackage](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L269)
```go
-type ListDepsOptions = list.DepOptions
+func LoadPackage(args *LoadPackageArgs) (*LoadPackageResult, error)
```
-## type [Option](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L47)
+LoadPackage provides users with the ability to parse KCL program and semantic model information including symbols, types, definitions, etc.
+
+Example
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+)
+
+func main() {
+ result, err := kcl.LoadPackage(&kcl.LoadPackageArgs{
+ ParseArgs: &kcl.ParseProgramArgs{
+ Paths: []string{"testdata/main.k"},
+ },
+ ResolveAst: true,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(result)
+}
+```
+
+
+
+
+## type [Option](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L50)
```go
type Option = kcl.Option
```
-### func [WithCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L86)
+### func [NewOption](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L100)
+
+```go
+func NewOption() *Option
+```
+
+NewOption returns a new Option.
+
+### func [WithCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L105)
```go
func WithCode(codes ...string) Option
@@ -694,7 +857,7 @@ func WithCode(codes ...string) Option
WithCode returns a Option which hold a kcl source code list.
-### func [WithDisableNone](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L110)
+### func [WithDisableNone](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L134)
```go
func WithDisableNone(disableNone bool) Option
@@ -702,7 +865,15 @@ func WithDisableNone(disableNone bool) Option
WithDisableNone returns a Option which hold a disable none switch.
-### func [WithExternalPkgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L89)
+### func [WithExternalPkgAndPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L111)
+
+```go
+func WithExternalPkgAndPath(name, path string) Option
+```
+
+WithExternalPkgAndPath returns a Option which hold a external package.
+
+### func [WithExternalPkgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L108)
```go
func WithExternalPkgs(externalPkgs ...string) Option
@@ -710,7 +881,7 @@ func WithExternalPkgs(externalPkgs ...string) Option
WithExternalPkgs returns a Option which hold a external package list.
-### func [WithFullTypePath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L118)
+### func [WithFullTypePath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L142)
```go
func WithFullTypePath(fullTypePath bool) Option
@@ -718,7 +889,7 @@ func WithFullTypePath(fullTypePath bool) Option
WithFullTypePath returns a Option which hold a include full type string in the \`\_type\` attribute.
-### func [WithIncludeSchemaTypePath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L113)
+### func [WithIncludeSchemaTypePath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L137)
```go
func WithIncludeSchemaTypePath(includeSchemaTypePath bool) Option
@@ -726,7 +897,7 @@ func WithIncludeSchemaTypePath(includeSchemaTypePath bool) Option
WithIncludeSchemaTypePath returns a Option which hold a include schema type path switch.
-### func [WithKFilenames](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L92)
+### func [WithKFilenames](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L116)
```go
func WithKFilenames(filenames ...string) Option
@@ -734,7 +905,7 @@ func WithKFilenames(filenames ...string) Option
WithKFilenames returns a Option which hold a filenames list.
-### func [WithLogger](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L138)
+### func [WithLogger](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L162)
```go
func WithLogger(l io.Writer) Option
@@ -742,7 +913,7 @@ func WithLogger(l io.Writer) Option
WithLogger returns a Option which hold a logger.
-### func [WithOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L95)
+### func [WithOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L119)
```go
func WithOptions(key_value_list ...string) Option
@@ -788,7 +959,7 @@ name: kcl
-### func [WithOverrides](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L98)
+### func [WithOverrides](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L122)
```go
func WithOverrides(override_list ...string) Option
@@ -796,7 +967,7 @@ func WithOverrides(override_list ...string) Option
WithOverrides returns a Option which hold a override list.
-### func [WithPrintOverridesAST](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L123)
+### func [WithPrintOverridesAST](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L147)
```go
func WithPrintOverridesAST(printOverridesAST bool) Option
@@ -804,7 +975,7 @@ func WithPrintOverridesAST(printOverridesAST bool) Option
WithPrintOverridesAST returns a Option which hold a printOverridesAST switch.
-### func [WithSelectors](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L101)
+### func [WithSelectors](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L125)
```go
func WithSelectors(selectors ...string) Option
@@ -812,7 +983,7 @@ func WithSelectors(selectors ...string) Option
WithSelectors returns a Option which hold a path selector list.
-### func [WithSettings](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L104)
+### func [WithSettings](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L128)
```go
func WithSettings(filename string) Option
@@ -820,7 +991,7 @@ func WithSettings(filename string) Option
WithSettings returns a Option which hold a settings file.
-### func [WithShowHidden](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L133)
+### func [WithShowHidden](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L157)
```go
func WithShowHidden(showHidden bool) Option
@@ -828,7 +999,7 @@ func WithShowHidden(showHidden bool) Option
WithShowHidden returns a Option which holds a showHidden switch.
-### func [WithSortKeys](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L128)
+### func [WithSortKeys](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L152)
```go
func WithSortKeys(sortKeys bool) Option
@@ -836,7 +1007,7 @@ func WithSortKeys(sortKeys bool) Option
WithSortKeys returns a Option which holds a sortKeys switch.
-### func [WithWorkDir](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L107)
+### func [WithWorkDir](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L131)
```go
func WithWorkDir(workDir string) Option
@@ -844,25 +1015,72 @@ func WithWorkDir(workDir string) Option
WithWorkDir returns a Option which hold a work dir.
-## type [TestCaseInfo](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L52)
+## type [ParseProgramArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L70)
+
+```go
+type ParseProgramArgs = parser.ParseProgramArgs
+```
+
+## type [ParseProgramResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L71)
+
+```go
+type ParseProgramResult = parser.ParseProgramResult
+```
+
+### func [ParseProgram](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L263)
+
+```go
+func ParseProgram(args *ParseProgramArgs) (*ParseProgramResult, error)
+```
+
+Parse KCL program with entry files and return the AST JSON string.
+
+Example
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+)
+
+func main() {
+ result, err := kcl.ParseProgram(&kcl.ParseProgramArgs{
+ Paths: []string{"testdata/main.k"},
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(result)
+}
+```
+
+
+
+
+## type [TestCaseInfo](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L55)
```go
type TestCaseInfo = testing.TestCaseInfo
```
-## type [TestOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L51)
+## type [TestOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L54)
```go
type TestOptions = testing.TestOptions
```
-## type [TestResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L53)
+## type [TestResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L56)
```go
type TestResult = testing.TestResult
```
-### func [Test](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L203)
+### func [Test](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L224)
```go
func Test(testOpts *TestOptions, opts ...Option) (TestResult, error)
@@ -870,8 +1088,136 @@ func Test(testOpts *TestOptions, opts ...Option) (TestResult, error)
Test calls the test tool to run uni tests in packages.
-## type [ValidateOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L50)
+## type [UpdateDependenciesArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L62)
+
+```go
+type UpdateDependenciesArgs = module.UpdateDependenciesArgs
+```
+
+## type [UpdateDependenciesResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L63)
+
+```go
+type UpdateDependenciesResult = module.UpdateDependenciesResult
+```
+
+### func [UpdateDependencies](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L285)
+
+```go
+func UpdateDependencies(args *UpdateDependenciesArgs) (*UpdateDependenciesResult, error)
+```
+
+Download and update dependencies defined in the kcl.mod file and return the external package name and location list.
+
+Example
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+ "kcl-lang.io/kcl-go/pkg/spec/gpyrpc"
+)
+
+func main() {
+ // [package]
+ // name = "mod_update"
+ // edition = "0.0.1"
+ // version = "0.0.1"
+ //
+ // [dependencies]
+ // helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
+ // flask = { git = "https://github.com/kcl-lang/flask-demo-kcl-manifests", commit = "ade147b" }
+
+ result, err := kcl.UpdateDependencies(&gpyrpc.UpdateDependencies_Args{
+ ManifestPath: "testdata/update_dependencies",
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ fmt.Println(result)
+}
+```
+
+
+
+
+Example (Exec Program)
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+ "kcl-lang.io/kcl-go/pkg/spec/gpyrpc"
+)
+
+func main() {
+ // [package]
+ // name = "mod_update"
+ // edition = "0.0.1"
+ // version = "0.0.1"
+ //
+ // [dependencies]
+ // helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
+ // flask = { git = "https://github.com/kcl-lang/flask-demo-kcl-manifests", commit = "ade147b" }
+
+ result, err := kcl.UpdateDependencies(&gpyrpc.UpdateDependencies_Args{
+ ManifestPath: "testdata/update_dependencies",
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ // import helloworld
+ // import flask
+ // a = helloworld.The_first_kcl_program
+ // fmt.Println(result.ExternalPkgs)
+
+ opt := kcl.NewOption()
+ opt.ExternalPkgs = result.ExternalPkgs
+
+ runResult, err := kcl.Run("testdata/update_dependencies/main.k", *opt)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ fmt.Println(runResult.GetRawYamlResult())
+
+}
+```
+
+```
+a: Hello World!
+```
+
+
+
+
+## type [ValidateOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L53)
```go
type ValidateOptions = validate.ValidateOptions
```
+
+## type [VersionResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L61)
+
+```go
+type VersionResult = kcl.VersionResult
+```
+
+### func [GetVersion](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L290)
+
+```go
+func GetVersion() (*VersionResult, error)
+```
+
+GetVersion returns the KCL service version information.
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/java-api.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/java-api.md
index c8df505e..6ffb16c6 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/java-api.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/java-api.md
@@ -83,42 +83,6 @@ ExecProgram_Result result = apiInstance.execProgram(args);
-### parseProgram
-
-Parse KCL program with entry files and return the AST JSON string.
-
-Example
-
-
-The content of `schema.k` is
-
-```python
-schema AppConfig:
- replicas: int
-
-app: AppConfig {
- replicas: 2
-}
-```
-
-Java Code
-
-```java
-import com.kcl.api.*;
-import com.kcl.ast.*;
-import com.kcl.util.JsonUtil;
-
-API api = new API();
-ParseProgram_Result result = api.parseProgram(
- ParseProgram_Args.newBuilder().addPaths("schema.k").build()
-);
-System.out.println(result.getAstJson());
-Program program = JsonUtil.deserializeProgram(result.getAstJson());
-```
-
-
-
-
### parseFile
Parse KCL single file to Module AST JSON string with import dependencies and parse errors.
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/nodejs-api.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/nodejs-api.md
index c87a19ca..f8f0c583 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/nodejs-api.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/nodejs-api.md
@@ -72,35 +72,6 @@ try {
-### parseProgram
-
-Parse KCL program with entry files and return the AST JSON string.
-
-Example
-
-
-The content of `schema.k` is
-
-```python
-schema AppConfig:
- replicas: int
-
-app: AppConfig {
- replicas: 2
-}
-```
-
-Node.js Code
-
-```ts
-import { parseProgram, ParseProgramArgs } from "kcl-lib";
-
-const result = parseProgram(new ParseProgramArgs(["schema.k"]));
-```
-
-
-
-
### parseFile
Parse KCL single file to Module AST JSON string with import dependencies and parse errors.
@@ -296,7 +267,7 @@ Node.js Code
import { overrideFile, OverrideFileArgs } from "kcl-lib";
const result = overrideFile(
- new OverrideFileArgs("main.k", ["app.replicas=4"], [])
+ new OverrideFileArgs("main.k", ["app.replicas=4"], []),
);
```
@@ -407,7 +378,7 @@ schema Person:
`;
const data = '{"name": "Alice", "age": 10}';
const result = validateCode(
- new ValidateCodeArgs(undefined, data, undefined, code)
+ new ValidateCodeArgs(undefined, data, undefined, code),
);
```
@@ -456,7 +427,7 @@ const args = RenameCodeArgs(
"/mock/path",
"a",
{ "/mock/path/main.k": "a = 1\nb = a" },
- "a2"
+ "a2",
);
const result = renameCode(args);
```
@@ -591,8 +562,8 @@ const execResult = execProgram(
undefined,
undefined,
undefined,
- result.externalPkgs
- )
+ result.externalPkgs,
+ ),
);
```
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/overview.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/overview.md
index b57d08a9..6881eb60 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/overview.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/overview.md
@@ -36,8 +36,8 @@ curl -X POST http://127.0.0.1:2021/api:protorpc/BuiltinService.Ping --data '{}'
```json
{
- "error": "",
- "result": {}
+ "error": "",
+ "result": {}
}
```
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/python-api.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/python-api.md
index bee781a1..8a5e0d8b 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/python-api.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/python-api.md
@@ -75,26 +75,6 @@ except Exception as err:
-### parse_program
-
-Parse KCL program with entry files and return the AST JSON string.
-
-Example
-
-
-```python
-import kcl_lib.api as api
-
-args = api.ParseProgram_Args(paths=["schema.k"])
-api = api.API()
-result = api.parse_program(args)
-assert len(result.paths) == 1
-assert len(result.errors) == 0
-```
-
-
-
-
### parse_file
Parse KCL single file to Module AST JSON string with import dependencies and parse errors.
@@ -118,10 +98,9 @@ Python Code
```python
import kcl_lib.api as api
-args = api.ParseProgram_Args(paths=[TEST_FILE])
+args = api.ParseFile_Args(path=TEST_FILE)
api = api.API()
-result = api.parse_program(args)
-assert len(result.paths) == 1
+result = api.parse_file(args)
assert len(result.errors) == 0
```
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/rest-api.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/rest-api.md
index 94903931..ca870b72 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/rest-api.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/xlang-api/rest-api.md
@@ -35,7 +35,7 @@ curl -X POST http://127.0.0.1:2021/api:protorpc/BuiltinService.Ping --data '{}'
完整的 `BuiltinService` 由 Protobuf 定义:
-```protobuf
+````protobuf
// Copyright The KCL Authors. All rights reserved.
//
// This file defines the request parameters and return structure of the KCL RPC server.
@@ -656,7 +656,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -698,7 +698,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -727,7 +727,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -760,7 +760,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -789,7 +789,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -1346,7 +1346,7 @@ message KeyValuePair {
// ---------------------------------------------------------------------------------
// Rename API
-// Find all the occurrences of the target symbol and rename them.
+// Find all the occurrences of the target symbol and rename them.
// This API will rewrite files if they contain symbols to be renamed.
// ---------------------------------------------------------------------------------
@@ -1509,4 +1509,4 @@ message Example {
// ----------------------------------------------------------------------------
// END
// ----------------------------------------------------------------------------
-```
+````
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/tools/cli/kcl/test.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/tools/cli/kcl/test.md
index 8802f89e..e7730544 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/tools/cli/kcl/test.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/tools/cli/kcl/test.md
@@ -128,7 +128,7 @@ import runtime
test_person_age_check_error_message = lambda {
msg = runtime.catch(lambda {
a = Person {age = 123}
- })
+ })
assert msg == "age must be in [0, 120]"
}
```
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/user_docs/guides/package-management/4-how-to/10-mod_private_repo.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/user_docs/guides/package-management/4-how-to/10-mod_private_repo.md
index 8833c4c9..2a37cb58 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/user_docs/guides/package-management/4-how-to/10-mod_private_repo.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/user_docs/guides/package-management/4-how-to/10-mod_private_repo.md
@@ -18,47 +18,47 @@ KCL 包管理工具与本地环境中的 Git 工具公用一份登录凭证,
1. 需要先使用 `kcl registry login` 命令登录私有 Registry。
- 更多信息 - [kcl registry login 登录 OCI registry](https://www.kcl-lang.io/zh-CN/docs/tools/cli/package-management/command-reference/login)
+ 更多信息 - [kcl registry login 登录 OCI registry](https://www.kcl-lang.io/zh-CN/docs/tools/cli/package-management/command-reference/login)
2. 更换 KCL 包管理工具使用的 OCI Registry,KCL 包管理工具支持通过三种方式指定下载 KCL 包时使用的 OCI registry.
- - 命令行或者 kcl.mod 中使用 OCI Url 指定使用的 OCI registry
+ - 命令行或者 kcl.mod 中使用 OCI Url 指定使用的 OCI registry
- 你可以通过以下命令行,指定 OCI Registry 为`ghcr.io`。
+ 你可以通过以下命令行,指定 OCI Registry 为`ghcr.io`。
- ```shell
- kcl mod add oci://ghcr.io/kcl-lang/helloworld --tag 0.1.0
- ```
+ ```shell
+ kcl mod add oci://ghcr.io/kcl-lang/helloworld --tag 0.1.0
+ ```
- 或者在 `kcl.mod` 文件中添加如下内容,指定 OCI Registry 为`ghcr.io`。
+ 或者在 `kcl.mod` 文件中添加如下内容,指定 OCI Registry 为`ghcr.io`。
- ```toml
- helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
- ```
+ ```toml
+ helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
+ ```
- - 通过环境变量
+ - 通过环境变量
- 你可以通过设置三个环境变量 KPM_REG、KPM_REGO 和 OCI_REG_PLAIN_HTTP 来调整配置。
+ 你可以通过设置三个环境变量 KPM_REG、KPM_REGO 和 OCI_REG_PLAIN_HTTP 来调整配置。
- ```shell
- # 设置默认仓库地址
- export KPM_REG="ghcr.io"
- # 设置默认仓库
- export KPM_REPO="kcl-lang"
- # 设置支持 'http'
- export OCI_REG_PLAIN_HTTP=off
- ```
+ ```shell
+ # 设置默认仓库地址
+ export KPM_REG="ghcr.io"
+ # 设置默认仓库
+ export KPM_REPO="kcl-lang"
+ # 设置支持 'http'
+ export OCI_REG_PLAIN_HTTP=off
+ ```
- - 通过配置文件
+ - 通过配置文件
- KCL 包管理工具的配置文件位于 `$KCL_PKG_PATH/.kpm/config/kpm.json`,如果环境变量 `KCL_PKG_PATH` 没有设置,它默认保存在 `$HOME/.kcl/kpm/.kpm/config/kpm.json`。
+ KCL 包管理工具的配置文件位于 `$KCL_PKG_PATH/.kpm/config/kpm.json`,如果环境变量 `KCL_PKG_PATH` 没有设置,它默认保存在 `$HOME/.kcl/kpm/.kpm/config/kpm.json`。
- 配置文件的默认内容如下:
+ 配置文件的默认内容如下:
- ```json
- {
- "DefaultOciRegistry": "ghcr.io",
- "DefaultOciRepo": "kcl-lang",
- "DefaultOciPlainHttp": true
- }
- ```
+ ```json
+ {
+ "DefaultOciRegistry": "ghcr.io",
+ "DefaultOciRepo": "kcl-lang",
+ "DefaultOciPlainHttp": true
+ }
+ ```
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.7/user_docs/guides/package-management/4-how-to/10-mod_private_repo.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.7/user_docs/guides/package-management/4-how-to/10-mod_private_repo.md
index 8833c4c9..2a37cb58 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.7/user_docs/guides/package-management/4-how-to/10-mod_private_repo.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.7/user_docs/guides/package-management/4-how-to/10-mod_private_repo.md
@@ -18,47 +18,47 @@ KCL 包管理工具与本地环境中的 Git 工具公用一份登录凭证,
1. 需要先使用 `kcl registry login` 命令登录私有 Registry。
- 更多信息 - [kcl registry login 登录 OCI registry](https://www.kcl-lang.io/zh-CN/docs/tools/cli/package-management/command-reference/login)
+ 更多信息 - [kcl registry login 登录 OCI registry](https://www.kcl-lang.io/zh-CN/docs/tools/cli/package-management/command-reference/login)
2. 更换 KCL 包管理工具使用的 OCI Registry,KCL 包管理工具支持通过三种方式指定下载 KCL 包时使用的 OCI registry.
- - 命令行或者 kcl.mod 中使用 OCI Url 指定使用的 OCI registry
+ - 命令行或者 kcl.mod 中使用 OCI Url 指定使用的 OCI registry
- 你可以通过以下命令行,指定 OCI Registry 为`ghcr.io`。
+ 你可以通过以下命令行,指定 OCI Registry 为`ghcr.io`。
- ```shell
- kcl mod add oci://ghcr.io/kcl-lang/helloworld --tag 0.1.0
- ```
+ ```shell
+ kcl mod add oci://ghcr.io/kcl-lang/helloworld --tag 0.1.0
+ ```
- 或者在 `kcl.mod` 文件中添加如下内容,指定 OCI Registry 为`ghcr.io`。
+ 或者在 `kcl.mod` 文件中添加如下内容,指定 OCI Registry 为`ghcr.io`。
- ```toml
- helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
- ```
+ ```toml
+ helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
+ ```
- - 通过环境变量
+ - 通过环境变量
- 你可以通过设置三个环境变量 KPM_REG、KPM_REGO 和 OCI_REG_PLAIN_HTTP 来调整配置。
+ 你可以通过设置三个环境变量 KPM_REG、KPM_REGO 和 OCI_REG_PLAIN_HTTP 来调整配置。
- ```shell
- # 设置默认仓库地址
- export KPM_REG="ghcr.io"
- # 设置默认仓库
- export KPM_REPO="kcl-lang"
- # 设置支持 'http'
- export OCI_REG_PLAIN_HTTP=off
- ```
+ ```shell
+ # 设置默认仓库地址
+ export KPM_REG="ghcr.io"
+ # 设置默认仓库
+ export KPM_REPO="kcl-lang"
+ # 设置支持 'http'
+ export OCI_REG_PLAIN_HTTP=off
+ ```
- - 通过配置文件
+ - 通过配置文件
- KCL 包管理工具的配置文件位于 `$KCL_PKG_PATH/.kpm/config/kpm.json`,如果环境变量 `KCL_PKG_PATH` 没有设置,它默认保存在 `$HOME/.kcl/kpm/.kpm/config/kpm.json`。
+ KCL 包管理工具的配置文件位于 `$KCL_PKG_PATH/.kpm/config/kpm.json`,如果环境变量 `KCL_PKG_PATH` 没有设置,它默认保存在 `$HOME/.kcl/kpm/.kpm/config/kpm.json`。
- 配置文件的默认内容如下:
+ 配置文件的默认内容如下:
- ```json
- {
- "DefaultOciRegistry": "ghcr.io",
- "DefaultOciRepo": "kcl-lang",
- "DefaultOciPlainHttp": true
- }
- ```
+ ```json
+ {
+ "DefaultOciRegistry": "ghcr.io",
+ "DefaultOciRepo": "kcl-lang",
+ "DefaultOciPlainHttp": true
+ }
+ ```
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.8/user_docs/guides/package-management/4-how-to/10-mod_private_repo.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.8/user_docs/guides/package-management/4-how-to/10-mod_private_repo.md
index 8833c4c9..2a37cb58 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.8/user_docs/guides/package-management/4-how-to/10-mod_private_repo.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.8/user_docs/guides/package-management/4-how-to/10-mod_private_repo.md
@@ -18,47 +18,47 @@ KCL 包管理工具与本地环境中的 Git 工具公用一份登录凭证,
1. 需要先使用 `kcl registry login` 命令登录私有 Registry。
- 更多信息 - [kcl registry login 登录 OCI registry](https://www.kcl-lang.io/zh-CN/docs/tools/cli/package-management/command-reference/login)
+ 更多信息 - [kcl registry login 登录 OCI registry](https://www.kcl-lang.io/zh-CN/docs/tools/cli/package-management/command-reference/login)
2. 更换 KCL 包管理工具使用的 OCI Registry,KCL 包管理工具支持通过三种方式指定下载 KCL 包时使用的 OCI registry.
- - 命令行或者 kcl.mod 中使用 OCI Url 指定使用的 OCI registry
+ - 命令行或者 kcl.mod 中使用 OCI Url 指定使用的 OCI registry
- 你可以通过以下命令行,指定 OCI Registry 为`ghcr.io`。
+ 你可以通过以下命令行,指定 OCI Registry 为`ghcr.io`。
- ```shell
- kcl mod add oci://ghcr.io/kcl-lang/helloworld --tag 0.1.0
- ```
+ ```shell
+ kcl mod add oci://ghcr.io/kcl-lang/helloworld --tag 0.1.0
+ ```
- 或者在 `kcl.mod` 文件中添加如下内容,指定 OCI Registry 为`ghcr.io`。
+ 或者在 `kcl.mod` 文件中添加如下内容,指定 OCI Registry 为`ghcr.io`。
- ```toml
- helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
- ```
+ ```toml
+ helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
+ ```
- - 通过环境变量
+ - 通过环境变量
- 你可以通过设置三个环境变量 KPM_REG、KPM_REGO 和 OCI_REG_PLAIN_HTTP 来调整配置。
+ 你可以通过设置三个环境变量 KPM_REG、KPM_REGO 和 OCI_REG_PLAIN_HTTP 来调整配置。
- ```shell
- # 设置默认仓库地址
- export KPM_REG="ghcr.io"
- # 设置默认仓库
- export KPM_REPO="kcl-lang"
- # 设置支持 'http'
- export OCI_REG_PLAIN_HTTP=off
- ```
+ ```shell
+ # 设置默认仓库地址
+ export KPM_REG="ghcr.io"
+ # 设置默认仓库
+ export KPM_REPO="kcl-lang"
+ # 设置支持 'http'
+ export OCI_REG_PLAIN_HTTP=off
+ ```
- - 通过配置文件
+ - 通过配置文件
- KCL 包管理工具的配置文件位于 `$KCL_PKG_PATH/.kpm/config/kpm.json`,如果环境变量 `KCL_PKG_PATH` 没有设置,它默认保存在 `$HOME/.kcl/kpm/.kpm/config/kpm.json`。
+ KCL 包管理工具的配置文件位于 `$KCL_PKG_PATH/.kpm/config/kpm.json`,如果环境变量 `KCL_PKG_PATH` 没有设置,它默认保存在 `$HOME/.kcl/kpm/.kpm/config/kpm.json`。
- 配置文件的默认内容如下:
+ 配置文件的默认内容如下:
- ```json
- {
- "DefaultOciRegistry": "ghcr.io",
- "DefaultOciRepo": "kcl-lang",
- "DefaultOciPlainHttp": true
- }
- ```
+ ```json
+ {
+ "DefaultOciRegistry": "ghcr.io",
+ "DefaultOciRepo": "kcl-lang",
+ "DefaultOciPlainHttp": true
+ }
+ ```
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/c-api.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/c-api.md
index 5bfe4678..0081421e 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/c-api.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/c-api.md
@@ -8,9 +8,9 @@ KCL [C API](https://github.com/kcl-lang/lib/tree/main/c) 正在开发中,欢
## 前置依赖
-+ Make
-+ C Compiler
-+ Cargo
+- Make
+- C Compiler
+- Cargo
## API 参考
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/cpp-api.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/cpp-api.md
index 8ab052f0..57f1cda1 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/cpp-api.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/cpp-api.md
@@ -8,9 +8,9 @@ KCL [C++ API](https://github.com/kcl-lang/lib/tree/main/cpp) 正在开发中,
## 前置依赖
-+ CMake >= 3.10
-+ C++ Compiler with C++17 Support
-+ Cargo
+- CMake >= 3.10
+- C++ Compiler with C++17 Support
+- Cargo
## 安装
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/dotnet-api.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/dotnet-api.md
index 6dea5eed..7e6fb092 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/dotnet-api.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/dotnet-api.md
@@ -57,38 +57,6 @@ var result = new API().ExecProgram(execArgs);
-### ParseProgram
-
-Parse KCL program with entry files and return the AST JSON string.
-
-Example
-
-
-The content of `schema.k` is
-
-```python
-schema AppConfig:
- replicas: int
-
-app: AppConfig {
- replicas: 2
-}
-```
-
-C# Code
-
-```csharp
-using KclLib.API;
-
-var path = "schema.k"
-var args = new ParseProgram_Args();
-args.Paths.Add(path);
-var result = new API().ParseProgram(args);
-```
-
-
-
-
### ParseFile
Parse KCL single file to Module AST JSON string with import dependencies and parse errors.
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/go-api.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/go-api.md
index 39f2777a..d495d555 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/go-api.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/go-api.md
@@ -93,49 +93,69 @@ x1 = Person {
## Index
- [Go API](#go-api)
- - [Index](#index)
- - [Constants](#constants)
- - [func FormatCode](#func-formatcode)
- - [func FormatPath](#func-formatpath)
- - [func GetSchemaTypeMapping](#func-getschematypemapping)
- - [func InitKclvmPath](#func-initkclvmpath)
- - [func InitKclvmRuntime](#func-initkclvmruntime)
- - [func LintPath](#func-lintpath)
- - [func ListDepFiles](#func-listdepfiles)
- - [func ListDownStreamFiles](#func-listdownstreamfiles)
- - [func ListUpStreamFiles](#func-listupstreamfiles)
- - [func OverrideFile](#func-overridefile)
- - [func Validate](#func-validate)
- - [func ValidateCode](#func-validatecode)
- - [type KCLResult](#type-kclresult)
- - [type KCLResultList](#type-kclresultlist)
- - [func MustRun](#func-mustrun)
- - [func Run](#func-run)
- - [func RunFiles](#func-runfiles)
- - [type KclType](#type-kcltype)
- - [type ListDepFilesOption](#type-listdepfilesoption)
- - [type ListDepsOptions](#type-listdepsoptions)
- - [type Option](#type-option)
- - [func WithCode](#func-withcode)
- - [func WithDisableNone](#func-withdisablenone)
- - [func WithExternalPkgs](#func-withexternalpkgs)
- - [func WithFullTypePath](#func-withfulltypepath)
- - [func WithIncludeSchemaTypePath](#func-withincludeschematypepath)
- - [func WithKFilenames](#func-withkfilenames)
- - [func WithLogger](#func-withlogger)
- - [func WithOptions](#func-withoptions)
- - [func WithOverrides](#func-withoverrides)
- - [func WithPrintOverridesAST](#func-withprintoverridesast)
- - [func WithSelectors](#func-withselectors)
- - [func WithSettings](#func-withsettings)
- - [func WithShowHidden](#func-withshowhidden)
- - [func WithSortKeys](#func-withsortkeys)
- - [func WithWorkDir](#func-withworkdir)
- - [type TestCaseInfo](#type-testcaseinfo)
- - [type TestOptions](#type-testoptions)
- - [type TestResult](#type-testresult)
- - [func Test](#func-test)
- - [type ValidateOptions](#type-validateoptions)
+ - [Index](#index)
+ - [Constants](#constants)
+ - [func FormatCode](#func-formatcode)
+ - [func FormatPath](#func-formatpath)
+ - [func GetSchemaTypeMapping](#func-getschematypemapping)
+ - [func InitKclvmPath](#func-initkclvmpath)
+ - [func InitKclvmRuntime](#func-initkclvmruntime)
+ - [func LintPath](#func-lintpath)
+ - [func ListDepFiles](#func-listdepfiles)
+ - [func ListDownStreamFiles](#func-listdownstreamfiles)
+ - [func ListUpStreamFiles](#func-listupstreamfiles)
+ - [func OverrideFile](#func-overridefile)
+ - [func Validate](#func-validate)
+ - [func ValidateCode](#func-validatecode)
+ - [type KCLResult](#type-kclresult)
+ - [type KCLResultList](#type-kclresultlist)
+ - [func MustRun](#func-mustrun)
+ - [func Run](#func-run)
+ - [func RunFiles](#func-runfiles)
+ - [type KclType](#type-kcltype)
+ - [func GetSchemaType](#func-getschematype)
+ - [type ListDepFilesOption](#type-listdepfilesoption)
+ - [type ListDepsOptions](#type-listdepsoptions)
+ - [type ListOptionsArgs](#type-listoptionsargs)
+ - [type ListOptionsResult](#type-listoptionsresult)
+ - [func ListOptions](#func-listoptions)
+ - [type ListVariablesArgs](#type-listvariablesargs)
+ - [type ListVariablesResult](#type-listvariablesresult)
+ - [func ListVariables](#func-listvariables)
+ - [type LoadPackageArgs](#type-loadpackageargs)
+ - [type LoadPackageResult](#type-loadpackageresult)
+ - [func LoadPackage](#func-loadpackage)
+ - [type Option](#type-option)
+ - [func NewOption](#func-newoption)
+ - [func WithCode](#func-withcode)
+ - [func WithDisableNone](#func-withdisablenone)
+ - [func WithExternalPkgAndPath](#func-withexternalpkgandpath)
+ - [func WithExternalPkgs](#func-withexternalpkgs)
+ - [func WithFullTypePath](#func-withfulltypepath)
+ - [func WithIncludeSchemaTypePath](#func-withincludeschematypepath)
+ - [func WithKFilenames](#func-withkfilenames)
+ - [func WithLogger](#func-withlogger)
+ - [func WithOptions](#func-withoptions)
+ - [func WithOverrides](#func-withoverrides)
+ - [func WithPrintOverridesAST](#func-withprintoverridesast)
+ - [func WithSelectors](#func-withselectors)
+ - [func WithSettings](#func-withsettings)
+ - [func WithShowHidden](#func-withshowhidden)
+ - [func WithSortKeys](#func-withsortkeys)
+ - [func WithWorkDir](#func-withworkdir)
+ - [type ParseProgramArgs](#type-parseprogramargs)
+ - [type ParseProgramResult](#type-parseprogramresult)
+ - [func ParseProgram](#func-parseprogram)
+ - [type TestCaseInfo](#type-testcaseinfo)
+ - [type TestOptions](#type-testoptions)
+ - [type TestResult](#type-testresult)
+ - [func Test](#func-test)
+ - [type UpdateDependenciesArgs](#type-updatedependenciesargs)
+ - [type UpdateDependenciesResult](#type-updatedependenciesresult)
+ - [func UpdateDependencies](#func-updatedependencies)
+ - [type ValidateOptions](#type-validateoptions)
+ - [type VersionResult](#type-versionresult)
+ - [func GetVersion](#func-getversion)
## Constants
@@ -145,7 +165,7 @@ KclvmAbiVersion is the current kclvm ABI version.
const KclvmAbiVersion = scripts.KclvmAbiVersion
```
-## func [FormatCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L143)
+## func [FormatCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L167)
```go
func FormatCode(code interface{}) ([]byte, error)
@@ -183,7 +203,7 @@ a = 1 + 2
-## func [FormatPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L155)
+## func [FormatPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L179)
```go
func FormatPath(path string) (changedPaths []string, err error)
@@ -218,7 +238,7 @@ func main() {
-## func [GetSchemaTypeMapping](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L237)
+## func [GetSchemaTypeMapping](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L258)
```go
func GetSchemaTypeMapping(filename string, src any, schemaName string) (map[string]*KclType, error)
@@ -244,7 +264,7 @@ schema_name: string
The schema name got, when the schema name is empty, all schemas are returned.
```
-## func [InitKclvmPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L61)
+## func [InitKclvmPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L75)
```go
func InitKclvmPath(kclvmRoot string)
@@ -252,7 +272,7 @@ func InitKclvmPath(kclvmRoot string)
InitKclvmPath init kclvm path.
-## func [InitKclvmRuntime](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L66)
+## func [InitKclvmRuntime](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L80)
```go
func InitKclvmRuntime(n int)
@@ -260,7 +280,7 @@ func InitKclvmRuntime(n int)
InitKclvmRuntime init kclvm process.
-## func [LintPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L175)
+## func [LintPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L199)
```go
func LintPath(paths []string) (results []string, err error)
@@ -305,7 +325,7 @@ Module 'a' imported but unused
-## func [ListDepFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L160)
+## func [ListDepFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L184)
```go
func ListDepFiles(workDir string, opt *ListDepFilesOption) (files []string, err error)
@@ -313,7 +333,7 @@ func ListDepFiles(workDir string, opt *ListDepFilesOption) (files []string, err
ListDepFiles return the depend files from the given path
-## func [ListDownStreamFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L170)
+## func [ListDownStreamFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L194)
```go
func ListDownStreamFiles(workDir string, opt *ListDepsOptions) ([]string, error)
@@ -321,7 +341,7 @@ func ListDownStreamFiles(workDir string, opt *ListDepsOptions) ([]string, error)
ListDownStreamFiles return a list of downstream depend files from the given changed path list.
-## func [ListUpStreamFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L165)
+## func [ListUpStreamFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L189)
```go
func ListUpStreamFiles(workDir string, opt *ListDepsOptions) (deps []string, err error)
@@ -329,22 +349,15 @@ func ListUpStreamFiles(workDir string, opt *ListDepsOptions) (deps []string, err
ListUpStreamFiles return a list of upstream depend files from the given path list
-## func [OverrideFile](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L187)
+## func [OverrideFile](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L208)
```go
func OverrideFile(file string, specs, importPaths []string) (bool, error)
```
-OverrideFile rewrites a file with override spec file: string. The File that need to be overridden specs: \[\]string. List of specs that need to be overridden.
+OverrideFile rewrites a file with override spec file: string. The File that need to be overridden specs: \[\]string. List of specs that need to be overridden. importPaths. List of import statements that need to be added. See https://www.kcl-lang.io/docs/user_docs/guides/automation for more override spec guide.
-```
-Each spec string satisfies the form: := or :-
-When the pkgpath is '__main__', it can be omitted.
-```
-
-importPaths. List of import statements that need to be added
-
-## func [Validate](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L198)
+## func [Validate](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L219)
```go
func Validate(dataFile, schemaFile string, opts *ValidateOptions) (ok bool, err error)
@@ -352,7 +365,7 @@ func Validate(dataFile, schemaFile string, opts *ValidateOptions) (ok bool, err
Validate validates the given data file against the specified schema file with the provided options.
-## func [ValidateCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L192)
+## func [ValidateCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L213)
```go
func ValidateCode(data, code string, opts *ValidateOptions) (ok bool, err error)
@@ -360,7 +373,7 @@ func ValidateCode(data, code string, opts *ValidateOptions) (ok bool, err error)
ValidateCode validate data string match code string
-## type [KCLResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L54)
+## type [KCLResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L57)
```go
type KCLResult = kcl.KCLResult
@@ -409,7 +422,7 @@ x1.age: 101
-Example ('et_struct)
+Example (Get)
```go
@@ -454,13 +467,13 @@ person: {Name:kcl Age:101}
-## type [KCLResultList](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L55)
+## type [KCLResultList](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L58)
```go
type KCLResultList = kcl.KCLResultList
```
-### func [MustRun](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L71)
+### func [MustRun](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L85)
```go
func MustRun(path string, opts ...Option) *KCLResultList
@@ -587,7 +600,7 @@ func main() {
-### func [Run](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L76)
+### func [Run](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L90)
```go
func Run(path string, opts ...Option) (*KCLResultList, error)
@@ -595,7 +608,15 @@ func Run(path string, opts ...Option) (*KCLResultList, error)
Run evaluates the KCL program with path and opts, then returns the object list.
-Example (Get Field)
+### func [RunFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L95)
+
+```go
+func RunFiles(paths []string, opts ...Option) (*KCLResultList, error)
+```
+
+RunFiles evaluates the KCL program with multi file path and opts, then returns the object list.
+
+Example
```go
@@ -603,43 +624,134 @@ package main
import (
"fmt"
- "log"
kcl "kcl-lang.io/kcl-go"
)
-func assert(v bool, a ...interface{}) {
- if !v {
- a = append([]interface{}{"assert failed"}, a...)
- log.Panic(a...)
- }
+func main() {
+ result, _ := kcl.RunFiles([]string{"./testdata/app0/kcl.yaml"})
+ fmt.Println(result.First().YAMLString())
}
+```
-func main() {
- // run kcl.yaml
- x, err := kcl.Run("./testdata/app0/kcl.yaml")
- assert(err == nil, err)
+
+
+
+## type [KclType](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L60)
+
+```go
+type KclType = kcl.KclType
+```
+
+### func [GetSchemaType](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L241)
+
+```go
+func GetSchemaType(filename string, src any, schemaName string) ([]*KclType, error)
+```
+
+GetSchemaType returns schema types from a kcl file or code.
+
+file: string
- // print deploy_topology[1].zone
- fmt.Println(x.First().Get("deploy_topology.1.zone"))
+```
+The kcl filename
+```
+
+code: string
+
+```
+The kcl code string
+```
+
+schema_name: string
+
+```
+The schema name got, when the schema name is empty, all schemas are returned.
+```
+
+## type [ListDepFilesOption](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L52)
+
+```go
+type ListDepFilesOption = list.Option
+```
+
+## type [ListDepsOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L51)
+
+```go
+type ListDepsOptions = list.DepOptions
+```
+
+## type [ListOptionsArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L68)
+
+```go
+type ListOptionsArgs = loader.ListOptionsArgs
+```
+
+## type [ListOptionsResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L69)
+
+```go
+type ListOptionsResult = loader.ListOptionsResult
+```
+
+### func [ListOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L280)
+
+```go
+func ListOptions(args *ListOptionsArgs) (*ListOptionsResult, error)
+```
+
+ListOptions provides users with the ability to parse kcl program and get all option calling information.
+
+Example
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+)
+
+func main() {
+ result, err := kcl.ListOptions(&kcl.ListOptionsArgs{
+ Paths: []string{"testdata/option/main.k"},
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(result)
}
```
```
-R000A
+options:{name:"key1"} options:{name:"key2" required:true} options:{name:"metadata-key"}
```
-### func [RunFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L81)
+## type [ListVariablesArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L66)
```go
-func RunFiles(paths []string, opts ...Option) (*KCLResultList, error)
+type ListVariablesArgs = loader.ListVariablesArgs
```
-RunFiles evaluates the KCL program with multi file path and opts, then returns the object list.
+## type [ListVariablesResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L67)
+
+```go
+type ListVariablesResult = loader.ListVariablesResult
+```
+
+### func [ListVariables](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L274)
+
+```go
+func ListVariables(args *ListVariablesArgs) (*ListVariablesResult, error)
+```
+
+ListVariables provides users with the ability to parse KCL program and get all variables by specs.
Example
@@ -649,44 +761,95 @@ package main
import (
"fmt"
+ "log"
kcl "kcl-lang.io/kcl-go"
)
func main() {
- result, _ := kcl.RunFiles([]string{"./testdata/app0/kcl.yaml"})
- fmt.Println(result.First().YAMLString())
+ result, err := kcl.ListVariables(&kcl.ListVariablesArgs{
+ Files: []string{"testdata/main.k"},
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(result)
+
}
```
+```
+variables:{key:"age" value:{variables:{value:"2" op_sym:"="}}} variables:{key:"four" value:{variables:{value:"4" op_sym:"="}}} variables:{key:"name" value:{variables:{value:"\"kcl-go\"" op_sym:"="}}} variables:{key:"x0" value:{variables:{value:"Person {}" type_name:"Person" op_sym:"="}}} variables:{key:"x1" value:{variables:{value:"Person {age = 101}" type_name:"Person" op_sym:"=" dict_entries:{key:"age" value:{value:"101" op_sym:"="}}}}}
+```
+
-## type [KclType](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L57)
+## type [LoadPackageArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L64)
```go
-type KclType = kcl.KclType
+type LoadPackageArgs = loader.LoadPackageArgs
```
-## type [ListDepFilesOption](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L49)
+## type [LoadPackageResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L65)
```go
-type ListDepFilesOption = list.Option
+type LoadPackageResult = loader.LoadPackageResult
```
-## type [ListDepsOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L48)
+### func [LoadPackage](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L269)
```go
-type ListDepsOptions = list.DepOptions
+func LoadPackage(args *LoadPackageArgs) (*LoadPackageResult, error)
```
-## type [Option](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L47)
+LoadPackage provides users with the ability to parse KCL program and semantic model information including symbols, types, definitions, etc.
+
+Example
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+)
+
+func main() {
+ result, err := kcl.LoadPackage(&kcl.LoadPackageArgs{
+ ParseArgs: &kcl.ParseProgramArgs{
+ Paths: []string{"testdata/main.k"},
+ },
+ ResolveAst: true,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(result)
+}
+```
+
+
+
+
+## type [Option](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L50)
```go
type Option = kcl.Option
```
-### func [WithCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L86)
+### func [NewOption](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L100)
+
+```go
+func NewOption() *Option
+```
+
+NewOption returns a new Option.
+
+### func [WithCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L105)
```go
func WithCode(codes ...string) Option
@@ -694,7 +857,7 @@ func WithCode(codes ...string) Option
WithCode returns a Option which hold a kcl source code list.
-### func [WithDisableNone](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L110)
+### func [WithDisableNone](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L134)
```go
func WithDisableNone(disableNone bool) Option
@@ -702,7 +865,15 @@ func WithDisableNone(disableNone bool) Option
WithDisableNone returns a Option which hold a disable none switch.
-### func [WithExternalPkgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L89)
+### func [WithExternalPkgAndPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L111)
+
+```go
+func WithExternalPkgAndPath(name, path string) Option
+```
+
+WithExternalPkgAndPath returns a Option which hold a external package.
+
+### func [WithExternalPkgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L108)
```go
func WithExternalPkgs(externalPkgs ...string) Option
@@ -710,7 +881,7 @@ func WithExternalPkgs(externalPkgs ...string) Option
WithExternalPkgs returns a Option which hold a external package list.
-### func [WithFullTypePath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L118)
+### func [WithFullTypePath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L142)
```go
func WithFullTypePath(fullTypePath bool) Option
@@ -718,7 +889,7 @@ func WithFullTypePath(fullTypePath bool) Option
WithFullTypePath returns a Option which hold a include full type string in the \`\_type\` attribute.
-### func [WithIncludeSchemaTypePath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L113)
+### func [WithIncludeSchemaTypePath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L137)
```go
func WithIncludeSchemaTypePath(includeSchemaTypePath bool) Option
@@ -726,7 +897,7 @@ func WithIncludeSchemaTypePath(includeSchemaTypePath bool) Option
WithIncludeSchemaTypePath returns a Option which hold a include schema type path switch.
-### func [WithKFilenames](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L92)
+### func [WithKFilenames](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L116)
```go
func WithKFilenames(filenames ...string) Option
@@ -734,7 +905,7 @@ func WithKFilenames(filenames ...string) Option
WithKFilenames returns a Option which hold a filenames list.
-### func [WithLogger](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L138)
+### func [WithLogger](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L162)
```go
func WithLogger(l io.Writer) Option
@@ -742,7 +913,7 @@ func WithLogger(l io.Writer) Option
WithLogger returns a Option which hold a logger.
-### func [WithOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L95)
+### func [WithOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L119)
```go
func WithOptions(key_value_list ...string) Option
@@ -788,7 +959,7 @@ name: kcl
-### func [WithOverrides](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L98)
+### func [WithOverrides](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L122)
```go
func WithOverrides(override_list ...string) Option
@@ -796,7 +967,7 @@ func WithOverrides(override_list ...string) Option
WithOverrides returns a Option which hold a override list.
-### func [WithPrintOverridesAST](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L123)
+### func [WithPrintOverridesAST](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L147)
```go
func WithPrintOverridesAST(printOverridesAST bool) Option
@@ -804,7 +975,7 @@ func WithPrintOverridesAST(printOverridesAST bool) Option
WithPrintOverridesAST returns a Option which hold a printOverridesAST switch.
-### func [WithSelectors](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L101)
+### func [WithSelectors](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L125)
```go
func WithSelectors(selectors ...string) Option
@@ -812,7 +983,7 @@ func WithSelectors(selectors ...string) Option
WithSelectors returns a Option which hold a path selector list.
-### func [WithSettings](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L104)
+### func [WithSettings](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L128)
```go
func WithSettings(filename string) Option
@@ -820,7 +991,7 @@ func WithSettings(filename string) Option
WithSettings returns a Option which hold a settings file.
-### func [WithShowHidden](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L133)
+### func [WithShowHidden](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L157)
```go
func WithShowHidden(showHidden bool) Option
@@ -828,7 +999,7 @@ func WithShowHidden(showHidden bool) Option
WithShowHidden returns a Option which holds a showHidden switch.
-### func [WithSortKeys](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L128)
+### func [WithSortKeys](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L152)
```go
func WithSortKeys(sortKeys bool) Option
@@ -836,7 +1007,7 @@ func WithSortKeys(sortKeys bool) Option
WithSortKeys returns a Option which holds a sortKeys switch.
-### func [WithWorkDir](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L107)
+### func [WithWorkDir](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L131)
```go
func WithWorkDir(workDir string) Option
@@ -844,25 +1015,72 @@ func WithWorkDir(workDir string) Option
WithWorkDir returns a Option which hold a work dir.
-## type [TestCaseInfo](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L52)
+## type [ParseProgramArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L70)
+
+```go
+type ParseProgramArgs = parser.ParseProgramArgs
+```
+
+## type [ParseProgramResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L71)
+
+```go
+type ParseProgramResult = parser.ParseProgramResult
+```
+
+### func [ParseProgram](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L263)
+
+```go
+func ParseProgram(args *ParseProgramArgs) (*ParseProgramResult, error)
+```
+
+Parse KCL program with entry files and return the AST JSON string.
+
+Example
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+)
+
+func main() {
+ result, err := kcl.ParseProgram(&kcl.ParseProgramArgs{
+ Paths: []string{"testdata/main.k"},
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(result)
+}
+```
+
+
+
+
+## type [TestCaseInfo](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L55)
```go
type TestCaseInfo = testing.TestCaseInfo
```
-## type [TestOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L51)
+## type [TestOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L54)
```go
type TestOptions = testing.TestOptions
```
-## type [TestResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L53)
+## type [TestResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L56)
```go
type TestResult = testing.TestResult
```
-### func [Test](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L203)
+### func [Test](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L224)
```go
func Test(testOpts *TestOptions, opts ...Option) (TestResult, error)
@@ -870,8 +1088,136 @@ func Test(testOpts *TestOptions, opts ...Option) (TestResult, error)
Test calls the test tool to run uni tests in packages.
-## type [ValidateOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L50)
+## type [UpdateDependenciesArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L62)
+
+```go
+type UpdateDependenciesArgs = module.UpdateDependenciesArgs
+```
+
+## type [UpdateDependenciesResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L63)
+
+```go
+type UpdateDependenciesResult = module.UpdateDependenciesResult
+```
+
+### func [UpdateDependencies](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L285)
+
+```go
+func UpdateDependencies(args *UpdateDependenciesArgs) (*UpdateDependenciesResult, error)
+```
+
+Download and update dependencies defined in the kcl.mod file and return the external package name and location list.
+
+Example
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+ "kcl-lang.io/kcl-go/pkg/spec/gpyrpc"
+)
+
+func main() {
+ // [package]
+ // name = "mod_update"
+ // edition = "0.0.1"
+ // version = "0.0.1"
+ //
+ // [dependencies]
+ // helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
+ // flask = { git = "https://github.com/kcl-lang/flask-demo-kcl-manifests", commit = "ade147b" }
+
+ result, err := kcl.UpdateDependencies(&gpyrpc.UpdateDependencies_Args{
+ ManifestPath: "testdata/update_dependencies",
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ fmt.Println(result)
+}
+```
+
+
+
+
+Example (Exec Program)
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+ "kcl-lang.io/kcl-go/pkg/spec/gpyrpc"
+)
+
+func main() {
+ // [package]
+ // name = "mod_update"
+ // edition = "0.0.1"
+ // version = "0.0.1"
+ //
+ // [dependencies]
+ // helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
+ // flask = { git = "https://github.com/kcl-lang/flask-demo-kcl-manifests", commit = "ade147b" }
+
+ result, err := kcl.UpdateDependencies(&gpyrpc.UpdateDependencies_Args{
+ ManifestPath: "testdata/update_dependencies",
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ // import helloworld
+ // import flask
+ // a = helloworld.The_first_kcl_program
+ // fmt.Println(result.ExternalPkgs)
+
+ opt := kcl.NewOption()
+ opt.ExternalPkgs = result.ExternalPkgs
+
+ runResult, err := kcl.Run("testdata/update_dependencies/main.k", *opt)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ fmt.Println(runResult.GetRawYamlResult())
+
+}
+```
+
+```
+a: Hello World!
+```
+
+
+
+
+## type [ValidateOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L53)
```go
type ValidateOptions = validate.ValidateOptions
```
+
+## type [VersionResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L61)
+
+```go
+type VersionResult = kcl.VersionResult
+```
+
+### func [GetVersion](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L290)
+
+```go
+func GetVersion() (*VersionResult, error)
+```
+
+GetVersion returns the KCL service version information.
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/java-api.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/java-api.md
index c8df505e..6ffb16c6 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/java-api.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/java-api.md
@@ -83,42 +83,6 @@ ExecProgram_Result result = apiInstance.execProgram(args);
-### parseProgram
-
-Parse KCL program with entry files and return the AST JSON string.
-
-Example
-
-
-The content of `schema.k` is
-
-```python
-schema AppConfig:
- replicas: int
-
-app: AppConfig {
- replicas: 2
-}
-```
-
-Java Code
-
-```java
-import com.kcl.api.*;
-import com.kcl.ast.*;
-import com.kcl.util.JsonUtil;
-
-API api = new API();
-ParseProgram_Result result = api.parseProgram(
- ParseProgram_Args.newBuilder().addPaths("schema.k").build()
-);
-System.out.println(result.getAstJson());
-Program program = JsonUtil.deserializeProgram(result.getAstJson());
-```
-
-
-
-
### parseFile
Parse KCL single file to Module AST JSON string with import dependencies and parse errors.
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/nodejs-api.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/nodejs-api.md
index c87a19ca..f8f0c583 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/nodejs-api.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/nodejs-api.md
@@ -72,35 +72,6 @@ try {
-### parseProgram
-
-Parse KCL program with entry files and return the AST JSON string.
-
-Example
-
-
-The content of `schema.k` is
-
-```python
-schema AppConfig:
- replicas: int
-
-app: AppConfig {
- replicas: 2
-}
-```
-
-Node.js Code
-
-```ts
-import { parseProgram, ParseProgramArgs } from "kcl-lib";
-
-const result = parseProgram(new ParseProgramArgs(["schema.k"]));
-```
-
-
-
-
### parseFile
Parse KCL single file to Module AST JSON string with import dependencies and parse errors.
@@ -296,7 +267,7 @@ Node.js Code
import { overrideFile, OverrideFileArgs } from "kcl-lib";
const result = overrideFile(
- new OverrideFileArgs("main.k", ["app.replicas=4"], [])
+ new OverrideFileArgs("main.k", ["app.replicas=4"], []),
);
```
@@ -407,7 +378,7 @@ schema Person:
`;
const data = '{"name": "Alice", "age": 10}';
const result = validateCode(
- new ValidateCodeArgs(undefined, data, undefined, code)
+ new ValidateCodeArgs(undefined, data, undefined, code),
);
```
@@ -456,7 +427,7 @@ const args = RenameCodeArgs(
"/mock/path",
"a",
{ "/mock/path/main.k": "a = 1\nb = a" },
- "a2"
+ "a2",
);
const result = renameCode(args);
```
@@ -591,8 +562,8 @@ const execResult = execProgram(
undefined,
undefined,
undefined,
- result.externalPkgs
- )
+ result.externalPkgs,
+ ),
);
```
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/overview.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/overview.md
index b57d08a9..6881eb60 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/overview.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/overview.md
@@ -36,8 +36,8 @@ curl -X POST http://127.0.0.1:2021/api:protorpc/BuiltinService.Ping --data '{}'
```json
{
- "error": "",
- "result": {}
+ "error": "",
+ "result": {}
}
```
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/python-api.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/python-api.md
index bee781a1..8a5e0d8b 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/python-api.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/python-api.md
@@ -75,26 +75,6 @@ except Exception as err:
-### parse_program
-
-Parse KCL program with entry files and return the AST JSON string.
-
-Example
-
-
-```python
-import kcl_lib.api as api
-
-args = api.ParseProgram_Args(paths=["schema.k"])
-api = api.API()
-result = api.parse_program(args)
-assert len(result.paths) == 1
-assert len(result.errors) == 0
-```
-
-
-
-
### parse_file
Parse KCL single file to Module AST JSON string with import dependencies and parse errors.
@@ -118,10 +98,9 @@ Python Code
```python
import kcl_lib.api as api
-args = api.ParseProgram_Args(paths=[TEST_FILE])
+args = api.ParseFile_Args(path=TEST_FILE)
api = api.API()
-result = api.parse_program(args)
-assert len(result.paths) == 1
+result = api.parse_file(args)
assert len(result.errors) == 0
```
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/rest-api.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/rest-api.md
index 94903931..ca870b72 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/rest-api.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/reference/xlang-api/rest-api.md
@@ -35,7 +35,7 @@ curl -X POST http://127.0.0.1:2021/api:protorpc/BuiltinService.Ping --data '{}'
完整的 `BuiltinService` 由 Protobuf 定义:
-```protobuf
+````protobuf
// Copyright The KCL Authors. All rights reserved.
//
// This file defines the request parameters and return structure of the KCL RPC server.
@@ -656,7 +656,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -698,7 +698,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -727,7 +727,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -760,7 +760,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -789,7 +789,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -1346,7 +1346,7 @@ message KeyValuePair {
// ---------------------------------------------------------------------------------
// Rename API
-// Find all the occurrences of the target symbol and rename them.
+// Find all the occurrences of the target symbol and rename them.
// This API will rewrite files if they contain symbols to be renamed.
// ---------------------------------------------------------------------------------
@@ -1509,4 +1509,4 @@ message Example {
// ----------------------------------------------------------------------------
// END
// ----------------------------------------------------------------------------
-```
+````
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/tools/cli/kcl/test.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/tools/cli/kcl/test.md
index 8802f89e..e7730544 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/tools/cli/kcl/test.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/tools/cli/kcl/test.md
@@ -128,7 +128,7 @@ import runtime
test_person_age_check_error_message = lambda {
msg = runtime.catch(lambda {
a = Person {age = 123}
- })
+ })
assert msg == "age must be in [0, 120]"
}
```
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/user_docs/guides/package-management/4-how-to/10-mod_private_repo.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/user_docs/guides/package-management/4-how-to/10-mod_private_repo.md
index 8833c4c9..2a37cb58 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/user_docs/guides/package-management/4-how-to/10-mod_private_repo.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.9/user_docs/guides/package-management/4-how-to/10-mod_private_repo.md
@@ -18,47 +18,47 @@ KCL 包管理工具与本地环境中的 Git 工具公用一份登录凭证,
1. 需要先使用 `kcl registry login` 命令登录私有 Registry。
- 更多信息 - [kcl registry login 登录 OCI registry](https://www.kcl-lang.io/zh-CN/docs/tools/cli/package-management/command-reference/login)
+ 更多信息 - [kcl registry login 登录 OCI registry](https://www.kcl-lang.io/zh-CN/docs/tools/cli/package-management/command-reference/login)
2. 更换 KCL 包管理工具使用的 OCI Registry,KCL 包管理工具支持通过三种方式指定下载 KCL 包时使用的 OCI registry.
- - 命令行或者 kcl.mod 中使用 OCI Url 指定使用的 OCI registry
+ - 命令行或者 kcl.mod 中使用 OCI Url 指定使用的 OCI registry
- 你可以通过以下命令行,指定 OCI Registry 为`ghcr.io`。
+ 你可以通过以下命令行,指定 OCI Registry 为`ghcr.io`。
- ```shell
- kcl mod add oci://ghcr.io/kcl-lang/helloworld --tag 0.1.0
- ```
+ ```shell
+ kcl mod add oci://ghcr.io/kcl-lang/helloworld --tag 0.1.0
+ ```
- 或者在 `kcl.mod` 文件中添加如下内容,指定 OCI Registry 为`ghcr.io`。
+ 或者在 `kcl.mod` 文件中添加如下内容,指定 OCI Registry 为`ghcr.io`。
- ```toml
- helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
- ```
+ ```toml
+ helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
+ ```
- - 通过环境变量
+ - 通过环境变量
- 你可以通过设置三个环境变量 KPM_REG、KPM_REGO 和 OCI_REG_PLAIN_HTTP 来调整配置。
+ 你可以通过设置三个环境变量 KPM_REG、KPM_REGO 和 OCI_REG_PLAIN_HTTP 来调整配置。
- ```shell
- # 设置默认仓库地址
- export KPM_REG="ghcr.io"
- # 设置默认仓库
- export KPM_REPO="kcl-lang"
- # 设置支持 'http'
- export OCI_REG_PLAIN_HTTP=off
- ```
+ ```shell
+ # 设置默认仓库地址
+ export KPM_REG="ghcr.io"
+ # 设置默认仓库
+ export KPM_REPO="kcl-lang"
+ # 设置支持 'http'
+ export OCI_REG_PLAIN_HTTP=off
+ ```
- - 通过配置文件
+ - 通过配置文件
- KCL 包管理工具的配置文件位于 `$KCL_PKG_PATH/.kpm/config/kpm.json`,如果环境变量 `KCL_PKG_PATH` 没有设置,它默认保存在 `$HOME/.kcl/kpm/.kpm/config/kpm.json`。
+ KCL 包管理工具的配置文件位于 `$KCL_PKG_PATH/.kpm/config/kpm.json`,如果环境变量 `KCL_PKG_PATH` 没有设置,它默认保存在 `$HOME/.kcl/kpm/.kpm/config/kpm.json`。
- 配置文件的默认内容如下:
+ 配置文件的默认内容如下:
- ```json
- {
- "DefaultOciRegistry": "ghcr.io",
- "DefaultOciRepo": "kcl-lang",
- "DefaultOciPlainHttp": true
- }
- ```
+ ```json
+ {
+ "DefaultOciRegistry": "ghcr.io",
+ "DefaultOciRepo": "kcl-lang",
+ "DefaultOciPlainHttp": true
+ }
+ ```
diff --git a/versioned_docs/version-0.7/user_docs/guides/package-management/4-how-to/10-private_mod_repo.md b/versioned_docs/version-0.7/user_docs/guides/package-management/4-how-to/10-private_mod_repo.md
index 520be7a6..b1d004e5 100644
--- a/versioned_docs/version-0.7/user_docs/guides/package-management/4-how-to/10-private_mod_repo.md
+++ b/versioned_docs/version-0.7/user_docs/guides/package-management/4-how-to/10-private_mod_repo.md
@@ -18,47 +18,47 @@ The KCL package management tool supports saving and sharing KCL packages through
1. Login to the private OCI Registry using the `kcl registry login` command.
- More Details - [kcl registry login Login OCI Registry](https://www.kcl-lang.io/docs/tools/cli/package-management/command-reference/login)
+ More Details - [kcl registry login Login OCI Registry](https://www.kcl-lang.io/docs/tools/cli/package-management/command-reference/login)
2. Replace the OCI Registry used by the KCL package management tool. The KCL package management tool supports specifying the OCI registry used to download KCL packages in three ways.
- - Use the OCI Url to specify the OCI registry in the command line or `kcl.mod`.
+ - Use the OCI Url to specify the OCI registry in the command line or `kcl.mod`.
- You can specify the OCI Registry as `ghcr.io` by the following command.
+ You can specify the OCI Registry as `ghcr.io` by the following command.
- ```shell
- kcl mod add oci://ghcr.io/kcl-lang/helloworld --tag 0.1.0
- ```
+ ```shell
+ kcl mod add oci://ghcr.io/kcl-lang/helloworld --tag 0.1.0
+ ```
- Or add the following content to the `kcl.mod` file to specify the OCI Registry as `ghcr.io`.
+ Or add the following content to the `kcl.mod` file to specify the OCI Registry as `ghcr.io`.
- ```toml
- helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
- ```
+ ```toml
+ helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
+ ```
- - By environment variable
+ - By environment variable
- You can adjust the configuration of the OCI Registry by setting the three environment variables `KPM_REG`, `KPM_REGO`, and `OCI_REG_PLAIN_HTTP`.
+ You can adjust the configuration of the OCI Registry by setting the three environment variables `KPM_REG`, `KPM_REGO`, and `OCI_REG_PLAIN_HTTP`.
- ```shell
- # set default registry
- export KPM_REG="ghcr.io"
- # set default repository
- export KPM_REPO="kcl-lang"
- # set support for 'http'
- export OCI_REG_PLAIN_HTTP=off
- ```
+ ```shell
+ # set default registry
+ export KPM_REG="ghcr.io"
+ # set default repository
+ export KPM_REPO="kcl-lang"
+ # set support for 'http'
+ export OCI_REG_PLAIN_HTTP=off
+ ```
- - By configuration file
+ - By configuration file
- The configuration file of the KCL package management tool is located at `$KCL_PKG_PATH/.kpm/config/kpm.json`, if the environment variable `KCL_PKG_PATH` is not set, it is saved by default in `$HOME/.kcl/kpm/.kpm/config/kpm.json`.
+ The configuration file of the KCL package management tool is located at `$KCL_PKG_PATH/.kpm/config/kpm.json`, if the environment variable `KCL_PKG_PATH` is not set, it is saved by default in `$HOME/.kcl/kpm/.kpm/config/kpm.json`.
- The default content of the configuration file is as follows:
+ The default content of the configuration file is as follows:
- ```json
- {
- "DefaultOciRegistry": "ghcr.io",
- "DefaultOciRepo": "kcl-lang",
- "DefaultOciPlainHttp": true
- }
- ```
+ ```json
+ {
+ "DefaultOciRegistry": "ghcr.io",
+ "DefaultOciRepo": "kcl-lang",
+ "DefaultOciPlainHttp": true
+ }
+ ```
diff --git a/versioned_docs/version-0.8/user_docs/guides/package-management/4-how-to/10-private_mod_repo.md b/versioned_docs/version-0.8/user_docs/guides/package-management/4-how-to/10-private_mod_repo.md
index 5a789b98..b1d004e5 100644
--- a/versioned_docs/version-0.8/user_docs/guides/package-management/4-how-to/10-private_mod_repo.md
+++ b/versioned_docs/version-0.8/user_docs/guides/package-management/4-how-to/10-private_mod_repo.md
@@ -18,48 +18,47 @@ The KCL package management tool supports saving and sharing KCL packages through
1. Login to the private OCI Registry using the `kcl registry login` command.
- More Details - [kcl registry login Login OCI Registry](https://www.kcl-lang.io/docs/tools/cli/package-management/command-reference/login)
+ More Details - [kcl registry login Login OCI Registry](https://www.kcl-lang.io/docs/tools/cli/package-management/command-reference/login)
2. Replace the OCI Registry used by the KCL package management tool. The KCL package management tool supports specifying the OCI registry used to download KCL packages in three ways.
- - Use the OCI Url to specify the OCI registry in the command line or `kcl.mod`.
+ - Use the OCI Url to specify the OCI registry in the command line or `kcl.mod`.
- You can specify the OCI Registry as `ghcr.io` by the following command.
+ You can specify the OCI Registry as `ghcr.io` by the following command.
- ```shell
- kcl mod add oci://ghcr.io/kcl-lang/helloworld --tag 0.1.0
- ```
+ ```shell
+ kcl mod add oci://ghcr.io/kcl-lang/helloworld --tag 0.1.0
+ ```
- Or add the following content to the `kcl.mod` file to specify the OCI Registry as `ghcr.io`.
+ Or add the following content to the `kcl.mod` file to specify the OCI Registry as `ghcr.io`.
- ```toml
- helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
- ```
+ ```toml
+ helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
+ ```
- - By environment variable
+ - By environment variable
- You can adjust the configuration of the OCI Registry by setting the three environment variables `KPM_REG`, `KPM_REGO`, and `OCI_REG_PLAIN_HTTP`.
+ You can adjust the configuration of the OCI Registry by setting the three environment variables `KPM_REG`, `KPM_REGO`, and `OCI_REG_PLAIN_HTTP`.
- ```shell
- # set default registry
- export KPM_REG="ghcr.io"
- # set default repository
- export KPM_REPO="kcl-lang"
- # set support for 'http'
- export OCI_REG_PLAIN_HTTP=off
- ```
+ ```shell
+ # set default registry
+ export KPM_REG="ghcr.io"
+ # set default repository
+ export KPM_REPO="kcl-lang"
+ # set support for 'http'
+ export OCI_REG_PLAIN_HTTP=off
+ ```
- - By configuration file
+ - By configuration file
- The configuration file of the KCL package management tool is located at `$KCL_PKG_PATH/.kpm/config/kpm.json`, if the environment variable `KCL_PKG_PATH` is not set, it is saved by default in `$HOME/.kcl/kpm/.kpm/config/kpm.json`.
+ The configuration file of the KCL package management tool is located at `$KCL_PKG_PATH/.kpm/config/kpm.json`, if the environment variable `KCL_PKG_PATH` is not set, it is saved by default in `$HOME/.kcl/kpm/.kpm/config/kpm.json`.
- The default content of the configuration file is as follows:
-
- ```json
- {
- "DefaultOciRegistry": "ghcr.io",
- "DefaultOciRepo": "kcl-lang",
- "DefaultOciPlainHttp": true
- }
- ```
+ The default content of the configuration file is as follows:
+ ```json
+ {
+ "DefaultOciRegistry": "ghcr.io",
+ "DefaultOciRepo": "kcl-lang",
+ "DefaultOciPlainHttp": true
+ }
+ ```
diff --git a/versioned_docs/version-0.9/reference/xlang-api/c-api.md b/versioned_docs/version-0.9/reference/xlang-api/c-api.md
index dea5cb25..04768efb 100644
--- a/versioned_docs/version-0.9/reference/xlang-api/c-api.md
+++ b/versioned_docs/version-0.9/reference/xlang-api/c-api.md
@@ -8,9 +8,9 @@ The [C API](https://github.com/kcl-lang/lib/tree/main/c) is in the development s
## Prerequisites
-+ Make
-+ C Compiler
-+ Cargo
+- Make
+- C Compiler
+- Cargo
## API Reference
diff --git a/versioned_docs/version-0.9/reference/xlang-api/cpp-api.md b/versioned_docs/version-0.9/reference/xlang-api/cpp-api.md
index a555b27f..32e8787f 100644
--- a/versioned_docs/version-0.9/reference/xlang-api/cpp-api.md
+++ b/versioned_docs/version-0.9/reference/xlang-api/cpp-api.md
@@ -8,9 +8,9 @@ The [C++ API](https://github.com/kcl-lang/lib/tree/main/cpp) is in the developme
## Prerequisites
-+ CMake >= 3.10
-+ C++ Compiler with C++17 Support
-+ Cargo
+- CMake >= 3.10
+- C++ Compiler with C++17 Support
+- Cargo
## Installation
@@ -22,7 +22,7 @@ You can use FetchContent to add KCL C++ Lib to your project.
FetchContent_Declare(
kcl-lib
GIT_REPOSITORY https://github.com/kcl-lang/lib.git
- GIT_TAG v0.9.1
+ GIT_TAG v0.9.1 # You can change the GitHub branch tag.
SOURCE_SUBDIR cpp
)
FetchContent_MakeAvailable(kcl-lib)
@@ -176,7 +176,7 @@ flask = { git = "https://github.com/kcl-lang/flask-demo-kcl-manifests", commit =
C++ Code
-```cpp
+```python
#include "kcl_lib.hpp"
#include
diff --git a/versioned_docs/version-0.9/reference/xlang-api/dotnet-api.md b/versioned_docs/version-0.9/reference/xlang-api/dotnet-api.md
index 12387547..50fdb70c 100644
--- a/versioned_docs/version-0.9/reference/xlang-api/dotnet-api.md
+++ b/versioned_docs/version-0.9/reference/xlang-api/dotnet-api.md
@@ -57,38 +57,6 @@ var result = new API().ExecProgram(execArgs);
-### ParseProgram
-
-Parse KCL program with entry files and return the AST JSON string.
-
-Example
-
-
-The content of `schema.k` is
-
-```python
-schema AppConfig:
- replicas: int
-
-app: AppConfig {
- replicas: 2
-}
-```
-
-C# Code
-
-```csharp
-using KclLib.API;
-
-var path = "schema.k"
-var args = new ParseProgram_Args();
-args.Paths.Add(path);
-var result = new API().ParseProgram(args);
-```
-
-
-
-
### ParseFile
Parse KCL single file to Module AST JSON string with import dependencies and parse errors.
diff --git a/versioned_docs/version-0.9/reference/xlang-api/go-api.md b/versioned_docs/version-0.9/reference/xlang-api/go-api.md
index 39f2777a..739bb18c 100644
--- a/versioned_docs/version-0.9/reference/xlang-api/go-api.md
+++ b/versioned_docs/version-0.9/reference/xlang-api/go-api.md
@@ -113,11 +113,23 @@ x1 = Person {
- [func Run](#func-run)
- [func RunFiles](#func-runfiles)
- [type KclType](#type-kcltype)
+ - [func GetSchemaType](#func-getschematype)
- [type ListDepFilesOption](#type-listdepfilesoption)
- [type ListDepsOptions](#type-listdepsoptions)
+ - [type ListOptionsArgs](#type-listoptionsargs)
+ - [type ListOptionsResult](#type-listoptionsresult)
+ - [func ListOptions](#func-listoptions)
+ - [type ListVariablesArgs](#type-listvariablesargs)
+ - [type ListVariablesResult](#type-listvariablesresult)
+ - [func ListVariables](#func-listvariables)
+ - [type LoadPackageArgs](#type-loadpackageargs)
+ - [type LoadPackageResult](#type-loadpackageresult)
+ - [func LoadPackage](#func-loadpackage)
- [type Option](#type-option)
+ - [func NewOption](#func-newoption)
- [func WithCode](#func-withcode)
- [func WithDisableNone](#func-withdisablenone)
+ - [func WithExternalPkgAndPath](#func-withexternalpkgandpath)
- [func WithExternalPkgs](#func-withexternalpkgs)
- [func WithFullTypePath](#func-withfulltypepath)
- [func WithIncludeSchemaTypePath](#func-withincludeschematypepath)
@@ -131,11 +143,19 @@ x1 = Person {
- [func WithShowHidden](#func-withshowhidden)
- [func WithSortKeys](#func-withsortkeys)
- [func WithWorkDir](#func-withworkdir)
+ - [type ParseProgramArgs](#type-parseprogramargs)
+ - [type ParseProgramResult](#type-parseprogramresult)
+ - [func ParseProgram](#func-parseprogram)
- [type TestCaseInfo](#type-testcaseinfo)
- [type TestOptions](#type-testoptions)
- [type TestResult](#type-testresult)
- [func Test](#func-test)
+ - [type UpdateDependenciesArgs](#type-updatedependenciesargs)
+ - [type UpdateDependenciesResult](#type-updatedependenciesresult)
+ - [func UpdateDependencies](#func-updatedependencies)
- [type ValidateOptions](#type-validateoptions)
+ - [type VersionResult](#type-versionresult)
+ - [func GetVersion](#func-getversion)
## Constants
@@ -145,7 +165,7 @@ KclvmAbiVersion is the current kclvm ABI version.
const KclvmAbiVersion = scripts.KclvmAbiVersion
```
-## func [FormatCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L143)
+## func [FormatCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L167)
```go
func FormatCode(code interface{}) ([]byte, error)
@@ -183,7 +203,7 @@ a = 1 + 2
-## func [FormatPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L155)
+## func [FormatPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L179)
```go
func FormatPath(path string) (changedPaths []string, err error)
@@ -218,7 +238,7 @@ func main() {
-## func [GetSchemaTypeMapping](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L237)
+## func [GetSchemaTypeMapping](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L258)
```go
func GetSchemaTypeMapping(filename string, src any, schemaName string) (map[string]*KclType, error)
@@ -244,7 +264,7 @@ schema_name: string
The schema name got, when the schema name is empty, all schemas are returned.
```
-## func [InitKclvmPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L61)
+## func [InitKclvmPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L75)
```go
func InitKclvmPath(kclvmRoot string)
@@ -252,7 +272,7 @@ func InitKclvmPath(kclvmRoot string)
InitKclvmPath init kclvm path.
-## func [InitKclvmRuntime](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L66)
+## func [InitKclvmRuntime](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L80)
```go
func InitKclvmRuntime(n int)
@@ -260,7 +280,7 @@ func InitKclvmRuntime(n int)
InitKclvmRuntime init kclvm process.
-## func [LintPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L175)
+## func [LintPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L199)
```go
func LintPath(paths []string) (results []string, err error)
@@ -305,7 +325,7 @@ Module 'a' imported but unused
-## func [ListDepFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L160)
+## func [ListDepFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L184)
```go
func ListDepFiles(workDir string, opt *ListDepFilesOption) (files []string, err error)
@@ -313,7 +333,7 @@ func ListDepFiles(workDir string, opt *ListDepFilesOption) (files []string, err
ListDepFiles return the depend files from the given path
-## func [ListDownStreamFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L170)
+## func [ListDownStreamFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L194)
```go
func ListDownStreamFiles(workDir string, opt *ListDepsOptions) ([]string, error)
@@ -321,7 +341,7 @@ func ListDownStreamFiles(workDir string, opt *ListDepsOptions) ([]string, error)
ListDownStreamFiles return a list of downstream depend files from the given changed path list.
-## func [ListUpStreamFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L165)
+## func [ListUpStreamFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L189)
```go
func ListUpStreamFiles(workDir string, opt *ListDepsOptions) (deps []string, err error)
@@ -329,22 +349,15 @@ func ListUpStreamFiles(workDir string, opt *ListDepsOptions) (deps []string, err
ListUpStreamFiles return a list of upstream depend files from the given path list
-## func [OverrideFile](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L187)
+## func [OverrideFile](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L208)
```go
func OverrideFile(file string, specs, importPaths []string) (bool, error)
```
-OverrideFile rewrites a file with override spec file: string. The File that need to be overridden specs: \[\]string. List of specs that need to be overridden.
+OverrideFile rewrites a file with override spec file: string. The File that need to be overridden specs: \[\]string. List of specs that need to be overridden. importPaths. List of import statements that need to be added. See https://www.kcl-lang.io/docs/user_docs/guides/automation for more override spec guide.
-```
-Each spec string satisfies the form: := or :-
-When the pkgpath is '__main__', it can be omitted.
-```
-
-importPaths. List of import statements that need to be added
-
-## func [Validate](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L198)
+## func [Validate](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L219)
```go
func Validate(dataFile, schemaFile string, opts *ValidateOptions) (ok bool, err error)
@@ -352,7 +365,7 @@ func Validate(dataFile, schemaFile string, opts *ValidateOptions) (ok bool, err
Validate validates the given data file against the specified schema file with the provided options.
-## func [ValidateCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L192)
+## func [ValidateCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L213)
```go
func ValidateCode(data, code string, opts *ValidateOptions) (ok bool, err error)
@@ -360,7 +373,7 @@ func ValidateCode(data, code string, opts *ValidateOptions) (ok bool, err error)
ValidateCode validate data string match code string
-## type [KCLResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L54)
+## type [KCLResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L57)
```go
type KCLResult = kcl.KCLResult
@@ -409,7 +422,7 @@ x1.age: 101
-Example ('et_struct)
+Example (Get)
```go
@@ -454,13 +467,13 @@ person: {Name:kcl Age:101}
-## type [KCLResultList](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L55)
+## type [KCLResultList](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L58)
```go
type KCLResultList = kcl.KCLResultList
```
-### func [MustRun](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L71)
+### func [MustRun](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L85)
```go
func MustRun(path string, opts ...Option) *KCLResultList
@@ -587,7 +600,7 @@ func main() {
-### func [Run](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L76)
+### func [Run](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L90)
```go
func Run(path string, opts ...Option) (*KCLResultList, error)
@@ -595,7 +608,15 @@ func Run(path string, opts ...Option) (*KCLResultList, error)
Run evaluates the KCL program with path and opts, then returns the object list.
-Example (Get Field)
+### func [RunFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L95)
+
+```go
+func RunFiles(paths []string, opts ...Option) (*KCLResultList, error)
+```
+
+RunFiles evaluates the KCL program with multi file path and opts, then returns the object list.
+
+Example
```go
@@ -603,43 +624,134 @@ package main
import (
"fmt"
- "log"
kcl "kcl-lang.io/kcl-go"
)
-func assert(v bool, a ...interface{}) {
- if !v {
- a = append([]interface{}{"assert failed"}, a...)
- log.Panic(a...)
- }
+func main() {
+ result, _ := kcl.RunFiles([]string{"./testdata/app0/kcl.yaml"})
+ fmt.Println(result.First().YAMLString())
}
+```
-func main() {
- // run kcl.yaml
- x, err := kcl.Run("./testdata/app0/kcl.yaml")
- assert(err == nil, err)
+
+
+
+## type [KclType](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L60)
+
+```go
+type KclType = kcl.KclType
+```
+
+### func [GetSchemaType](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L241)
+
+```go
+func GetSchemaType(filename string, src any, schemaName string) ([]*KclType, error)
+```
+
+GetSchemaType returns schema types from a kcl file or code.
+
+file: string
- // print deploy_topology[1].zone
- fmt.Println(x.First().Get("deploy_topology.1.zone"))
+```
+The kcl filename
+```
+
+code: string
+
+```
+The kcl code string
+```
+
+schema_name: string
+
+```
+The schema name got, when the schema name is empty, all schemas are returned.
+```
+
+## type [ListDepFilesOption](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L52)
+
+```go
+type ListDepFilesOption = list.Option
+```
+
+## type [ListDepsOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L51)
+
+```go
+type ListDepsOptions = list.DepOptions
+```
+
+## type [ListOptionsArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L68)
+
+```go
+type ListOptionsArgs = loader.ListOptionsArgs
+```
+
+## type [ListOptionsResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L69)
+
+```go
+type ListOptionsResult = loader.ListOptionsResult
+```
+
+### func [ListOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L280)
+
+```go
+func ListOptions(args *ListOptionsArgs) (*ListOptionsResult, error)
+```
+
+ListOptions provides users with the ability to parse kcl program and get all option calling information.
+
+Example
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+)
+
+func main() {
+ result, err := kcl.ListOptions(&kcl.ListOptionsArgs{
+ Paths: []string{"testdata/option/main.k"},
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(result)
}
```
```
-R000A
+options:{name:"key1"} options:{name:"key2" required:true} options:{name:"metadata-key"}
```
-### func [RunFiles](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L81)
+## type [ListVariablesArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L66)
```go
-func RunFiles(paths []string, opts ...Option) (*KCLResultList, error)
+type ListVariablesArgs = loader.ListVariablesArgs
```
-RunFiles evaluates the KCL program with multi file path and opts, then returns the object list.
+## type [ListVariablesResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L67)
+
+```go
+type ListVariablesResult = loader.ListVariablesResult
+```
+
+### func [ListVariables](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L274)
+
+```go
+func ListVariables(args *ListVariablesArgs) (*ListVariablesResult, error)
+```
+
+ListVariables provides users with the ability to parse KCL program and get all variables by specs.
Example
@@ -649,44 +761,95 @@ package main
import (
"fmt"
+ "log"
kcl "kcl-lang.io/kcl-go"
)
func main() {
- result, _ := kcl.RunFiles([]string{"./testdata/app0/kcl.yaml"})
- fmt.Println(result.First().YAMLString())
+ result, err := kcl.ListVariables(&kcl.ListVariablesArgs{
+ Files: []string{"testdata/main.k"},
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(result)
+
}
```
+```
+variables:{key:"age" value:{variables:{value:"2" op_sym:"="}}} variables:{key:"four" value:{variables:{value:"4" op_sym:"="}}} variables:{key:"name" value:{variables:{value:"\"kcl-go\"" op_sym:"="}}} variables:{key:"x0" value:{variables:{value:"Person {}" type_name:"Person" op_sym:"="}}} variables:{key:"x1" value:{variables:{value:"Person {age = 101}" type_name:"Person" op_sym:"=" dict_entries:{key:"age" value:{value:"101" op_sym:"="}}}}}
+```
+
-## type [KclType](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L57)
+## type [LoadPackageArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L64)
```go
-type KclType = kcl.KclType
+type LoadPackageArgs = loader.LoadPackageArgs
```
-## type [ListDepFilesOption](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L49)
+## type [LoadPackageResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L65)
```go
-type ListDepFilesOption = list.Option
+type LoadPackageResult = loader.LoadPackageResult
```
-## type [ListDepsOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L48)
+### func [LoadPackage](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L269)
```go
-type ListDepsOptions = list.DepOptions
+func LoadPackage(args *LoadPackageArgs) (*LoadPackageResult, error)
```
-## type [Option](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L47)
+LoadPackage provides users with the ability to parse KCL program and semantic model information including symbols, types, definitions, etc.
+
+Example
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+)
+
+func main() {
+ result, err := kcl.LoadPackage(&kcl.LoadPackageArgs{
+ ParseArgs: &kcl.ParseProgramArgs{
+ Paths: []string{"testdata/main.k"},
+ },
+ ResolveAst: true,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(result)
+}
+```
+
+
+
+
+## type [Option](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L50)
```go
type Option = kcl.Option
```
-### func [WithCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L86)
+### func [NewOption](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L100)
+
+```go
+func NewOption() *Option
+```
+
+NewOption returns a new Option.
+
+### func [WithCode](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L105)
```go
func WithCode(codes ...string) Option
@@ -694,7 +857,7 @@ func WithCode(codes ...string) Option
WithCode returns a Option which hold a kcl source code list.
-### func [WithDisableNone](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L110)
+### func [WithDisableNone](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L134)
```go
func WithDisableNone(disableNone bool) Option
@@ -702,7 +865,15 @@ func WithDisableNone(disableNone bool) Option
WithDisableNone returns a Option which hold a disable none switch.
-### func [WithExternalPkgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L89)
+### func [WithExternalPkgAndPath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L111)
+
+```go
+func WithExternalPkgAndPath(name, path string) Option
+```
+
+WithExternalPkgAndPath returns a Option which hold a external package.
+
+### func [WithExternalPkgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L108)
```go
func WithExternalPkgs(externalPkgs ...string) Option
@@ -710,7 +881,7 @@ func WithExternalPkgs(externalPkgs ...string) Option
WithExternalPkgs returns a Option which hold a external package list.
-### func [WithFullTypePath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L118)
+### func [WithFullTypePath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L142)
```go
func WithFullTypePath(fullTypePath bool) Option
@@ -718,7 +889,7 @@ func WithFullTypePath(fullTypePath bool) Option
WithFullTypePath returns a Option which hold a include full type string in the \`\_type\` attribute.
-### func [WithIncludeSchemaTypePath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L113)
+### func [WithIncludeSchemaTypePath](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L137)
```go
func WithIncludeSchemaTypePath(includeSchemaTypePath bool) Option
@@ -726,7 +897,7 @@ func WithIncludeSchemaTypePath(includeSchemaTypePath bool) Option
WithIncludeSchemaTypePath returns a Option which hold a include schema type path switch.
-### func [WithKFilenames](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L92)
+### func [WithKFilenames](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L116)
```go
func WithKFilenames(filenames ...string) Option
@@ -734,7 +905,7 @@ func WithKFilenames(filenames ...string) Option
WithKFilenames returns a Option which hold a filenames list.
-### func [WithLogger](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L138)
+### func [WithLogger](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L162)
```go
func WithLogger(l io.Writer) Option
@@ -742,7 +913,7 @@ func WithLogger(l io.Writer) Option
WithLogger returns a Option which hold a logger.
-### func [WithOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L95)
+### func [WithOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L119)
```go
func WithOptions(key_value_list ...string) Option
@@ -788,7 +959,7 @@ name: kcl
-### func [WithOverrides](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L98)
+### func [WithOverrides](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L122)
```go
func WithOverrides(override_list ...string) Option
@@ -796,7 +967,7 @@ func WithOverrides(override_list ...string) Option
WithOverrides returns a Option which hold a override list.
-### func [WithPrintOverridesAST](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L123)
+### func [WithPrintOverridesAST](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L147)
```go
func WithPrintOverridesAST(printOverridesAST bool) Option
@@ -804,7 +975,7 @@ func WithPrintOverridesAST(printOverridesAST bool) Option
WithPrintOverridesAST returns a Option which hold a printOverridesAST switch.
-### func [WithSelectors](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L101)
+### func [WithSelectors](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L125)
```go
func WithSelectors(selectors ...string) Option
@@ -812,7 +983,7 @@ func WithSelectors(selectors ...string) Option
WithSelectors returns a Option which hold a path selector list.
-### func [WithSettings](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L104)
+### func [WithSettings](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L128)
```go
func WithSettings(filename string) Option
@@ -820,7 +991,7 @@ func WithSettings(filename string) Option
WithSettings returns a Option which hold a settings file.
-### func [WithShowHidden](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L133)
+### func [WithShowHidden](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L157)
```go
func WithShowHidden(showHidden bool) Option
@@ -828,7 +999,7 @@ func WithShowHidden(showHidden bool) Option
WithShowHidden returns a Option which holds a showHidden switch.
-### func [WithSortKeys](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L128)
+### func [WithSortKeys](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L152)
```go
func WithSortKeys(sortKeys bool) Option
@@ -836,7 +1007,7 @@ func WithSortKeys(sortKeys bool) Option
WithSortKeys returns a Option which holds a sortKeys switch.
-### func [WithWorkDir](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L107)
+### func [WithWorkDir](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L131)
```go
func WithWorkDir(workDir string) Option
@@ -844,25 +1015,72 @@ func WithWorkDir(workDir string) Option
WithWorkDir returns a Option which hold a work dir.
-## type [TestCaseInfo](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L52)
+## type [ParseProgramArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L70)
+
+```go
+type ParseProgramArgs = parser.ParseProgramArgs
+```
+
+## type [ParseProgramResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L71)
+
+```go
+type ParseProgramResult = parser.ParseProgramResult
+```
+
+### func [ParseProgram](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L263)
+
+```go
+func ParseProgram(args *ParseProgramArgs) (*ParseProgramResult, error)
+```
+
+Parse KCL program with entry files and return the AST JSON string.
+
+Example
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+)
+
+func main() {
+ result, err := kcl.ParseProgram(&kcl.ParseProgramArgs{
+ Paths: []string{"testdata/main.k"},
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(result)
+}
+```
+
+
+
+
+## type [TestCaseInfo](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L55)
```go
type TestCaseInfo = testing.TestCaseInfo
```
-## type [TestOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L51)
+## type [TestOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L54)
```go
type TestOptions = testing.TestOptions
```
-## type [TestResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L53)
+## type [TestResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L56)
```go
type TestResult = testing.TestResult
```
-### func [Test](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L203)
+### func [Test](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L224)
```go
func Test(testOpts *TestOptions, opts ...Option) (TestResult, error)
@@ -870,8 +1088,136 @@ func Test(testOpts *TestOptions, opts ...Option) (TestResult, error)
Test calls the test tool to run uni tests in packages.
-## type [ValidateOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L50)
+## type [UpdateDependenciesArgs](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L62)
+
+```go
+type UpdateDependenciesArgs = module.UpdateDependenciesArgs
+```
+
+## type [UpdateDependenciesResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L63)
+
+```go
+type UpdateDependenciesResult = module.UpdateDependenciesResult
+```
+
+### func [UpdateDependencies](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L285)
+
+```go
+func UpdateDependencies(args *UpdateDependenciesArgs) (*UpdateDependenciesResult, error)
+```
+
+Download and update dependencies defined in the kcl.mod file and return the external package name and location list.
+
+Example
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+ "kcl-lang.io/kcl-go/pkg/spec/gpyrpc"
+)
+
+func main() {
+ // [package]
+ // name = "mod_update"
+ // edition = "0.0.1"
+ // version = "0.0.1"
+ //
+ // [dependencies]
+ // helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
+ // flask = { git = "https://github.com/kcl-lang/flask-demo-kcl-manifests", commit = "ade147b" }
+
+ result, err := kcl.UpdateDependencies(&gpyrpc.UpdateDependencies_Args{
+ ManifestPath: "testdata/update_dependencies",
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ fmt.Println(result)
+}
+```
+
+
+
+
+Example (Exec Program)
+
+
+```go
+package main
+
+import (
+ "fmt"
+ "log"
+
+ kcl "kcl-lang.io/kcl-go"
+ "kcl-lang.io/kcl-go/pkg/spec/gpyrpc"
+)
+
+func main() {
+ // [package]
+ // name = "mod_update"
+ // edition = "0.0.1"
+ // version = "0.0.1"
+ //
+ // [dependencies]
+ // helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
+ // flask = { git = "https://github.com/kcl-lang/flask-demo-kcl-manifests", commit = "ade147b" }
+
+ result, err := kcl.UpdateDependencies(&gpyrpc.UpdateDependencies_Args{
+ ManifestPath: "testdata/update_dependencies",
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ // import helloworld
+ // import flask
+ // a = helloworld.The_first_kcl_program
+ // fmt.Println(result.ExternalPkgs)
+
+ opt := kcl.NewOption()
+ opt.ExternalPkgs = result.ExternalPkgs
+
+ runResult, err := kcl.Run("testdata/update_dependencies/main.k", *opt)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ fmt.Println(runResult.GetRawYamlResult())
+
+}
+```
+
+```
+a: Hello World!
+```
+
+
+
+
+## type [ValidateOptions](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L53)
```go
type ValidateOptions = validate.ValidateOptions
```
+
+## type [VersionResult](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L61)
+
+```go
+type VersionResult = kcl.VersionResult
+```
+
+### func [GetVersion](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L290)
+
+```go
+func GetVersion() (*VersionResult, error)
+```
+
+GetVersion returns the KCL service version information.
diff --git a/versioned_docs/version-0.9/reference/xlang-api/java-api.md b/versioned_docs/version-0.9/reference/xlang-api/java-api.md
index fee90323..d72d32a9 100644
--- a/versioned_docs/version-0.9/reference/xlang-api/java-api.md
+++ b/versioned_docs/version-0.9/reference/xlang-api/java-api.md
@@ -84,42 +84,6 @@ ExecProgram_Result result = apiInstance.execProgram(args);
-### parseProgram
-
-Parse KCL program with entry files and return the AST JSON string.
-
-Example
-
-
-The content of `schema.k` is
-
-```python
-schema AppConfig:
- replicas: int
-
-app: AppConfig {
- replicas: 2
-}
-```
-
-Java Code
-
-```java
-import com.kcl.api.*;
-import com.kcl.ast.*;
-import com.kcl.util.JsonUtil;
-
-API api = new API();
-ParseProgram_Result result = api.parseProgram(
- ParseProgram_Args.newBuilder().addPaths("schema.k").build()
-);
-System.out.println(result.getAstJson());
-Program program = JsonUtil.deserializeProgram(result.getAstJson());
-```
-
-
-
-
### parseFile
Parse KCL single file to Module AST JSON string with import dependencies and parse errors.
diff --git a/versioned_docs/version-0.9/reference/xlang-api/nodejs-api.md b/versioned_docs/version-0.9/reference/xlang-api/nodejs-api.md
index 400f39f4..9c507d00 100644
--- a/versioned_docs/version-0.9/reference/xlang-api/nodejs-api.md
+++ b/versioned_docs/version-0.9/reference/xlang-api/nodejs-api.md
@@ -72,35 +72,6 @@ try {
-### parseProgram
-
-Parse KCL program with entry files and return the AST JSON string.
-
-Example
-
-
-The content of `schema.k` is
-
-```python
-schema AppConfig:
- replicas: int
-
-app: AppConfig {
- replicas: 2
-}
-```
-
-Node.js Code
-
-```ts
-import { parseProgram, ParseProgramArgs } from "kcl-lib";
-
-const result = parseProgram(new ParseProgramArgs(["schema.k"]));
-```
-
-
-
-
### parseFile
Parse KCL single file to Module AST JSON string with import dependencies and parse errors.
@@ -296,7 +267,7 @@ Node.js Code
import { overrideFile, OverrideFileArgs } from "kcl-lib";
const result = overrideFile(
- new OverrideFileArgs("main.k", ["app.replicas=4"], [])
+ new OverrideFileArgs("main.k", ["app.replicas=4"], []),
);
```
@@ -407,7 +378,7 @@ schema Person:
`;
const data = '{"name": "Alice", "age": 10}';
const result = validateCode(
- new ValidateCodeArgs(undefined, data, undefined, code)
+ new ValidateCodeArgs(undefined, data, undefined, code),
);
```
@@ -456,7 +427,7 @@ const args = RenameCodeArgs(
"/mock/path",
"a",
{ "/mock/path/main.k": "a = 1\nb = a" },
- "a2"
+ "a2",
);
const result = renameCode(args);
```
@@ -591,8 +562,8 @@ const execResult = execProgram(
undefined,
undefined,
undefined,
- result.externalPkgs
- )
+ result.externalPkgs,
+ ),
);
```
diff --git a/versioned_docs/version-0.9/reference/xlang-api/python-api.md b/versioned_docs/version-0.9/reference/xlang-api/python-api.md
index 49e3bfdf..589f73c3 100644
--- a/versioned_docs/version-0.9/reference/xlang-api/python-api.md
+++ b/versioned_docs/version-0.9/reference/xlang-api/python-api.md
@@ -75,26 +75,6 @@ except Exception as err:
-### parse_program
-
-Parse KCL program with entry files and return the AST JSON string.
-
-Example
-
-
-```python
-import kcl_lib.api as api
-
-args = api.ParseProgram_Args(paths=["schema.k"])
-api = api.API()
-result = api.parse_program(args)
-assert len(result.paths) == 1
-assert len(result.errors) == 0
-```
-
-
-
-
### parse_file
Parse KCL single file to Module AST JSON string with import dependencies and parse errors.
@@ -118,10 +98,9 @@ Python Code
```python
import kcl_lib.api as api
-args = api.ParseProgram_Args(paths=[TEST_FILE])
+args = api.ParseFile_Args(path=TEST_FILE)
api = api.API()
-result = api.parse_program(args)
-assert len(result.paths) == 1
+result = api.parse_file(args)
assert len(result.errors) == 0
```
diff --git a/versioned_docs/version-0.9/reference/xlang-api/rest-api.md b/versioned_docs/version-0.9/reference/xlang-api/rest-api.md
index 7d0cf97e..b9a9ab73 100644
--- a/versioned_docs/version-0.9/reference/xlang-api/rest-api.md
+++ b/versioned_docs/version-0.9/reference/xlang-api/rest-api.md
@@ -113,7 +113,7 @@ $ curl -X POST \
Cross-language APIs defined via Protobuf([https://github.com/kcl-lang/kcl/blob/main/kclvm/spec/gpyrpc/gpyrpc.proto](https://github.com/kcl-lang/kcl/blob/main/kclvm/spec/gpyrpc/gpyrpc.proto)):
-```protobuf
+````protobuf
// Copyright The KCL Authors. All rights reserved.
//
// This file defines the request parameters and return structure of the KCL RPC server.
@@ -734,7 +734,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -776,7 +776,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -805,7 +805,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -838,7 +838,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -867,7 +867,7 @@ service KclvmService {
///
/// # Examples
///
- ///
+ ///
/// // Request
/// {
/// "jsonrpc": "2.0",
@@ -1424,7 +1424,7 @@ message KeyValuePair {
// ---------------------------------------------------------------------------------
// Rename API
-// Find all the occurrences of the target symbol and rename them.
+// Find all the occurrences of the target symbol and rename them.
// This API will rewrite files if they contain symbols to be renamed.
// ---------------------------------------------------------------------------------
@@ -1587,4 +1587,4 @@ message Example {
// ----------------------------------------------------------------------------
// END
// ----------------------------------------------------------------------------
-```
+````
diff --git a/versioned_docs/version-0.9/reference/xlang-api/wasm-api.md b/versioned_docs/version-0.9/reference/xlang-api/wasm-api.md
index 1fd3e308..bb5301a7 100644
--- a/versioned_docs/version-0.9/reference/xlang-api/wasm-api.md
+++ b/versioned_docs/version-0.9/reference/xlang-api/wasm-api.md
@@ -86,7 +86,7 @@ a: 1
In Go, we use `wasmtime` as an example, and of course, you can also use other runtime that supports WASI to accomplish this.
-Write the code, and the code of package `github.com/kcl-lang/wasm-lib/pkg/module` can be found [here](https://github.com/kcl-lang/lib/blob/main/wasm/examples/go/pkg/module/module.go)
+Write the code, and the code of package `github.com/kcl-lang/wasm-lib/pkg/module` can be found [here](https://github.com/kcl-lang/lib/blob/main/wasm/examples/go/pkg/module/module.go)
```go
package main
diff --git a/versioned_docs/version-0.9/tools/cli/kcl/test.md b/versioned_docs/version-0.9/tools/cli/kcl/test.md
index 55330c3a..e5e9bdbf 100644
--- a/versioned_docs/version-0.9/tools/cli/kcl/test.md
+++ b/versioned_docs/version-0.9/tools/cli/kcl/test.md
@@ -128,7 +128,7 @@ import runtime
test_person_age_check_error_message = lambda {
msg = runtime.catch(lambda {
a = Person {age = 123}
- })
+ })
assert msg == "age must be in [0, 120]"
}
```
diff --git a/versioned_docs/version-0.9/user_docs/guides/package-management/4-how-to/10-private_mod_repo.md b/versioned_docs/version-0.9/user_docs/guides/package-management/4-how-to/10-private_mod_repo.md
index 5a789b98..b1d004e5 100644
--- a/versioned_docs/version-0.9/user_docs/guides/package-management/4-how-to/10-private_mod_repo.md
+++ b/versioned_docs/version-0.9/user_docs/guides/package-management/4-how-to/10-private_mod_repo.md
@@ -18,48 +18,47 @@ The KCL package management tool supports saving and sharing KCL packages through
1. Login to the private OCI Registry using the `kcl registry login` command.
- More Details - [kcl registry login Login OCI Registry](https://www.kcl-lang.io/docs/tools/cli/package-management/command-reference/login)
+ More Details - [kcl registry login Login OCI Registry](https://www.kcl-lang.io/docs/tools/cli/package-management/command-reference/login)
2. Replace the OCI Registry used by the KCL package management tool. The KCL package management tool supports specifying the OCI registry used to download KCL packages in three ways.
- - Use the OCI Url to specify the OCI registry in the command line or `kcl.mod`.
+ - Use the OCI Url to specify the OCI registry in the command line or `kcl.mod`.
- You can specify the OCI Registry as `ghcr.io` by the following command.
+ You can specify the OCI Registry as `ghcr.io` by the following command.
- ```shell
- kcl mod add oci://ghcr.io/kcl-lang/helloworld --tag 0.1.0
- ```
+ ```shell
+ kcl mod add oci://ghcr.io/kcl-lang/helloworld --tag 0.1.0
+ ```
- Or add the following content to the `kcl.mod` file to specify the OCI Registry as `ghcr.io`.
+ Or add the following content to the `kcl.mod` file to specify the OCI Registry as `ghcr.io`.
- ```toml
- helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
- ```
+ ```toml
+ helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.0" }
+ ```
- - By environment variable
+ - By environment variable
- You can adjust the configuration of the OCI Registry by setting the three environment variables `KPM_REG`, `KPM_REGO`, and `OCI_REG_PLAIN_HTTP`.
+ You can adjust the configuration of the OCI Registry by setting the three environment variables `KPM_REG`, `KPM_REGO`, and `OCI_REG_PLAIN_HTTP`.
- ```shell
- # set default registry
- export KPM_REG="ghcr.io"
- # set default repository
- export KPM_REPO="kcl-lang"
- # set support for 'http'
- export OCI_REG_PLAIN_HTTP=off
- ```
+ ```shell
+ # set default registry
+ export KPM_REG="ghcr.io"
+ # set default repository
+ export KPM_REPO="kcl-lang"
+ # set support for 'http'
+ export OCI_REG_PLAIN_HTTP=off
+ ```
- - By configuration file
+ - By configuration file
- The configuration file of the KCL package management tool is located at `$KCL_PKG_PATH/.kpm/config/kpm.json`, if the environment variable `KCL_PKG_PATH` is not set, it is saved by default in `$HOME/.kcl/kpm/.kpm/config/kpm.json`.
+ The configuration file of the KCL package management tool is located at `$KCL_PKG_PATH/.kpm/config/kpm.json`, if the environment variable `KCL_PKG_PATH` is not set, it is saved by default in `$HOME/.kcl/kpm/.kpm/config/kpm.json`.
- The default content of the configuration file is as follows:
-
- ```json
- {
- "DefaultOciRegistry": "ghcr.io",
- "DefaultOciRepo": "kcl-lang",
- "DefaultOciPlainHttp": true
- }
- ```
+ The default content of the configuration file is as follows:
+ ```json
+ {
+ "DefaultOciRegistry": "ghcr.io",
+ "DefaultOciRepo": "kcl-lang",
+ "DefaultOciPlainHttp": true
+ }
+ ```