mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-27 22:57:50 -03:00
Squashed 'go-enry/' content from commit 7e3a9a7
git-subtree-dir: go-enry
git-subtree-split: 7e3a9a7241
This commit is contained in:
30
internal/code-generator/generator/documentation.go
Normal file
30
internal/code-generator/generator/documentation.go
Normal file
@ -0,0 +1,30 @@
|
||||
package generator
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// Documentation generates regex matchers in Go for documentation files/dirs.
|
||||
// It is of generator.File type.
|
||||
func Documentation(fileToParse, _, outFile, tmplPath, tmplName, commit string) error {
|
||||
data, err := ioutil.ReadFile(fileToParse)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var regexpList []string
|
||||
if err := yaml.Unmarshal(data, ®expList); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
err = executeTemplate(buf, tmplName, tmplPath, commit, nil, regexpList)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return formatedWrite(outFile, buf.Bytes())
|
||||
}
|
Reference in New Issue
Block a user