Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/v0.36.3/format-markdown-files.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
changelog:
- type: FIX
issueLink: https://github.com/solo-io/solo-projects/issues/6612
resolvesIssue: false
description: >-
Update the markdown templates to fit new formatting guidelines.
32 changes: 23 additions & 9 deletions pkg/code-generator/docgen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,22 +147,36 @@ func (d *DocsGen) FileHeader(filename string) string {
return ".. Code generated by solo-kit. DO NOT EDIT."
}
if d.DocsOptions.Output == options.Hugo {
name := filepath.Base(filename)
if strings.HasSuffix(name, d.protoSuffix()) {
name = name[:len(name)-len(d.protoSuffix())]
}
return fmt.Sprintf(`
return d.hugoFileHeader(filename)
}
return `<!-- Code generated by solo-kit. DO NOT EDIT. -->
`
}

func (d *DocsGen) hugoFileHeader(filename string) string {
name := filepath.Base(filename)

var title string
protoExtension := ".proto" + d.protoSuffix()
if strings.HasSuffix(name, protoExtension) {
// Remove the "proto.sk.md" extension
name = strings.TrimSuffix(name, protoExtension)

title = strcase.ToCamel(name)
} else {
// Not a file generated by a proto file, leave the title to match the name of the file
title = name
}

return fmt.Sprintf(`
---
title: "%s"
weight: 5
---

<!-- Code generated by solo-kit. DO NOT EDIT. -->

`, name)
}
return `<!-- Code generated by solo-kit. DO NOT EDIT. -->
`
`, title)
}

func (d *DocsGen) projectSuffix() string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func ProtoFileTemplate(project *model.Project, docsOptions *options.DocsOptions)
{{ end }}

{{- if gt (len .Messages) 0 }}
#### Types:
**Types:**

{{ $linkMessage := "- [{{ printfptr \"%v\" .Name }}](#{{ toAnchorLink \"%v\" .Name }}) {{- if (resourceForMessage .) }} **Top-Level Resource**{{ end }}" }}
{{ $linkEnum := "- [{{ printfptr \"%v\" .Name }}](#{{ toAnchorLink \"%v\" .Name }})" }}
Expand All @@ -35,7 +35,7 @@ func ProtoFileTemplate(project *model.Project, docsOptions *options.DocsOptions)

{{- if gt (len .Enums) 0 }}

##### Enums:
**Enums:**

{{ range .Enums}}
- [{{ printfptr "%v" .Name }}](#{{ toAnchorLink "%v" .Name }})
Expand All @@ -44,7 +44,7 @@ func ProtoFileTemplate(project *model.Project, docsOptions *options.DocsOptions)

{{ end}}

##### Source File: {{ githubLinkForFile "main" .Name }}
**Source File: {{ githubLinkForFile "main" .Name }}**

{{ $msgLongInfo := ` + "`" + `
{{ $Message := . -}}
Expand Down
4 changes: 3 additions & 1 deletion pkg/code-generator/schemagen/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const (
v1 = "apiextensions.k8s.io/v1"
)

const crdFileHeader = `CRD validation schema generated by solo-kit. DO NOT EDIT.`

var (
ApiVersionMismatch = func(expected, actual string) error {
return eris.Errorf("Expected ApiVersion [%s] but found [%s]", expected, actual)
Expand All @@ -37,7 +39,7 @@ func NewCrdWriter(crdDirectory string) *CrdWriter {
fileWriter: &writer.DefaultFileWriter{
Root: crdDirectory,
HeaderFromFilename: func(s string) string {
return fmt.Sprintf("# %s\n\n", writer.DefaultFileHeader)
return fmt.Sprintf("# %s\n\n", crdFileHeader)
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/crds/testing.solo.io_v1_MockResource.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Code generated by solo-kit. DO NOT EDIT.
# CRD validation schema generated by solo-kit. DO NOT EDIT.

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/crds/testing.solo.io_v1_SimpleMockResource.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Code generated by solo-kit. DO NOT EDIT.
# CRD validation schema generated by solo-kit. DO NOT EDIT.

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down