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