Skip to content

Commit

Permalink
fix: fixes a bug that could select wrong tag description markdown file
Browse files Browse the repository at this point in the history
  • Loading branch information
Kafkalasch committed Jun 17, 2024
1 parent b8662de commit 50f5d07
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,13 @@ func isGeneralAPIComment(comments []string) bool {
}

func getMarkdownForTag(tagName string, dirPath string) ([]byte, error) {
if tagName == "" {
// this happens when parsing the @description.markdown attribute
// it will be called properly another time with tagName="api"
// so we can safely return an empty byte slice here
return make([]byte, 0), nil
}

dirEntries, err := os.ReadDir(dirPath)
if err != nil {
return nil, err
Expand All @@ -897,11 +904,9 @@ func getMarkdownForTag(tagName string, dirPath string) ([]byte, error) {

fileName := entry.Name()

if !strings.Contains(fileName, ".md") {
continue
}
expectedFileName := tagName + ".md"

if strings.Contains(fileName, tagName) {
if fileName == expectedFileName {
fullPath := filepath.Join(dirPath, fileName)

commentInfo, err := os.ReadFile(fullPath)
Expand Down

0 comments on commit 50f5d07

Please sign in to comment.