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

40 lines
1.1 KiB
Plaintext
Raw Normal View History

2017-01-24 15:09:23 +00:00
{% import (
"sort"
2017-01-26 07:28:34 +00:00
"github.com/knq/chromedp/cmd/chromedp-gen/internal"
2017-01-24 15:09:23 +00:00
) %}
// FileHeader is the file header template.
2017-01-26 07:28:34 +00:00
{% func FileHeader(pkgName string, d *internal.Domain) %}
2017-01-24 15:09:23 +00:00
{% if d != nil %}// Package {%s= d.PackageName() %} provides the Chrome Debugging Protocol
// commands, types, and events for the {%s= d.String() %} domain.
2017-01-24 15:09:23 +00:00
// {% if desc := d.Description; desc != "" %}
{%s= formatComment(desc, "", "") %}
//{% endif %}
// Generated by the chromedp-gen command.{% endif %}
2017-01-24 15:09:23 +00:00
package {%s= pkgName %}
{%s= "// Code generated by chromedp-gen. DO NOT EDIT." %}
2017-01-24 15:09:23 +00:00
{% 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 %} {% endif %}"{%s= k %}"{% endfor %}
2017-01-24 15:09:23 +00:00
)
{% endfunc %}
// FileVarTemplate is a template for a single variable declaration.
{% func FileVarTemplate(name, value, desc string) %}
2017-01-26 07:28:34 +00:00
{%s= formatComment(desc, "", name+" ") %}
2017-01-24 15:09:23 +00:00
var {%s= name %} = {%s= value %}
{% endfunc %}