language

package
v0.0.0-...-58c2bd7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DoubleSlash = CommentType{
		Regex:   `(?m)^\s*//.*?$`,
		Replace: []string{"//"},
	}
	DoubleSlashMultiLine = CommentType{
		Regex:   `(?s)/\*.*?\*/`,
		Replace: []string{"/*", "*/"},
	}
	Hash = CommentType{
		Regex:   `(?m)^\s*#.*?$`,
		Replace: []string{"#"},
	}
)

Functions

func DetectLanguage

func DetectLanguage(text string) map[string]float64

func DetectProgrammingLanguage

func DetectProgrammingLanguage(code, filename string) string

func ExtractComments

func ExtractComments(code string, commentType ...CommentType) []string

Types

type AnalyzedComment

type AnalyzedComment struct {
	Text string             `json:"text"`
	Lang map[string]float64 `json:"lang"`
}

func AnalyzeCode

func AnalyzeCode(code string, lang string) []AnalyzedComment

type CommentType

type CommentType struct {
	Regex   string `json:"regex"`
	Replace []string
}

type Lang

type Lang []CommentType

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL