From 0fbba34e780cea85ce0a8b67d5a7d8013405ad69 Mon Sep 17 00:00:00 2001 From: Ali Hashemi <60406325+haashemi@users.noreply.github.com> Date: Thu, 4 Apr 2024 20:05:12 +0330 Subject: [PATCH] fix: fix codegen crashing no description --- cmd/parser.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/parser.go b/cmd/parser.go index 32cb0bb..8b09602 100644 --- a/cmd/parser.go +++ b/cmd/parser.go @@ -95,8 +95,10 @@ func Parse(doc *goquery.Document) (data TemplateData) { }) // Normalize the description - section.Description[0] = strings.Replace(section.Description[0], "This object", section.Name, 1) - section.Description[0] = strings.Replace(section.Description[0], "Use this method to", section.Name+" is used to", 1) + if len(section.Description) != 0 { + section.Description[0] = strings.Replace(section.Description[0], "This object", section.Name, 1) + section.Description[0] = strings.Replace(section.Description[0], "Use this method to", section.Name+" is used to", 1) + } data.Sections = append(data.Sections, section) })