Skip to content

Commit 697572a

Browse files
authored
Fixes Issue 1829 (#1830)
* fix: fixes a bug that could select wrong tag description markdown file * fixes parser to be able to parse file names with and without ext
1 parent 807dd1f commit 697572a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

parser.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,13 @@ func isGeneralAPIComment(comments []string) bool {
888888
}
889889

890890
func getMarkdownForTag(tagName string, dirPath string) ([]byte, error) {
891+
if tagName == "" {
892+
// this happens when parsing the @description.markdown attribute
893+
// it will be called properly another time with tagName="api"
894+
// so we can safely return an empty byte slice here
895+
return make([]byte, 0), nil
896+
}
897+
891898
dirEntries, err := os.ReadDir(dirPath)
892899
if err != nil {
893900
return nil, err
@@ -900,11 +907,12 @@ func getMarkdownForTag(tagName string, dirPath string) ([]byte, error) {
900907

901908
fileName := entry.Name()
902909

903-
if !strings.Contains(fileName, ".md") {
904-
continue
910+
expectedFileName := tagName
911+
if !strings.HasSuffix(tagName, ".md") {
912+
expectedFileName = tagName + ".md"
905913
}
906914

907-
if strings.Contains(fileName, tagName) {
915+
if fileName == expectedFileName {
908916
fullPath := filepath.Join(dirPath, fileName)
909917

910918
commentInfo, err := os.ReadFile(fullPath)

0 commit comments

Comments
 (0)