Skip to content

Commit

Permalink
chore: don't add empty // if there's no description
Browse files Browse the repository at this point in the history
  • Loading branch information
haashemi committed Apr 4, 2024
1 parent 0fbba34 commit ce1f379
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion cmd/helper_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
7 changes: 6 additions & 1 deletion cmd/helper_method.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion cmd/helper_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ce1f379

Please sign in to comment.