Skip to content

Commit

Permalink
feat: doc gen html escape for default value (#218)
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy authored Jan 24, 2024
1 parent ba06a22 commit 771f644
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/tools/gen/templates/doc/schemaDoc.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
1 change: 1 addition & 0 deletions pkg/tools/gen/testdata/doc/pkg/container.k
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ schema Container:
The name of the long-running container.
"""
name: str
image: str
3 changes: 2 additions & 1 deletion pkg/tools/gen/testdata/doc/pkg/md/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 {<br /> name = "main"<br /> image = "image"<br />}|
|**name** `required`|str|A Server-level attribute.<br />The name of the long-running service.<br />See also: kusion_models/core/v1/metadata.k.||
|**numMultiplier** `required`|units.NumberMultiplier||1M|
|**others** `required`|any|||
Expand Down
5 changes: 4 additions & 1 deletion pkg/tools/gen/testdata/doc/pkg/server.k
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 771f644

Please sign in to comment.