chromedp/cmd/chromedp-gen/templates/file.qtpl

55 lines
1.5 KiB
Plaintext
Raw Normal View History

2017-01-24 15:09:23 +00:00
{% import (
"sort"
. "github.com/knq/chromedp/cmd/chromedp-gen/internal"
) %}
// FileHeader is the file header template.
{% func FileHeader(pkgName string, d *Domain) %}
{% if d != nil %}// Package {%s= d.PackageName() %} provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome {%s= d.String() %} domain.
// {% if desc := d.Description; desc != "" %}
{%s= formatComment(desc, "", "") %}
//{% endif %}
// Generated by the chromedp-gen command.{% end %}
package {%s= pkgName %}
// AUTOGENERATED. DO NOT EDIT.
{% endfunc %}
// FileLocalImportTemplate is a template for local imports.
{% func FileLocalImportTemplate(out string) %}
import (
. "{%s= out %}"
)
{% endfunc %}
// FileImportTemplate is a general import template.
{% func FileImportTemplate(m map[string]string) %}{% code
var keys []string
for k, _ := range m {
keys = append(keys, k)
}
sort.Strings(keys)
%}
import ({% for _, k := range keys %}{% code
v := m[k]
%}
{% if k != v %}{%s= v %} {% end %}"{%s= k %}"{% endfor %}
)
{% endfunc %}
// FileEmptyVarTemplate is a template that imports empty variable names.
{% func FileEmptyVarTemplate(m ...string) %}{% code
sort.Strings(m)
%}
var ({% for _, typ := range m %}
_ {%s= typ %}{% endfor %})
{% endfunc %}
// FileVarTemplate is a template for a single variable declaration.
{% func FileVarTemplate(name, value, desc string) %}
{% if desc != "" %}{%s= formatComment(desc, "", "") %}{% end %}
var {%s= name %} = {%s= value %}
{% endfunc %}