github.com/paganotoni/doco@v1.0.7/internal/humanize.go (about) 1 package internal 2 3 import ( 4 "path/filepath" 5 "strings" 6 7 "golang.org/x/text/cases" 8 "golang.org/x/text/language" 9 ) 10 11 func humanizeFilename(path string) string { 12 // remove the extension 13 s := strings.ReplaceAll(path, filepath.Ext(path), "") 14 // remove the path 15 s = filepath.Base(s) 16 17 return humanize(s) 18 } 19 20 func humanize(s string) string { 21 // remove underscores and dashes 22 s = strings.ReplaceAll(s, "-", " ") 23 s = strings.ReplaceAll(s, "_", " ") 24 s = cases.Title(language.English).String(s) 25 26 return s 27 }