kcl-lang / kcl-lang.io

KCL Website and Documentation Repo: https://kcl-lang.io
https://kcl-lang.github.io
Apache License 2.0
13 stars 35 forks source link

[FAQ] Escape | symbole during rendering documents #445

Closed soubinan closed 3 weeks ago

soubinan commented 4 weeks ago

Enhancement

What we have today: image

This markdown section has been generated from the model below

schema Service:
    $serviceType: "http" | "https" | "tcp"
    remark?: str
    enable: bool = True
    ingressProfile: "wan" | "lan" = "wan"
    egressProfile: "wan" | "lan" = "lan"
    virtualPort: int = 443
    virtualAddresse: str
    snatFlow: "inbound" | "outbound" = "inbound"
    flowType: "internal" | "external" = "external"
    multiplexProfile: "oneconnect" | "amaconnect" = "oneconnect"
    $useCookies?: "default" | "webui" | "none" = "none"
    iRules?: [Pointer]
    pool?: Pointer
    clientTLS?: str
    serverTLS?: str
    redirect80?: bool
    profileHTTPCompression?: Pointer
    if $serviceType == "https":
        virtualPort: int = 443
        redirect80: bool = True
        clientTLS: str = ""
        serverTLS: str = ""

Issue noticed: In declaractions with union of types like in $serviceType: "http" | "https" | "tcp" the values are spreaded over a markdown table while they should be in one column

the render gives

| name | type | description | default value |
|**serviceType** `required`|"http" | "https" | "tcp"|||

instead of

| name | type | description | default value |
|**serviceType** `required`|"http" \| "https" \| "tcp"|||

Expected behavior: the union symbol | should be escaped by default for the type column to become: "http" \| "https" \| "tcp" or could even be replace by or to become: "http" or "https" or "tcp"

Peefy commented 4 weeks ago

Hello. Have you tried the --escape-html flag in the kcl doc gen command or the EscapeHtml options in the KCL Go API: https://github.com/kcl-lang/kcl-go/blob/main/pkg/tools/gen/gendoc.go#L66

soubinan commented 4 weeks ago

Just tried and it did the job Great! When I saw escape-html I assumed it was for html content (I did not considered | to be an html symbol) and didn't try. Maybe could be more explicit?

Thanks!