From b88377962700307f5aa6c14aa21b48d9ab88c9b1 Mon Sep 17 00:00:00 2001 From: peefy Date: Thu, 18 Jan 2024 20:24:26 +0800 Subject: [PATCH] feat: doc gen html escape for default value Signed-off-by: peefy --- pkg/tools/gen/templates/doc/schemaDoc.gotmpl | 2 +- pkg/tools/gen/testdata/doc/pkg/container.k | 1 + pkg/tools/gen/testdata/doc/pkg/md/main.md | 3 ++- pkg/tools/gen/testdata/doc/pkg/server.k | 5 ++++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/tools/gen/templates/doc/schemaDoc.gotmpl b/pkg/tools/gen/templates/doc/schemaDoc.gotmpl index 5ee0d49f..16b746e1 100644 --- a/pkg/tools/gen/templates/doc/schemaDoc.gotmpl +++ b/pkg/tools/gen/templates/doc/schemaDoc.gotmpl @@ -10,7 +10,7 @@ | name | type | description | default value | | --- | --- | --- | --- | -{{range $name, $property := $Data.Properties}}|**{{$name}}**{{if containsString $Data.Required $name }} `required`{{end}}{{if $property.ReadOnly}} `readOnly`{{end}}|{{kclType $property $EscapeHtml}}|{{if ne $property.Description ""}}{{escapeHtml $property.Description $EscapeHtml}}{{end}}|{{$property.Default}}| +{{range $name, $property := $Data.Properties}}|**{{$name}}**{{if containsString $Data.Required $name }} `required`{{end}}{{if $property.ReadOnly}} `readOnly`{{end}}|{{kclType $property $EscapeHtml}}|{{if ne $property.Description ""}}{{escapeHtml $property.Description $EscapeHtml}}{{end}}|{{escapeHtml $property.Default $EscapeHtml}}| {{end}}{{if ne (len $Data.Examples) 0}}#### Examples {{range $name, $example := $Data.Examples}}{{if $example.Summary}}**$example.Summary** diff --git a/pkg/tools/gen/testdata/doc/pkg/container.k b/pkg/tools/gen/testdata/doc/pkg/container.k index 5e4f089a..17788dd1 100644 --- a/pkg/tools/gen/testdata/doc/pkg/container.k +++ b/pkg/tools/gen/testdata/doc/pkg/container.k @@ -8,3 +8,4 @@ schema Container: The name of the long-running container. """ name: str + image: str diff --git a/pkg/tools/gen/testdata/doc/pkg/md/main.md b/pkg/tools/gen/testdata/doc/pkg/md/main.md index e4b98f12..2612d0c3 100644 --- a/pkg/tools/gen/testdata/doc/pkg/md/main.md +++ b/pkg/tools/gen/testdata/doc/pkg/md/main.md @@ -19,6 +19,7 @@ Container is the common user interface for long-running services. | name | type | description | default value | | --- | --- | --- | --- | +|**image** `required`|str||| |**name** `required`|str|The name of the long-running container.|| ### Server @@ -40,7 +41,7 @@ Server is the common user interface for long-running services adopting the best |**litFloat** `required` `readOnly`|1.11||1.11| |**litInt** `required` `readOnly`|123||123| |**litStr** `required` `readOnly`|"abc"||"abc"| -|**mainContainer** `required`|[Container](#container)||| +|**mainContainer** `required`|[Container](#container)||Container {
name = "main"
image = "image"
}| |**name** `required`|str|A Server-level attribute.
The name of the long-running service.
See also: kusion_models/core/v1/metadata.k.|| |**numMultiplier** `required`|units.NumberMultiplier||1M| |**others** `required`|any||| diff --git a/pkg/tools/gen/testdata/doc/pkg/server.k b/pkg/tools/gen/testdata/doc/pkg/server.k index 11b1f34a..ec68eebd 100644 --- a/pkg/tools/gen/testdata/doc/pkg/server.k +++ b/pkg/tools/gen/testdata/doc/pkg/server.k @@ -35,7 +35,10 @@ schema Server: age: int height: float port: int | str - mainContainer: Container + mainContainer: Container = Container { + name = "main" + image = "image" + } antiSelf: bool others: any litStr: "abc"