aboutsummaryrefslogtreecommitdiff
path: root/ciigo.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-10-10 01:43:02 +0700
committerShulhan <ms@kilabit.info>2021-10-10 01:43:02 +0700
commit88504a35592cf0c1a714d0a7454cdf95c7adec8b (patch)
treed6d74ccb0aaef9ca2ed816a5e5202a8cc02951e0 /ciigo.go
parentf48d930a6baec91815fe63e01cb16c4a71867922 (diff)
downloadciigo-88504a35592cf0c1a714d0a7454cdf95c7adec8b.tar.xz
all: refactoring with latest share module
The lates share module use the term GoEmbed to generate Go source file. In order for this repo in sync with upstream terminology and to minimize confusion, we changes the exported function and command name from "generate" to "embed", this includes * Command "ciigo generate" become "ciigo embed" * Exported function to generate Go renamed from "Generate" to "GoEmbed". This include the parameter GenerateOptions which renamed to EmbedOptions. * The internal command to generate example renamed from "generate" to "goembed"
Diffstat (limited to 'ciigo.go')
-rw-r--r--ciigo.go25
1 files changed, 13 insertions, 12 deletions
diff --git a/ciigo.go b/ciigo.go
index ae9d9c2..c551ddd 100644
--- a/ciigo.go
+++ b/ciigo.go
@@ -40,8 +40,8 @@ var (
//
// Convert all markup files inside directory "dir" recursively into HTML
-// files using "htmlTemplate" file as template.
-// If htmlTemplate is empty it will default to use embedded HTML template.
+// files using ConvertOptions HtmlTemplate file as base template.
+// If HtmlTemplate is empty it will default to use embedded HTML template.
// See template_index_html.go for template format.
//
func Convert(opts *ConvertOptions) (err error) {
@@ -75,25 +75,27 @@ func Convert(opts *ConvertOptions) (err error) {
}
//
-// Generate a static Go file to be used for building binary.
+// GoEmbed generate a static Go file that embed all files inside Root except
+// the one that being excluded explicitly by ConvertOptions Exclude.
//
-// It will convert all markup files inside directory "dir" into HTML files,
-// recursively; and read all the HTML files and files in "content/assets" and
-// convert them into Go file in "out".
+// It convert all markup files inside directory "dir" into HTML files,
+// recursively, and then embed them into Go file defined by
+// EmbedOptions.GoFileName.
//
-// If htmlTemplate is empty it will default to use embedded HTML template.
+// If HtmlTemplate option is empty it default to use embedded HTML
+// template.
// See template_index_html.go for template format.
//
-func Generate(opts *GenerateOptions) (err error) {
+func GoEmbed(opts *EmbedOptions) (err error) {
var (
- logp = "Generate"
+ logp = "GoEmbed"
htmlg *htmlGenerator
fileMarkups map[string]*fileMarkup
mfs *memfs.MemFS
)
if opts == nil {
- opts = &GenerateOptions{}
+ opts = &EmbedOptions{}
}
err = opts.init()
if err != nil {
@@ -128,8 +130,7 @@ func Generate(opts *GenerateOptions) (err error) {
}
}
- err = mfs.GoGenerate(opts.GenPackageName, opts.GenVarName,
- opts.GenGoFileName, memfs.EncodingGzip)
+ err = mfs.GoEmbed(opts.PackageName, opts.VarName, opts.GoFileName, memfs.EncodingGzip)
if err != nil {
return fmt.Errorf("%s: %w", logp, err)
}