Skip to content

Commit

Permalink
Allow gen-device-svd to handle multi-line device descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
cibomahto committed Nov 17, 2024
1 parent 3bbfffd commit 52bd80d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tools/gen-device-svd/gen-device-svd.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,13 @@ func readSVD(path, sourceURL string) (*Device, error) {
return interruptList[i].PeripheralIndex < interruptList[j].PeripheralIndex
})

// Properly format the description, with comments.
description := ""
if text := device.Description; text != "" {
description = "// " + strings.ReplaceAll(text, "\n", "\n// ")
description = regexp.MustCompile(`\s+\n`).ReplaceAllString(description, "\n")
}

// Properly format the license block, with comments.
licenseBlock := ""
if text := formatText(device.LicenseText); text != "" {
Expand All @@ -460,7 +467,7 @@ func readSVD(path, sourceURL string) (*Device, error) {
DescriptorSource: sourceURL,
Name: device.Name,
NameLower: nameLower,
Description: strings.TrimSpace(device.Description),
Description: description,
LicenseBlock: licenseBlock,
}
if device.CPU != nil {
Expand Down Expand Up @@ -902,9 +909,9 @@ func writeGo(outdir string, device *Device, interruptSystem string) error {
//go:build {{.pkgName}} && {{.device.Metadata.NameLower}}
/*
{{.device.Metadata.Description}}
*/
{{.device.Metadata.LicenseBlock}}
package {{.pkgName}}
Expand Down Expand Up @@ -1351,7 +1358,7 @@ func writeAsm(outdir string, device *Device) error {
t := template.Must(template.New("go").Parse(`// Automatically generated file. DO NOT EDIT.
// Generated by gen-device-svd.go from {{.File}}, see {{.DescriptorSource}}
// {{.Description}}
{{.Description}}
//
{{.LicenseBlock}}
Expand Down

0 comments on commit 52bd80d

Please sign in to comment.