Skip to content

Commit

Permalink
Fixes Issue 1829 (#1830)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Kafkalasch authored Jul 1, 2024
1 parent 807dd1f commit 697572a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,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 @@ -900,11 +907,12 @@ func getMarkdownForTag(tagName string, dirPath string) ([]byte, error) {

fileName := entry.Name()

if !strings.Contains(fileName, ".md") {
continue
expectedFileName := tagName
if !strings.HasSuffix(tagName, ".md") {
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 697572a

Please sign in to comment.