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

[tools] Doc tool does not escape union types in markdown table #421

Open
zflat opened this issue Dec 13, 2024 · 1 comment
Open

[tools] Doc tool does not escape union types in markdown table #421

zflat opened this issue Dec 13, 2024 · 1 comment

Comments

@zflat
Copy link

zflat commented Dec 13, 2024

Bug Report

I have a schema that uses the union to specify the type of an attribute and when I run the doc tool, the markdown output contains a pipe which results in an extra column in the table and the type following the pipe in the wrong column in the table.

1. Minimal reproduce step (Required)

  1. Create a new module test
    kcl mod init test && cd test
    
  2. Create a schema file with the contents:
    schema x:
        a: int | str  # attribute a could be a int or string
    
  3. Run the doc tool

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

I expected to see the int | str as the type column in the markdown table.

Acceptable output would have the pipe escaped:

Here is the relevant output:

| name | type | description | default value |
| --- | --- | --- | --- |
|**a** `required`|int \| str|||

3. What did you see instead (Required)

Instead, I see the str in the wrong column in the markdown table because the table has too many pipes. The pipe character should be escaped.

Here is the relevant output markdown:

| name | type | description | default value |
| --- | --- | --- | --- |
|**a** `required`|int | str|||

This is what the table looks like:

name type description default value
a required int str

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

$ kcl --version
kcl version 0.11.0-alpha.1
@Peefy
Copy link
Contributor

Peefy commented Dec 14, 2024

You can use the --escape-html flag to prevent this issue.

Perhaps we can set this flag to default to true in the KCL CLI. cc @zong-zhe @He1pa

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