tartrazine/internal/code-generator/generator/documentation.go

31 lines
627 B
Go
Raw Normal View History

package generator
import (
"bytes"
2017-06-13 11:56:07 +00:00
"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 {
2017-06-13 11:56:07 +00:00
data, err := ioutil.ReadFile(fileToParse)
if err != nil {
return err
}
var regexpList []string
if err := yaml.Unmarshal(data, &regexpList); err != nil {
2017-06-13 11:56:07 +00:00
return err
}
buf := &bytes.Buffer{}
err = executeTemplate(buf, tmplName, tmplPath, commit, nil, regexpList)
if err != nil {
2017-06-13 11:56:07 +00:00
return err
}
return formatedWrite(outFile, buf.Bytes())
}