Skip to content

docs: update override and multiple SDK documents in 0.9 #379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions docs/reference/lang/tour.md
Original file line number Diff line number Diff line change
Expand Up @@ -3249,17 +3249,16 @@ kcl main.k -O override_spec

- `override_spec` represents a unified representation of the configuration model fields and values that need to be modified

```txt
override_spec: [[pkgpath] ":"] identifier ("=" value | "-")
```bash
override_spec: identifier (("=" | ":" | "+=") value | "-")
```

- `pkgpath`: Indicates the path of the package whose identifier needs to be modified, usually in the form of `a.b.c`. For the main package, `pkgpath` is expressed as `__main__`, which can be omitted. If omitted, it means the main package.
- `identifier`: Indicates the identifier that needs to modify the configuration, usually in the form of `a.b.c`.
- `value`: Indicates the value of the configuration that needs to be modified, which can be any legal KCL expression, such as number/string literal value, list/dict/schema expression, etc.
- `=`: means to modify the value of identifier.
- `identifier` indicates the identifier that needs to modify the configuration, usually in the form of `a.b.c` or `a["dot.key"].c`
- `value` indicates the value of the configuration that needs to be modified, which can be any legal KCL expression, such as number/string literal value, list/dict/schema expression, etc.
- `=`, `:` and `+=` denotes modifying of the value of the identifier with the corresponding attribute operator.
- When the identifier exists, modify the value of the existing identifier to value.
- When identifier does not exist, add the identifier attribute and set its value to value.
- `-`: means to delete the identifier attribute.
- `-` denotes deleting of the identifier.
- When the identifier exists, delete it directly.
- When the identifier does not exist, no modification is made to the configuration.

Expand Down
115 changes: 44 additions & 71 deletions docs/reference/xlang-api/go-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,50 +93,49 @@ 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)
- [func GetSchemaType](#func-getschematype)
- [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)
- [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)

## Constants

Expand Down Expand Up @@ -222,7 +221,7 @@ func main() {
## func [GetSchemaTypeMapping](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L237)

```go
func GetSchemaTypeMapping(file, code, schemaName string) (map[string]*KclType, error)
func GetSchemaTypeMapping(filename string, src any, schemaName string) (map[string]*KclType, error)
```

GetSchemaTypeMapping returns a \<schemaName\>:\<schemaType\> mapping of schema types from a kcl file or code.
Expand Down Expand Up @@ -669,32 +668,6 @@ func main() {
type KclType = kcl.KclType
```

### func [GetSchemaType](https://github.com/kcl-lang/kcl-go/blob/main/kclvm.go#L220)

```go
func GetSchemaType(file, code, schemaName string) ([]*KclType, error)
```

GetSchemaType returns schema types from a kcl file or code.

file: string

```
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#L49)

```go
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/xlang-api/java-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This way you'll be able to import the above dependency to use the SDK.
<dependency>
<groupId>com.kcl</groupId>
<artifactId>kcl-lib</artifactId>
<version>0.8.6</version>
<version>0.9.0-SNAPSHOT</version>
</dependency>
```

Expand Down
71 changes: 37 additions & 34 deletions docs/reference/xlang-api/rest-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,25 +123,17 @@ syntax = "proto3";
package gpyrpc;

// kcl main.k -E pkg_name=pkg_path
message CmdExternalPkgSpec {
message ExternalPkg {
string pkg_name = 1;
string pkg_path = 2;
}

// kcl main.k -D name=value
message CmdArgSpec {
message Argument {
string name = 1;
string value = 2;
}

// kcl main.k -O pkgpath:path.to.field=field_value
message CmdOverrideSpec {
string pkgpath = 1;
string field_path = 2;
string field_value = 3;
string action = 4;
}

// ----------------------------------------------------------------------------
// Error types
// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -186,8 +178,6 @@ service KclvmService {
rpc LintPath(LintPath_Args) returns(LintPath_Result);
rpc OverrideFile(OverrideFile_Args) returns (OverrideFile_Result);

rpc GetSchemaType(GetSchemaType_Args) returns(GetSchemaType_Result);
rpc GetFullSchemaType(GetFullSchemaType_Args) returns(GetSchemaType_Result);
rpc GetSchemaTypeMapping(GetSchemaTypeMapping_Args) returns(GetSchemaTypeMapping_Result);
rpc ValidateCode(ValidateCode_Args) returns(ValidateCode_Result);

Expand All @@ -198,6 +188,8 @@ service KclvmService {
rpc RenameCode(RenameCode_Args) returns(RenameCode_Result);

rpc Test(Test_Args) returns (Test_Result);

rpc UpdateDependencies(UpdateDependencies_Args) returns (UpdateDependencies_Result);
}

message Ping_Args {
Expand All @@ -217,7 +209,7 @@ message ListMethod_Result {
message ParseFile_Args {
string path = 1;
string source = 2;
repeated CmdExternalPkgSpec external_pkgs = 3; // External packages path
repeated ExternalPkg external_pkgs = 3; // External packages path
}

message ParseFile_Result {
Expand All @@ -229,7 +221,7 @@ message ParseFile_Result {
message ParseProgram_Args {
repeated string paths = 1;
repeated string sources = 2;
repeated CmdExternalPkgSpec external_pkgs = 3; // External packages path
repeated ExternalPkg external_pkgs = 3; // External packages path
}

message ParseProgram_Result {
Expand Down Expand Up @@ -304,9 +296,9 @@ message ExecProgram_Args {

repeated string k_filename_list = 2;
repeated string k_code_list = 3;

repeated CmdArgSpec args = 4;
repeated CmdOverrideSpec overrides = 5;
repeated Argument args = 4;
repeated string overrides = 5;

bool disable_yaml_result = 6;

Expand All @@ -327,7 +319,7 @@ message ExecProgram_Args {
bool sort_keys = 12;

// -E --external : external packages path
repeated CmdExternalPkgSpec external_pkgs = 13;
repeated ExternalPkg external_pkgs = 13;

// Whether including schema type in JSON/YAML result
bool include_schema_type_path = 14;
Expand Down Expand Up @@ -405,6 +397,7 @@ message OverrideFile_Args {

message OverrideFile_Result {
bool result = 1;
repeated Error parse_errors = 2;
}

message ListVariables_Args {
Expand All @@ -414,31 +407,26 @@ message ListVariables_Args {

message ListVariables_Result {
map<string, Variable> variables = 1;
repeated string unsupported_codes = 2;
repeated string unsupported_codes = 2;
repeated Error parse_errors = 3;
}

message Variable {
string value = 1;
string type_name = 2;
string op_sym = 3;
repeated Variable list_items = 4;
repeated MapEntry dict_entries = 5;
}

message GetFullSchemaType_Args {
ExecProgram_Args exec_args = 1;
string schema_name = 2;
}

message GetSchemaType_Args {
string file = 1;
string code = 2;
string schema_name = 3;
}
message GetSchemaType_Result {
repeated KclType schema_type_list = 1;
message MapEntry {
string key = 1;
Variable value = 2;
}

message GetSchemaTypeMapping_Args {
string file = 1;
string code = 2;
string schema_name = 3;
ExecProgram_Args exec_args = 1;
string schema_name = 2;
}
message GetSchemaTypeMapping_Result {
map<string, KclType> schema_type_mapping = 1;
Expand Down Expand Up @@ -568,6 +556,20 @@ message TestCaseInfo {
string log_message = 4;
}

// ---------------------------------------------------------------------------------
// UpdateDependencies API
// Download and update dependencies defined in the kcl.mod file
// ---------------------------------------------------------------------------------

message UpdateDependencies_Args {
string manifest_path = 1;
bool vendor = 2;
}

message UpdateDependencies_Result {
repeated ExternalPkg external_pkgs = 3;
}

// ----------------------------------------------------------------------------
// KCL Type Structure
// ----------------------------------------------------------------------------
Expand All @@ -593,6 +595,7 @@ message KclType {
string pkg_path = 13; // `pkg_path` represents the path name of the package where the attribute is located.
string description = 14; // `description` represents the document of the attribute.
map<string, Example> examples = 15; // A map object to hold examples, the key is the example name.
KclType base_schema = 16; // contains referenced by info for schema
}

message Decorator {
Expand Down
7 changes: 7 additions & 0 deletions docs/reference/xlang-api/rust-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,10 @@ fn main() -> Result<()> {
Ok(())
}
```

More Rust APIs can be found [here](https://github.com/kcl-lang/kcl). If you want to use the sub crate of KCL Rust core, you can run the following command.

```shell
# Take the kclvm-runtime as an example.
cargo add --git https://github.com/kcl-lang/kcl kclvm-runtime
```
9 changes: 6 additions & 3 deletions docs/user_docs/guides/automation.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,17 @@ kcl main.k -O override_spec
- `override_spec` represents a unified representation of the configuration model fields and values that need to be modified

```bash
override_spec: [[pkgpath] ":"] identifier ("=" value | "-")
override_spec: identifier (("=" | ":" | "+=") value | "-")
```

- `pkgpath`: indicates the package path where the identifier needs to be modified, usually in the form of `a.b.c`. For the main package,`pkgpath` is represented as `__ main__`. When omitted or not written, it indicates the main package
- `identifier` indicates the identifier that needs to modify the configuration, usually in the form of `a.b.c` or `a["dot.key"].c`
- `value` indicates the value of the configuration that needs to be modified, which can be any legal KCL expression, such as number/string literal value, list/dict/schema expression, etc.
- `=` denotes modifying of the value of the identifier.
- `=`, `:` and `+=` denotes modifying of the value of the identifier with the corresponding attribute operator.
- When the identifier exists, modify the value of the existing identifier to value.
- When identifier does not exist, add the identifier attribute and set its value to value.
- `-` denotes deleting of the identifier.
- When the identifier exists, delete it directly.
- When the identifier does not exist, no modification is made to the configuration.

#### Override Configuration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3182,14 +3182,13 @@ kcl main.k -O override_spec

- `override_spec`: 表示需要修改的配置模型字段和值的统一表示

```txt
override_spec: [[pkgpath] ":"] identifier ("=" value | "-")
```bash
override_spec: identifier (("=" | ":" | "+=") value | "-")
```

- `pkgpath`: 表示需要修改标识符的包路径,通常为 `a.b.c` 的形式,对于 main 包,`pkgpath` 表示为 `__main__`, 可省略,省略不写时表示 main 包
- `identifier`: 表示需要修改配置的标识符,通常为 `a.b.c` 的形式
- `identifier`: 表示需要修改配置的标识符,通常为 `a.b.c` 或者 `a["dot.key"].c` 的形式
- `value`: 表示需要修改配置的值,可以是任意合法的 KCL 表达式,比如数字/字符串字面值,list/dict/schema 表达式等
- `=`: 表示修改identifier的值
- `=`, `-` 和 `+=`: 表示用对应的属性运算符修改 identifier 的值
- 当 identifier 存在时,修改已有 identifier的值为 value
- 当 identifier 不存在时,添加 identifier属性,并将其值设置为 value
- `-`: 表示删除 identifier属性
Expand Down
Loading
Loading