Skip to content

Commit

Permalink
Added more docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
Calvin Lobo authored and daveshanley committed Sep 9, 2024
1 parent c818646 commit 9d5251a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion index/index_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ type SpecIndexConfig struct {
uri []string
}

// SetTheoreticalRoot sets the spec file paths to a theoretical file path
// SetTheoreticalRoot sets the spec file paths to point to a theoretical spec file, which does not exist but is required
// in order to formulate the absolute path to root references correctly.
func (s *SpecIndexConfig) SetTheoreticalRoot() {
s.SpecFilePath = filepath.Join(s.BasePath, theoreticalRoot)

Expand Down
7 changes: 5 additions & 2 deletions index/spec_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"fmt"
"log/slog"
"os"
"path/filepath"
"sort"
"strings"
"sync"
Expand All @@ -26,6 +27,7 @@ import (
)

const (
// theoreticalRoot is the name of the theoretical spec file used when a root spec file does not exist
theoreticalRoot = "root.yaml"
)

Expand Down Expand Up @@ -156,11 +158,12 @@ func (index *SpecIndex) GetRolodex() *Rolodex {
return index.rolodex
}

// GetSpecFileName returns the root spec filename, if it exists, otherwise returns the theoretical root spec
func (index *SpecIndex) GetSpecFileName() string {
if index == nil || index.rolodex == nil || index.rolodex.indexConfig == nil {
if index == nil || index.rolodex == nil || index.rolodex.indexConfig == nil || index.rolodex.indexConfig.SpecFilePath == "" {
return theoreticalRoot
}
return index.rolodex.indexConfig.SpecFilePath
return filepath.Base(index.rolodex.indexConfig.SpecFilePath)
}

// GetGlobalTagsNode returns document root tags node.
Expand Down

0 comments on commit 9d5251a

Please sign in to comment.