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

doc generate error / 文档生成错误 #1424

Closed
LinYunling opened this issue Jun 20, 2024 · 4 comments
Closed

doc generate error / 文档生成错误 #1424

LinYunling opened this issue Jun 20, 2024 · 4 comments

Comments

@LinYunling
Copy link

LinYunling commented Jun 20, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. The schema define:
    schema ResourceModel:
    '''
    Resource Model Definition

     Attributes
     ----------
     name: str, default is "", required.
         The name of resource.
     alias: str, default is "", optional.
         The alias name of resource.
     type: str, default is "PC", required.
         The type of resource.
    
     Examples
     ----------------------
     res = ResourceModel {
         name = "ServerA"
         alias = "My Computer"
         type = "PC"
     }
    

    '''
    name: str
    alias: str
    type: str

    check:
    type in ["PC", "Notebook", "IPad", "SmartPhone"]

  2. kcl doc generate

  3. see the markdown file, the result is error.
    image

2. What did you expect to see? (Required)

  1. Attribute definitions should be sorted in the order.
  2. The alias is optional, but required.

3. What did you see instead (Required)

like 2

4. What is your KCL components version? (Required)

0.9.0-beta.1
image

@Peefy
Copy link
Contributor

Peefy commented Jun 20, 2024

Hello @LinYunling

The type of attribute alias is depended on the definition instead of the doc string. For example, if you write the definition with the optional op ?, the doc will generate the right the form.

schema ResourceModel:
    '''
    Resource Model Definition

    Attributes
    ----------
    name: str, default is "", required.
        The name of resource.
    alias: str, default is "", optional.
        The alias name of resource.
    type: str, default is "string", required.
        The type of resource.
   
    Examples
    ----------------------
    res = ResourceModel {
        name = "ServerA"
        alias = "My Computer"
        type = "PC"
    }
    '''
    name: str
    alias?: str # Note the `?` here.
    type: str
    
    check:
        type in ["PC", "Notebook", "IPad", "SmartPhone"]

image

@LinYunling
Copy link
Author

Only the description is from comments ?
May I define the sorting order of attributes?

@LinYunling
Copy link
Author

The document is misleading.

@Peefy
Copy link
Contributor

Peefy commented Jun 20, 2024

Only the description is from comments ? May I define the sorting order of attributes?

  1. The doc use the required/optional attribute annotation defined in the schema e.g., alias?: str or alias: str
  2. At present, it is not yet supported to do so, but we can implement it in the kcl doc tool using the line attribute defined in the KCL OpenAPI type https://github.com/kcl-lang/kcl-go/blob/main/pkg/spec/gpyrpc/gpyrpc.pb.go#L3749. Welcome to open a new Issue or PR to record or implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants