diff --git a/pkg/tools/gen/gendoc.go b/pkg/tools/gen/gendoc.go index aba7d555..a4bd7e90 100644 --- a/pkg/tools/gen/gendoc.go +++ b/pkg/tools/gen/gendoc.go @@ -19,9 +19,13 @@ var schemaDocTmpl string //go:embed templates/doc/packageDoc.gotmpl var packageDocTmpl string +//go:embed templates/doc/schemaListDoc.gotmpl +var schemaListDocTmpl string + const ( - schemaDocTmplFile = "schemaDoc.gotmpl" - packageDocTmplFile = "packageDoc.gotmpl" + schemaDocTmplFile = "schemaDoc.gotmpl" + packageDocTmplFile = "packageDoc.gotmpl" + schemaListDocTmplFile = "schemaListDoc.gotmpl" ) // GenContext defines the context during the generation @@ -40,6 +44,8 @@ type GenContext struct { SchemaDocTmpl string // PackageDocTmpl defines the content of the packageDoc template PackageDocTmpl string + // SchemaListDocTmpl defines the content of the schemaListDoc template + SchemaListDocTmpl string // Template is the doc render template Template *template.Template } @@ -169,7 +175,7 @@ func funcMap() template.FuncMap { return false }, "kclType": func(tpe KclOpenAPIType) string { - return tpe.GetKclTypeName(false) + return tpe.GetKclTypeName(false, true) }, "fullTypeName": func(tpe KclOpenAPIType) string { if tpe.KclExtensions.XKclModelType.Import.Package != "" { @@ -192,50 +198,31 @@ func funcMap() template.FuncMap { return filepath.Join(tpe.GetSchemaPkgDir(""), tpe.KclExtensions.XKclModelType.Import.Alias) }, "indexContent": func(pkg *KclPackage) string { - return pkg.getIndexContent(0, " ", "", false) - }, - "indexContentIgnoreDirPath": func(pkg *KclPackage) string { - return pkg.getIndexContent(0, " ", "", true) + return pkg.getIndexContent(0, " ") }, } } -func (pkg *KclPackage) getPackageIndexContent(level int, indentation string, pkgPath string, ignoreDir bool) string { - currentPkgPath := filepath.Join(pkgPath, pkg.Name) - currentDocPath := pkg.Name - if !ignoreDir { - // get the full directory path - currentDocPath = filepath.Join(currentPkgPath, fmt.Sprintf("%s.md", pkg.Name)) - } - return fmt.Sprintf(`%s- [%s](%s) -%s`, strings.Repeat(indentation, level), pkg.Name, currentDocPath, pkg.getIndexContent(level+1, indentation, currentPkgPath, ignoreDir)) +func (pkg *KclPackage) getPackageIndexContent(level int, indentation string) string { + return fmt.Sprintf(`%s- %s +%s`, strings.Repeat(indentation, level), pkg.Name, pkg.getIndexContent(level+1, indentation)) } -func (tpe *KclOpenAPIType) getSchemaIndexContent(level int, indentation string, pkgPath string, pkgName string, ignoreDir bool) string { - docPath := pkgName - if !ignoreDir { - // get the full directory path - docPath = filepath.Join(pkgPath, fmt.Sprintf("%s.md", pkgName)) - } - if level == 0 { - // the schema is defined in current package - docPath = "" - } - - return fmt.Sprintf(`%s- [%s](%s#%s) -`, strings.Repeat(indentation, level), tpe.KclExtensions.XKclModelType.Type, docPath, strings.ToLower(tpe.KclExtensions.XKclModelType.Type)) +func (tpe *KclOpenAPIType) getSchemaIndexContent(level int, indentation string) string { + return fmt.Sprintf(`%s- [%s](#%s) +`, strings.Repeat(indentation, level), tpe.KclExtensions.XKclModelType.Type, strings.ToLower(tpe.KclExtensions.XKclModelType.Type)) } -func (pkg *KclPackage) getIndexContent(level int, indentation string, pkgPath string, ignoreDir bool) string { +func (pkg *KclPackage) getIndexContent(level int, indentation string) string { var content string if len(pkg.SchemaList) > 0 { for _, sch := range pkg.SchemaList { - content += sch.getSchemaIndexContent(level, indentation, pkgPath, pkg.Name, ignoreDir) + content += sch.getSchemaIndexContent(level, indentation) } } if len(pkg.SubPackageList) > 0 { for _, pkg := range pkg.SubPackageList { - content += pkg.getPackageIndexContent(level, indentation, pkgPath, ignoreDir) + content += pkg.getPackageIndexContent(level, indentation) } } return content @@ -247,7 +234,7 @@ func (g *GenContext) renderPackage(pkg *KclPackage, parentDir string) error { pkgName = "main" } fmt.Println(fmt.Sprintf("generating doc for package %s", pkgName)) - indexFileName := fmt.Sprintf("%s.%s", pkgName, g.Format) + docFileName := fmt.Sprintf("%s.%s", pkgName, g.Format) var contentBuf bytes.Buffer err := g.Template.ExecuteTemplate(&contentBuf, "packageDoc", struct { EscapeHtml bool @@ -260,22 +247,9 @@ func (g *GenContext) renderPackage(pkg *KclPackage, parentDir string) error { return fmt.Errorf("failed to render package %s with template, err: %s", pkg.Name, err) } // write content to file - err = os.WriteFile(filepath.Join(parentDir, indexFileName), contentBuf.Bytes(), 0644) + err = os.WriteFile(filepath.Join(parentDir, docFileName), contentBuf.Bytes(), 0644) if err != nil { - return fmt.Errorf("failed to write file %s in %s: %v", indexFileName, parentDir, err) - } - - for _, sub := range pkg.SubPackageList { - pkgDir := GetPkgDir(parentDir, sub.Name) - //fmt.Println(fmt.Sprintf("creating directory: %s", pkgDir)) - err := os.MkdirAll(pkgDir, 0755) - if err != nil { - return fmt.Errorf("failed to create docs/%s directory under the target directory: %s", pkgDir, err) - } - err = g.renderPackage(sub, pkgDir) - if err != nil { - return err - } + return fmt.Errorf("failed to write file %s in %s: %v", docFileName, parentDir, err) } return nil } @@ -308,6 +282,7 @@ func (opts *GenOpts) ValidateComplete() (*GenContext, error) { // --- template directory --- g.SchemaDocTmpl = schemaDocTmpl g.PackageDocTmpl = packageDocTmpl + g.SchemaListDocTmpl = schemaListDocTmpl if opts.TemplateDir != "" { tmplAbsPath := filepath.Join(g.PackagePath, opts.TemplateDir) templatesDirInfo, err := os.Stat(tmplAbsPath) @@ -343,6 +318,14 @@ func (opts *GenOpts) ValidateComplete() (*GenContext, error) { } g.PackageDocTmpl = string(content) return nil + case schemaListDocTmplFile: + // use custom schema list Doc Template file + content, err := os.ReadFile(path) + if err != nil { + return err + } + g.SchemaListDocTmpl = string(content) + return nil default: return fmt.Errorf("unexpected template file: %s", path) } @@ -361,6 +344,10 @@ func (opts *GenOpts) ValidateComplete() (*GenContext, error) { if err != nil { return nil, err } + _, err = g.Template.Parse(g.SchemaListDocTmpl) + if err != nil { + return nil, err + } // --- target --- if opts.Target == "" { diff --git a/pkg/tools/gen/gendoc_test.go b/pkg/tools/gen/gendoc_test.go index 6c3c7255..8fa32e32 100644 --- a/pkg/tools/gen/gendoc_test.go +++ b/pkg/tools/gen/gendoc_test.go @@ -7,15 +7,11 @@ import ( assert2 "github.com/stretchr/testify/assert" "os" "path/filepath" - "runtime" "strings" "testing" ) func TestIndexContent(t *testing.T) { - if runtime.GOOS == "windows" { - return - } rootPkg := KclPackage{ Name: "test", SubPackageList: []*KclPackage{ @@ -57,33 +53,21 @@ func TestIndexContent(t *testing.T) { }, } tCases := []struct { - root KclPackage - ignoreDir bool - expect string + root KclPackage + expect string }{ { - root: rootPkg, - ignoreDir: false, - expect: `- [A](#a) -- [sub1](sub1/sub1.md) - - [B](sub1/sub1.md#b) - - [sub2](sub1/sub2/sub2.md) - - [C](sub1/sub2/sub2.md#c) -`, - }, - { - root: rootPkg, - ignoreDir: true, + root: rootPkg, expect: `- [A](#a) -- [sub1](sub1) - - [B](sub1#b) - - [sub2](sub2) - - [C](sub2#c) +- sub1 + - [B](#b) + - sub2 + - [C](#c) `, }, } for _, tCase := range tCases { - got := tCase.root.getIndexContent(0, " ", "", tCase.ignoreDir) + got := tCase.root.getIndexContent(0, " ") assert2.Equal(t, tCase.expect, got) } } @@ -138,18 +122,12 @@ func initTestCases(t *testing.T) []*TestCase { for i, p := range sourcePkgs { packageDir := filepath.Join(cwd, testdataDir, p) - var resultDir string - if runtime.GOOS == "windows" { - resultDir = filepath.Join(packageDir, "windows") - } else { - resultDir = filepath.Join(packageDir, "unixlike") - } tcases[i] = &TestCase{ PackagePath: packageDir, - ExpectMd: filepath.Join(resultDir, "md"), - ExpectHtml: filepath.Join(resultDir, "html"), - GotMd: filepath.Join(resultDir, "md_got"), - GotHtml: filepath.Join(resultDir, "html_got"), + ExpectMd: filepath.Join(packageDir, "md"), + ExpectHtml: filepath.Join(packageDir, "html"), + GotMd: filepath.Join(packageDir, "md_got"), + GotHtml: filepath.Join(packageDir, "html_got"), } } return tcases diff --git a/pkg/tools/gen/genopenapi.go b/pkg/tools/gen/genopenapi.go index c31c1158..28389633 100644 --- a/pkg/tools/gen/genopenapi.go +++ b/pkg/tools/gen/genopenapi.go @@ -175,10 +175,15 @@ type XKclDecorators struct { } // GetKclTypeName get the string representation of a KclOpenAPIType -func (tpe *KclOpenAPIType) GetKclTypeName(omitAny bool) string { +func (tpe *KclOpenAPIType) GetKclTypeName(omitAny bool, addLink bool) string { if tpe.Ref != "" { schemaId := Ref2SchemaId(tpe.Ref) - return schemaId[strings.LastIndex(schemaId, ".")+1:] + schemaName := schemaId[strings.LastIndex(schemaId, ".")+1:] + if addLink { + return fmt.Sprintf("[%s](#%s)", schemaName, strings.ToLower(schemaName)) + } else { + return schemaName + } } switch tpe.Type { case String: @@ -214,20 +219,20 @@ func (tpe *KclOpenAPIType) GetKclTypeName(omitAny bool) string { } return typBool case Array: - return fmt.Sprintf("[%s]", tpe.Items.GetKclTypeName(true)) + return fmt.Sprintf("[%s]", tpe.Items.GetKclTypeName(true, addLink)) case Object: if tpe.AdditionalProperties != nil { // dict type if tpe.KclExtensions.XKclDictKeyType.isAnyType() && tpe.AdditionalProperties.isAnyType() { return "{}" } - return fmt.Sprintf("{%s:%s}", tpe.KclExtensions.XKclDictKeyType.GetKclTypeName(true), tpe.AdditionalProperties.GetKclTypeName(true)) + return fmt.Sprintf("{%s:%s}", tpe.KclExtensions.XKclDictKeyType.GetKclTypeName(true, addLink), tpe.AdditionalProperties.GetKclTypeName(true, addLink)) } if tpe.KclExtensions != nil && len(tpe.KclExtensions.XKclUnionTypes) > 0 { // union type tpes := make([]string, len(tpe.KclExtensions.XKclUnionTypes)) for i, unionType := range tpe.KclExtensions.XKclUnionTypes { - tpes[i] = unionType.GetKclTypeName(true) + tpes[i] = unionType.GetKclTypeName(true, addLink) } return strings.Join(tpes, " | ") } diff --git a/pkg/tools/gen/templates/doc/packageDoc.gotmpl b/pkg/tools/gen/templates/doc/packageDoc.gotmpl index bbdae706..bcb842f7 100644 --- a/pkg/tools/gen/templates/doc/packageDoc.gotmpl +++ b/pkg/tools/gen/templates/doc/packageDoc.gotmpl @@ -11,11 +11,10 @@ ## Index {{ indexContent $Data }} -{{ if $Data.SchemaList}} +{{- if or $Data.SchemaList $Data.SubPackageList}} ## Schemas -{{range $i, $schema := $Data.SchemaList }}{{template "schemaDoc" (arr $schema $EscapeHtml) }} +{{template "schemaListDoc" (arr $Data $EscapeHtml) }} {{- end -}} -{{end -}} {{end}} diff --git a/pkg/tools/gen/templates/doc/schemaDoc.gotmpl b/pkg/tools/gen/templates/doc/schemaDoc.gotmpl index 12119dab..fdafce11 100644 --- a/pkg/tools/gen/templates/doc/schemaDoc.gotmpl +++ b/pkg/tools/gen/templates/doc/schemaDoc.gotmpl @@ -10,7 +10,7 @@ {{range $name, $property := $Data.Properties}}**{{$name}}**{{if containsString $Data.Required $name }} *required*{{end}}{{if $property.ReadOnly}} *readOnly*{{end}} -`{{kclType $property}}`{{if ne $property.Description ""}} +{{kclType $property}}{{if ne $property.Description ""}} {{escapeHtml $property.Description $EscapeHtml}}{{end}} diff --git a/pkg/tools/gen/templates/doc/schemaListDoc.gotmpl b/pkg/tools/gen/templates/doc/schemaListDoc.gotmpl new file mode 100644 index 00000000..80026a8b --- /dev/null +++ b/pkg/tools/gen/templates/doc/schemaListDoc.gotmpl @@ -0,0 +1,13 @@ +{{- define "schemaListDoc" -}} + +{{- $Data := index . 0 -}} +{{- $EscapeHtml := index . 1 -}} +{{- if $Data.SchemaList }}{{range $i, $schema := $Data.SchemaList }}{{template "schemaDoc" (arr $schema $EscapeHtml) }} +{{- end -}} +{{- end -}} + +{{- if $Data.SubPackageList}}{{range $i, $pkg := $Data.SubPackageList }}{{template "schemaListDoc" (arr $pkg $EscapeHtml) }} +{{- end -}} +{{- end -}} + +{{- end -}} diff --git a/pkg/tools/gen/testdata/doc/k8s/unixlike/md/apps/apps.md b/pkg/tools/gen/testdata/doc/k8s/md/main.md similarity index 55% rename from pkg/tools/gen/testdata/doc/k8s/unixlike/md/apps/apps.md rename to pkg/tools/gen/testdata/doc/k8s/md/main.md index 63881b38..f91ebd99 100644 --- a/pkg/tools/gen/testdata/doc/k8s/unixlike/md/apps/apps.md +++ b/pkg/tools/gen/testdata/doc/k8s/md/main.md @@ -1,9 +1,11 @@ -# apps +# main ## Index -- [Deployment](#deployment) - +- apps + - [Deployment](#deployment) +- core + - [PodSpec](#podspec) ## Schemas @@ -13,10 +15,18 @@ **metadata** *required* -`str` +str **podSpec** *required* -`any` +any + +### PodSpec + +#### Attributes + +**image** *required* + +str diff --git a/pkg/tools/gen/testdata/doc/k8s/unixlike/md/core/core.md b/pkg/tools/gen/testdata/doc/k8s/unixlike/md/core/core.md deleted file mode 100644 index 1a1632bc..00000000 --- a/pkg/tools/gen/testdata/doc/k8s/unixlike/md/core/core.md +++ /dev/null @@ -1,18 +0,0 @@ -# core - -## Index - -- [PodSpec](#podspec) - - -## Schemas - -### PodSpec - -#### Attributes - -**image** *required* - -`str` - - diff --git a/pkg/tools/gen/testdata/doc/k8s/unixlike/md/main.md b/pkg/tools/gen/testdata/doc/k8s/unixlike/md/main.md deleted file mode 100644 index 5915c7e3..00000000 --- a/pkg/tools/gen/testdata/doc/k8s/unixlike/md/main.md +++ /dev/null @@ -1,10 +0,0 @@ -# main - -## Index - -- [apps](apps/apps.md) - - [Deployment](apps/apps.md#deployment) -- [core](core/core.md) - - [PodSpec](core/core.md#podspec) - - diff --git a/pkg/tools/gen/testdata/doc/k8s/windows/md/apps/apps.md b/pkg/tools/gen/testdata/doc/k8s/windows/md/apps/apps.md deleted file mode 100644 index 63881b38..00000000 --- a/pkg/tools/gen/testdata/doc/k8s/windows/md/apps/apps.md +++ /dev/null @@ -1,22 +0,0 @@ -# apps - -## Index - -- [Deployment](#deployment) - - -## Schemas - -### Deployment - -#### Attributes - -**metadata** *required* - -`str` - -**podSpec** *required* - -`any` - - diff --git a/pkg/tools/gen/testdata/doc/k8s/windows/md/core/core.md b/pkg/tools/gen/testdata/doc/k8s/windows/md/core/core.md deleted file mode 100644 index 1a1632bc..00000000 --- a/pkg/tools/gen/testdata/doc/k8s/windows/md/core/core.md +++ /dev/null @@ -1,18 +0,0 @@ -# core - -## Index - -- [PodSpec](#podspec) - - -## Schemas - -### PodSpec - -#### Attributes - -**image** *required* - -`str` - - diff --git a/pkg/tools/gen/testdata/doc/k8s/windows/md/main.md b/pkg/tools/gen/testdata/doc/k8s/windows/md/main.md deleted file mode 100644 index b620313c..00000000 --- a/pkg/tools/gen/testdata/doc/k8s/windows/md/main.md +++ /dev/null @@ -1,10 +0,0 @@ -# main - -## Index - -- [apps](apps\apps.md) - - [Deployment](apps\apps.md#deployment) -- [core](core\core.md) - - [PodSpec](core\core.md#podspec) - - diff --git a/pkg/tools/gen/testdata/doc/pkg/unixlike/md/main.md b/pkg/tools/gen/testdata/doc/pkg/md/main.md similarity index 74% rename from pkg/tools/gen/testdata/doc/pkg/unixlike/md/main.md rename to pkg/tools/gen/testdata/doc/pkg/md/main.md index 385dfdea..e0638d94 100644 --- a/pkg/tools/gen/testdata/doc/pkg/unixlike/md/main.md +++ b/pkg/tools/gen/testdata/doc/pkg/md/main.md @@ -4,11 +4,10 @@ - [Container](#container) - [Server](#server) -- [k8s](k8s/k8s.md) - - [Deployment](k8s/k8s.md#deployment) - - [core](k8s/core/core.md) - - [PodSpec](k8s/core/core.md#podspec) - +- k8s + - [Deployment](#deployment) + - core + - [PodSpec](#podspec) ## Schemas @@ -20,7 +19,7 @@ Container is the common user interface for long-running services. **name** *required* -`str` +str The name of the long-running container. @@ -32,31 +31,31 @@ Server is the common user interface for long-running services adopting the best **age** *required* -`int` +int **antiSelf** *required* -`bool` +bool **backendWorkload** *required* -`Deployment` +[Deployment](#deployment) **containers** *required* -`[Container]` +[[Container](#container)] **dictAny** *required* -`{str:}` +{str:} **height** *required* -`float` +float **labels** -`{str:str}` +{str:str} A Server-level attribute. The labels of the long-running service. Contains <key>:<value> pairs. @@ -64,31 +63,31 @@ See also: kusion_models/core/v1/metadata.k. **listAny** *required* -`[]` +[] **litBool** *required* *readOnly* -`True` +True **litFloat** *required* *readOnly* -`1.11` +1.11 **litInt** *required* *readOnly* -`123` +123 **litStr** *required* *readOnly* -`"abc"` +"abc" **mainContainer** *required* -`Container` +[Container](#container) **name** *required* -`str` +str A Server-level attribute. The name of the long-running service. @@ -96,27 +95,27 @@ See also: kusion_models/core/v1/metadata.k. **numMultiplier** *required* -`units.NumberMultiplier` +units.NumberMultiplier **others** *required* -`any` +any **port** *required* -`int | str` +int | str **union** *required* -`"abc" | 123 | True | 1.11 | Container | units.NumberMultiplier | 1M` +"abc" | 123 | True | 1.11 | [Container](#container) | units.NumberMultiplier | 1M **union2** *required* -`"abc" | "def"` +"abc" | "def" **workloadType** *required* -`str` +str Use this attribute to specify which kind of long-running service you want. Valid values: Deployment, CafeDeployment. @@ -130,4 +129,24 @@ myCustomApp = AppConfiguration { } ``` +### Deployment + +#### Attributes + +**metadata** *required* + +str + +**podSpec** *required* + +[PodSpec](#podspec) + +### PodSpec + +#### Attributes + +**image** *required* + +str + diff --git a/pkg/tools/gen/testdata/doc/pkg/unixlike/md/k8s/core/core.md b/pkg/tools/gen/testdata/doc/pkg/unixlike/md/k8s/core/core.md deleted file mode 100644 index 1a1632bc..00000000 --- a/pkg/tools/gen/testdata/doc/pkg/unixlike/md/k8s/core/core.md +++ /dev/null @@ -1,18 +0,0 @@ -# core - -## Index - -- [PodSpec](#podspec) - - -## Schemas - -### PodSpec - -#### Attributes - -**image** *required* - -`str` - - diff --git a/pkg/tools/gen/testdata/doc/pkg/unixlike/md/k8s/k8s.md b/pkg/tools/gen/testdata/doc/pkg/unixlike/md/k8s/k8s.md deleted file mode 100644 index d258b654..00000000 --- a/pkg/tools/gen/testdata/doc/pkg/unixlike/md/k8s/k8s.md +++ /dev/null @@ -1,24 +0,0 @@ -# k8s - -## Index - -- [Deployment](#deployment) -- [core](core/core.md) - - [PodSpec](core/core.md#podspec) - - -## Schemas - -### Deployment - -#### Attributes - -**metadata** *required* - -`str` - -**podSpec** *required* - -`PodSpec` - - diff --git a/pkg/tools/gen/testdata/doc/pkg/windows/md/k8s/core/core.md b/pkg/tools/gen/testdata/doc/pkg/windows/md/k8s/core/core.md deleted file mode 100644 index 1a1632bc..00000000 --- a/pkg/tools/gen/testdata/doc/pkg/windows/md/k8s/core/core.md +++ /dev/null @@ -1,18 +0,0 @@ -# core - -## Index - -- [PodSpec](#podspec) - - -## Schemas - -### PodSpec - -#### Attributes - -**image** *required* - -`str` - - diff --git a/pkg/tools/gen/testdata/doc/pkg/windows/md/k8s/k8s.md b/pkg/tools/gen/testdata/doc/pkg/windows/md/k8s/k8s.md deleted file mode 100644 index 5792e057..00000000 --- a/pkg/tools/gen/testdata/doc/pkg/windows/md/k8s/k8s.md +++ /dev/null @@ -1,24 +0,0 @@ -# k8s - -## Index - -- [Deployment](#deployment) -- [core](core\core.md) - - [PodSpec](core\core.md#podspec) - - -## Schemas - -### Deployment - -#### Attributes - -**metadata** *required* - -`str` - -**podSpec** *required* - -`PodSpec` - - diff --git a/pkg/tools/gen/testdata/doc/pkg/windows/md/main.md b/pkg/tools/gen/testdata/doc/pkg/windows/md/main.md deleted file mode 100644 index 7fda10b6..00000000 --- a/pkg/tools/gen/testdata/doc/pkg/windows/md/main.md +++ /dev/null @@ -1,133 +0,0 @@ -# main - -## Index - -- [Container](#container) -- [Server](#server) -- [k8s](k8s\k8s.md) - - [Deployment](k8s\k8s.md#deployment) - - [core](k8s\core\core.md) - - [PodSpec](k8s\core\core.md#podspec) - - -## Schemas - -### Container - -Container is the common user interface for long-running services. - -#### Attributes - -**name** *required* - -`str` - -The name of the long-running container. - -### Server - -Server is the common user interface for long-running services adopting the best practice of Kubernetes. - -#### Attributes - -**age** *required* - -`int` - -**antiSelf** *required* - -`bool` - -**backendWorkload** *required* - -`Deployment` - -**containers** *required* - -`[Container]` - -**dictAny** *required* - -`{str:}` - -**height** *required* - -`float` - -**labels** - -`{str:str}` - -A Server-level attribute. -The labels of the long-running service. Contains <key>:<value> pairs. -See also: kusion_models/core/v1/metadata.k. - -**listAny** *required* - -`[]` - -**litBool** *required* *readOnly* - -`True` - -**litFloat** *required* *readOnly* - -`1.11` - -**litInt** *required* *readOnly* - -`123` - -**litStr** *required* *readOnly* - -`"abc"` - -**mainContainer** *required* - -`Container` - -**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` - -**others** *required* - -`any` - -**port** *required* - -`int | str` - -**union** *required* - -`"abc" | 123 | True | 1.11 | Container | units.NumberMultiplier | 1M` - -**union2** *required* - -`"abc" | "def"` - -**workloadType** *required* - -`str` - -Use this attribute to specify which kind of long-running service you want. -Valid values: Deployment, CafeDeployment. -See also: kusion_models/core/v1/workload_metadata.k. - -#### Examples - -``` -myCustomApp = AppConfiguration { - name = "componentName" -} -``` - - diff --git a/pkg/tools/gen/testdata/doc/reimport/unixlike/md/main.md b/pkg/tools/gen/testdata/doc/reimport/md/main.md similarity index 57% rename from pkg/tools/gen/testdata/doc/reimport/unixlike/md/main.md rename to pkg/tools/gen/testdata/doc/reimport/md/main.md index 44ecf411..24936263 100644 --- a/pkg/tools/gen/testdata/doc/reimport/unixlike/md/main.md +++ b/pkg/tools/gen/testdata/doc/reimport/md/main.md @@ -4,9 +4,8 @@ - [A](#a) - [B](#b) -- [k8s](k8s/k8s.md) - - [Deployment](k8s/k8s.md#deployment) - +- k8s + - [Deployment](#deployment) ## Schemas @@ -16,7 +15,7 @@ **attr** *required* -`Deployment` +[Deployment](#deployment) ### B @@ -24,6 +23,14 @@ **attr** *required* -`Deployment` +[Deployment](#deployment) + +### Deployment + +#### Attributes + +**metadata** *required* + +str diff --git a/pkg/tools/gen/testdata/doc/reimport/unixlike/md/k8s/k8s.md b/pkg/tools/gen/testdata/doc/reimport/unixlike/md/k8s/k8s.md deleted file mode 100644 index ef311695..00000000 --- a/pkg/tools/gen/testdata/doc/reimport/unixlike/md/k8s/k8s.md +++ /dev/null @@ -1,18 +0,0 @@ -# k8s - -## Index - -- [Deployment](#deployment) - - -## Schemas - -### Deployment - -#### Attributes - -**metadata** *required* - -`str` - - diff --git a/pkg/tools/gen/testdata/doc/reimport/windows/md/k8s/k8s.md b/pkg/tools/gen/testdata/doc/reimport/windows/md/k8s/k8s.md deleted file mode 100644 index ef311695..00000000 --- a/pkg/tools/gen/testdata/doc/reimport/windows/md/k8s/k8s.md +++ /dev/null @@ -1,18 +0,0 @@ -# k8s - -## Index - -- [Deployment](#deployment) - - -## Schemas - -### Deployment - -#### Attributes - -**metadata** *required* - -`str` - - diff --git a/pkg/tools/gen/testdata/doc/reimport/windows/md/main.md b/pkg/tools/gen/testdata/doc/reimport/windows/md/main.md deleted file mode 100644 index 24df8631..00000000 --- a/pkg/tools/gen/testdata/doc/reimport/windows/md/main.md +++ /dev/null @@ -1,29 +0,0 @@ -# main - -## Index - -- [A](#a) -- [B](#b) -- [k8s](k8s\k8s.md) - - [Deployment](k8s\k8s.md#deployment) - - -## Schemas - -### A - -#### Attributes - -**attr** *required* - -`Deployment` - -### B - -#### Attributes - -**attr** *required* - -`Deployment` - -