Skip to content
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

enhance: doc parser support schema example #703

Merged
merged 2 commits into from
Sep 11, 2023

Conversation

amyXia1994
Copy link
Contributor

@amyXia1994 amyXia1994 commented Sep 8, 2023

Close #668

1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

  • N
  • Y

2. What is the scope of this PR (e.g. component or file name):

kclvm/api/src/service/ty.rs
kclvm/sema/src/resolver/doc.rs
kclvm/sema/src/resolver/global.rs
kclvm/sema/src/resolver/mod.rs
kclvm/sema/src/ty/mod.rs

kclvm/spec/gpyrpc/gpyrpc.proto

kclvm/api/src/testdata/get-schema-type-mapping.json
kclvm/api/src/testdata/get-schema-type-mapping.response.json
kclvm/sema/src/resolver/test_data/doc.k

3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

This PR support parsing the Examples section from the schema docstring, and exposes the examples field from the KclvmService.GetSchemaTypeMapping API

Note: The Example.value field of the KclvmService.GetSchemaTypeMapping API changed to string type.

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Other

4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

  • N
  • Y

5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

  • Unit test
  • Integration test
  • Benchmark (add benchmark stats below)
  • Manual test (add detailed scripts or steps below)
  • Other

@amyXia1994
Copy link
Contributor Author

amyXia1994 commented Sep 8, 2023

@Peefy

I suggest to change the type of grpc.Example.value to String, since the example code snippet of the schema can only be represented in plain text. And currently, if we keep using prost_wkt_types::Any as the example value, the corresponding json representation of the Server schema's example in the kclvm/api/src/testdata/exec-program-with-include-schema-type-path.response.json file will be like:

{
    "@type":"type.googleapis.com/example.StringValue",
    "value":[109,121,67,117,115,116,111,109,65,112,112,32,61,32,65,112,112,67,111,110,102,105,103,117,114,97,116,105,111,110,32,123,10,32,32,32,32,110,97,109,101,32,61,32,34,99,111,109,112,111,110,101,110,116,78,97,109,101,34,10,125]
}
```, which is unreadable manually since the example value is wrapped and represented in bytes.

@Peefy Peefy added the semantic Issues or PRs related to kcl semantic and checker label Sep 11, 2023
@Peefy Peefy added this to the v0.6.0 Release milestone Sep 11, 2023
@Peefy Peefy added the tool Issues or PRs related to kcl tools inlucding format, lint, validation, document tools, etc. label Sep 11, 2023
Copy link
Contributor

@Peefy Peefy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Peefy Peefy merged commit be09eef into kcl-lang:main Sep 11, 2023
9 of 10 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Sep 11, 2023
@amyXia1994 amyXia1994 deleted the enhance/doc-schema-example branch September 11, 2023 07:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
semantic Issues or PRs related to kcl semantic and checker tool Issues or PRs related to kcl tools inlucding format, lint, validation, document tools, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

doc parser: support parse the example section of schema
2 participants