Documentation
¶
Index ¶
- func ConvertToUTF8(b []byte) ([]byte, error)
- func CountLines(content string) (int, error)
- func CountTokens(input string) int
- func DetectProjectType(files []FileInfo) string
- func GitContributors(path string) ([]string, error)
- func LanguageFromExtension(ext string) string
- func LoadIgnorePatterns(filenames ...string) (map[string]struct{}, error)
- func OptimizeCode(source string, ext string) string
- func ParseContributor(line string) string
- func PossiblyAPIServer(dir string) bool
- func ReadProjectName(dir string) (string, error)
- func RecognizedExtension(path string, docAndConf bool) bool
- func RecognizedFilename(path string, docAndConf bool) bool
- func ShouldSkip(path string, ignores map[string]struct{}) bool
- func StripCodeBlockMarkers(input string) string
- func URLFromGitConfig(configFilePath string) (string, error)
- type CsProj
- type FileInfo
- type PomProject
- type ProjectInfo
- type PropertyGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToUTF8 ¶
ConvertToUTF8 attempts to convert a byte slice to UTF-8 encoding, managing non-UTF8 encoded parts.
func CountLines ¶
CountLines counts the number of lines in a string, often used to determine the size of file contents
func CountTokens ¶
CountTokens estimates the number of tokens in a string based on UTF-8 rune count
func DetectProjectType ¶
DetectProjectType determines the most common programming language used in the project files to suggest the project's type
func GitContributors ¶
Contributors uses the Git command line to fetch a list of contributors sorted by the number of commits
func LanguageFromExtension ¶
LanguageFromExtension determines the programming language from the file extension
func LoadIgnorePatterns ¶
LoadIgnorePatterns loads patterns from specified filenames to ignore during file operations
func OptimizeCode ¶
OptimizeCode optimizes the source code by normalizing line breaks, trimming unnecessary whitespace, and reducing blank lines.
func ParseContributor ¶
parseContributor extracts the name of the contributor from a line of git shortlog output.
func PossiblyAPIServer ¶ added in v1.1.1
PossiblyAPIServer tries to detect if the source code in the given directory is likely to be an API server.
func ReadProjectName ¶
ReadProjectName tries to deduce the project name from common configuration files.
func RecognizedExtension ¶
RecognizedExtension checks if the file extension is recognized and should be included based on the docAndConf flag
func RecognizedFilename ¶ added in v1.2.3
RecognizedFilename checks if the given path is a recgonized filename, like "LICENSE"
func ShouldSkip ¶
ShouldSkip determines if a directory should be skipped based on ignore patterns
func StripCodeBlockMarkers ¶
StripCodeBlockMarkers removes leading and trailing Markdown code block markers (```)
func URLFromGitConfig ¶
URLFromGitConfig reads the .git/config file and extracts the repository URL from the "remote origin" section
Types ¶
type CsProj ¶
type CsProj struct {
XMLName xml.Name `xml:"Project"`
PropertyGroups []PropertyGroup `xml:"PropertyGroup"`
}
type FileInfo ¶
type FileInfo struct {
Path string `json:"path"`
Language string `json:"language"`
LastModified string `json:"last_modified,omitempty"`
Contents string `json:"contents,omitempty"`
LineCount int `json:"line_count,omitempty"`
TokenCount int `json:"token_count"`
Contributors []string `json:"contributors"`
}
FileInfo represents information about a file in the project, including its content-related attributes
func CollectFiles ¶
func CollectFiles(dir string, ignores map[string]struct{}, alsoDocOrConf, alsoContributors, verbose bool) ([]FileInfo, error)
CollectFiles walks through a directory recursively and collects files that have the right extensions
func FindFileName ¶
FindFileName returns the first file that has a filename that matches the given string
type PomProject ¶
type ProjectInfo ¶
type ProjectInfo struct {
Name string `json:"name"`
RepoURL string `json:"repositoryURL"`
SourceFiles []FileInfo `json:"sourceFiles"`
ConfAndDocFiles []FileInfo `json:"confAndDocFiles"`
Type string `json:"type"`
Contributors string `json:"contributors"`
APIServer bool `json:"apiServer"`
}
ProjectInfo holds information about the entire project, useful for generating documentation or other reports.
func (*ProjectInfo) AllFiles ¶ added in v1.2.0
func (project *ProjectInfo) AllFiles() []FileInfo
type PropertyGroup ¶
type PropertyGroup struct {
ProjectName string `xml:"AssemblyName"`
}