step

package
v0.0.0-...-201b726 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const COMMENT_DEFINE_FILE = CONFIG_PATH + "comment_define.json"

注释定义文件路径

View Source
const CONFIG_PATH = "./config_step/"

程序设置文件

View Source
const LOG = "bslog.log"

日志

View Source
const SETTING_FILE = CONFIG_PATH + "setting.yml"

程序设置文件

Variables

View Source
var BLogger *logs.BeeLogger

日志记录器

View Source
var LangPos string = "xx"

语言

View Source
var Message map[string]string

提示信息Map

View Source
var MessageFile string = "message_xx.json"

提示信息文件

Functions

func Count

func Count(file string, mCommentRegExp *map[string]CommentRegExp, stepInfo *[]StepInfo) error

统计单文件代码行数

func GetAllRegExp

func GetAllRegExp(commentDefineFile string) (map[string]CommentRegExp, error)

从注释定义文件中取得注释正则表达式

func MatchIn

func MatchIn(line string, regexList []*regexp.Regexp) (matchIndex int, isMatch bool)

多个标志的正则表达式确认

Types

type CommentDefine

type CommentDefine struct {
	// 扩展名(多个)
	FileExtension []string
	// 单行正则表达式
	SingleLine []string
	// 多行正则表达式 开始
	MultiLineStart []string
	// 多行正则表达式 结束
	MultiLineEnd []string
}

代码注释统计用正则表达式定义

type CommentRegExp

type CommentRegExp struct {
	// 扩展名
	FileExtFlag string
	// 扩展名(多个)
	FileExtension []string
	// 有单行注释
	HasSingleLineMark bool
	// 有多行注释
	HasMultiLineMark bool

	// 空正则表达式
	RegExEmptyLine *regexp.Regexp
	// 单行正则表达式
	RegExSingleLine []*regexp.Regexp
	// 写在单行的多行正则表达式 开始结束
	RegExSingleLineStartEnd []*regexp.Regexp
	// 多行正则表达式 开始
	RegExMultiLineStart []*regexp.Regexp
	// 多行正则表达式 结束
	RegExMultiLineEnd []*regexp.Regexp
}

代码注释统计用正则表达式定义

func ToRegExp

func ToRegExp(ext string, def CommentDefine) CommentRegExp

转换为正则表达式

type Setting

type Setting struct {
	Language string `yaml:"language"`
	LogFile  string `yaml:"logfile"`
	LogLevel string `yaml:"loglevel"`
}

程序设置(对应程序设置yaml文件)

type StepInfo

type StepInfo struct {
	File          string `json:"file"`          // 文件名(全路径)
	FileName      string `json:"fileName"`      // 文件名
	TotalStep     int    `json:"totalStep"`     // 总行数
	EmptyLineStep int    `json:"emptyLineStep"` // 空行数
	CommentStep   int    `json:"commentStep"`   // 注释行数
	SourceStep    int    `json:"sourceStep"`    // 代码行数
	ValidStep     int    `json:"validStep"`     // 有效行数(注释+代码)
	ExInfo        string `json:"exInfo"`        // 扩展信息
	Counted       bool   `json:"counted"`       // 已统计标志 true:已统计 false:未统计
}

代码行数信息

func CountAll

func CountAll(file []string, mCommentRegExp *map[string]CommentRegExp) []StepInfo

统计多文件代码行数

func (StepInfo) ToString

func (step StepInfo) ToString() string

代码信息 字符串

type StepOption

type StepOption struct {
	File   string              `yaml:"file"`   // 单文件(命令行模式)
	Option common.SearchOption `yaml:"option"` // 代码文件搜索选项
	// 导出用
	ResultFile   string `yaml:"resultFile"`   // 统计结果输出文件
	StepInfoText string `json:"stepInfoText"` // 代码行数统计结果(文本)
	ExInfo       string `json:"exInfo"`       // 附加信息
}

统计选项

type StepResult

type StepResult struct {
	StepInfo     []StepInfo `json:"stepInfo"`     // 代码行数统计结果
	StepInfoText []string   `json:"stepInfoText"` // 代码行数统计结果(文本)
	NoneStepFile []string   `json:"noneStepFile"` // 未统计文件一览
	ExInfo       []string   `json:"exInfo"`       // 运行信息
}

代码行数统计结果

func Step

func Step(stepOption StepOption, mCommentRegExp map[string]CommentRegExp) StepResult

执行统计代码

Jump to

Keyboard shortcuts

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