整理打印
This commit is contained in:
@@ -124,6 +124,14 @@ func parseFunctions(lines []string, exportedFunctions map[string]bool) []ErlangF
|
||||
inFunction = false
|
||||
currentFunction = ErlangFunction{}
|
||||
}
|
||||
|
||||
// 函数结束条件:行以 ; 结束,且括号和花括号匹配
|
||||
if strings.HasSuffix(trimmedLine, ";") && braceCount == 0 && parenCount == 0 {
|
||||
currentFunction.EndLine = i + 1
|
||||
functions = append(functions, currentFunction.ParseComments())
|
||||
inFunction = false
|
||||
currentFunction = ErlangFunction{}
|
||||
}
|
||||
} else {
|
||||
// 不在函数中时,遇到非注释行就清空注释缓存
|
||||
if trimmedLine != "" && !strings.HasPrefix(trimmedLine, "%") {
|
||||
|
||||
@@ -51,3 +51,22 @@ func FprintfArgsMap(layer int, out io.Writer, argsMap map[string]any) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// FindPathByWd 返回目录基于执行目录
|
||||
func FindPathByWd(path string) (string, error) {
|
||||
return FindPathByBasePath(os.Getwd, path)
|
||||
}
|
||||
|
||||
// FindPathByExecutable 返回目录基于exe路径
|
||||
func FindPathByExecutable(path string) (string, error) {
|
||||
return FindPathByBasePath(os.Executable, path)
|
||||
}
|
||||
|
||||
func FindPathByBasePath(basefun func() (basePath string, err error), path string) (string, error) {
|
||||
basePath, err := basefun()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
path = filepath.Join(filepath.Dir(basePath), path)
|
||||
return path, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user