diff --git a/cmd/helper_interface.go b/cmd/helper_interface.go index c8eb5a4..a4e408c 100644 --- a/cmd/helper_interface.go +++ b/cmd/helper_interface.go @@ -9,9 +9,14 @@ type InterfaceTemplate struct { } func getInterfaceTemplate(section Section, sections []Section) InterfaceTemplate { + desc := strings.Join(section.Description, "\n// ") + if desc != "" { + desc = "// " + desc + } + return InterfaceTemplate{ Name: section.Name, - Description: "// " + strings.Join(section.Description, "\n// "), + Description: desc, InterfaceOf: section.InterfaceOf, } } diff --git a/cmd/helper_method.go b/cmd/helper_method.go index 4241a9f..e3e8e8a 100644 --- a/cmd/helper_method.go +++ b/cmd/helper_method.go @@ -61,12 +61,17 @@ func getMethodTemplate(section Section, sections []Section) MethodTemplate { nestedInputFileFields, _ := NewMethodFields(getNestedMediaFields(sections, section), sections) returnType := getType("", extractReturnType(section.Description), true, sections) + desc := strings.Join(section.Description, "\n// ") + if desc != "" { + desc = "// " + desc + } + mt := MethodTemplate{ Name: strings.ToUpper(string(section.Name[0])) + section.Name[1:], MethodName: section.Name, ReturnType: returnType, ReturnsInterface: isInterface(returnType, sections), - Description: "// " + strings.Join(section.Description, "\n// "), + Description: desc, EmptyReturnValue: defaultValueOfType(returnType), Fields: fields, InputFileFields: inputFileFields, diff --git a/cmd/helper_type.go b/cmd/helper_type.go index a9c2ab4..c8680ad 100644 --- a/cmd/helper_type.go +++ b/cmd/helper_type.go @@ -72,9 +72,14 @@ func NewTypeFields(fields []Field, sections []Section) (newFields []TypeField, c func getTypeTemplate(section Section, sections []Section, implementers map[string]string) TypeTemplate { fields, containsInterface, containsInputFile := NewTypeFields(section.Fields, sections) + desc := strings.Join(section.Description, "\n// ") + if desc != "" { + desc = "// " + desc + } + return TypeTemplate{ Name: section.Name, - Description: "// " + strings.Join(section.Description, "\n// "), + Description: desc, Implements: implementers[section.Name], Fields: fields, ContainsInterface: containsInterface,