Added more docstrings

This commit is contained in:
Calvin Lobo
2024-08-28 15:36:30 -04:00
committed by quobix
parent c8186468ae
commit 9d5251a55e
2 changed files with 7 additions and 3 deletions

View File

@@ -155,7 +155,8 @@ type SpecIndexConfig struct {
uri []string 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() { func (s *SpecIndexConfig) SetTheoreticalRoot() {
s.SpecFilePath = filepath.Join(s.BasePath, theoreticalRoot) s.SpecFilePath = filepath.Join(s.BasePath, theoreticalRoot)

View File

@@ -16,6 +16,7 @@ import (
"fmt" "fmt"
"log/slog" "log/slog"
"os" "os"
"path/filepath"
"sort" "sort"
"strings" "strings"
"sync" "sync"
@@ -26,6 +27,7 @@ import (
) )
const ( const (
// theoreticalRoot is the name of the theoretical spec file used when a root spec file does not exist
theoreticalRoot = "root.yaml" theoreticalRoot = "root.yaml"
) )
@@ -156,11 +158,12 @@ func (index *SpecIndex) GetRolodex() *Rolodex {
return index.rolodex return index.rolodex
} }
// GetSpecFileName returns the root spec filename, if it exists, otherwise returns the theoretical root spec
func (index *SpecIndex) GetSpecFileName() string { 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 theoreticalRoot
} }
return index.rolodex.indexConfig.SpecFilePath return filepath.Base(index.rolodex.indexConfig.SpecFilePath)
} }
// GetGlobalTagsNode returns document root tags node. // GetGlobalTagsNode returns document root tags node.