Documentation ¶
Index ¶
- Constants
- Variables
- func CDPTypeList() []string
- func ForceCamel(s string) string
- func ForceCamelWithFirstLower(s string) string
- func IsCDPType(dtyp DomainType, typ string) bool
- func SetCDPTypes(types map[string]bool)
- type Bool
- type Domain
- type DomainType
- type HandlerType
- type ProtocolInfo
- type Type
- func (t *Type) Base64EncodedRetParam() *Type
- func (t *Type) CamelName() string
- func (t *Type) CommandMethodType(d *Domain) string
- func (t *Type) CommandReturnsType() string
- func (t *Type) CommandType() string
- func (t *Type) EmptyRetList(d *Domain, domains []*Domain) string
- func (t *Type) EnumValueName(v string) string
- func (t *Type) EnumValues() []string
- func (t *Type) EventMethodType(d *Domain) string
- func (t *Type) EventType() string
- func (t *Type) GetDescription() string
- func (t *Type) GoEmptyValue(d *Domain, domains []*Domain) string
- func (t *Type) GoName(noExposeOverride bool) string
- func (t *Type) GoType(d *Domain, domains []*Domain) string
- func (t *Type) GoTypeDef(d *Domain, domains []*Domain, extra []*Type, ...) string
- func (t Type) IdOrName() string
- func (t *Type) ParamList(d *Domain, domains []*Domain, all bool) string
- func (t *Type) ProtoName(d *Domain) string
- func (t *Type) ResolveType(d *Domain, domains []*Domain) (DomainType, *Type, string)
- func (t *Type) RetTypeList(d *Domain, domains []*Domain) string
- func (t *Type) RetValueList(d *Domain, domains []*Domain) string
- func (t Type) String() string
- func (t *Type) TypeName(prefix, suffix string) string
- type TypeEnum
- type Version
Constants ¶
const ( // Base64EncodedParamName is the base64encoded variable name in command // return values when they are optionally base64 encoded. Base64EncodedParamName = "base64Encoded" // Base64EncodedDescriptionPrefix is the prefix for command return // description prefix when base64 encoded. Base64EncodedDescriptionPrefix = "Base64-encoded" )
Variables ¶
var ( FlagPkg = FlagSet.String("pkg", "github.com/knq/chromedp/cdp", "output package") FlagFile = FlagSet.String("file", "protocol.json", "path to chrome protocol.json") FlagDep = FlagSet.Bool("dep", false, "toggle deprecated API generation") FlagExp = FlagSet.Bool("exp", true, "toggle experimental API generation") FlagRedirect = FlagSet.Bool("redirect", false, "toggle redirect API generation") FlagNoRemove = FlagSet.Bool("noremove", false, "toggle to not remove existing package directory") )
The application flags.
var ( DomainTypePrefix = "" DomainTypeSuffix = "" TypePrefix = "" TypeSuffix = "" EventMethodPrefix = "Event" EventMethodSuffix = "" CommandMethodPrefix = "Command" CommandMethodSuffix = "" EventTypePrefix = "Event" EventTypeSuffix = "" CommandTypePrefix = "" CommandTypeSuffix = "Params" CommandReturnsPrefix = "" CommandReturnsSuffix = "Returns" OptionFuncPrefix = "With" OptionFuncSuffix = "" )
Prefix and suffix values.
var CodeRE = regexp.MustCompile(`<\/?code>`)
CodeRE is a regexp to match <code> and </code> tags.
var FlagSet = &flag.FlagSet{}
FlagSet is the set of application flags.
Functions ¶
func ForceCamelWithFirstLower ¶
ForceCamelWithFirstLower forces the first portion to be lower case.
func IsCDPType ¶
func IsCDPType(dtyp DomainType, typ string) bool
IsCDPType determines if the specified domain and typ constitute an internal type.
Types ¶
type Bool ¶
type Bool bool
Bool provides a type for handling incorrectly quoted boolean values in the protocol.json file.
func (Bool) MarshalJSON ¶
MarshalJSON marshals the bool into its corresponding JSON representation.
func (*Bool) UnmarshalJSON ¶
UnmarshalJSON unmarshals a possibly quoted string representation of a bool (ie, true, "true", false, "false").
type Domain ¶
type Domain struct { // Domain is the name of the domain. Domain DomainType `json:"domain,omitempty"` // Description is the domain description. Description string `json:"description,omitempty"` // Experimental indicates whether or not the domain is experimental. Experimental Bool `json:"experimental,omitempty"` // Deprecated indicates whether or not the domain is deprecated. Deprecated Bool `json:"deprecated,omitempty"` // Types are the list of types in the domain. Types []*Type `json:"types,omitempty"` // Commands are the list of command types in the domain. Commands []*Type `json:"commands,omitempty"` // Events is the list of events types in the domain. Events []*Type `json:"events,omitempty"` }
Domain represents a Chrome Debugging Protocol domain.
func (*Domain) DomainType ¶
DomainType returns the name of the type to use for the domain.
func (*Domain) GetDescription ¶
GetDescription returns the formatted description of the domain.
func (*Domain) PackageImportAlias ¶
PackageImportAlias returns the Go import package name alias to use for the domain, or the empty string.
func (*Domain) PackageName ¶
PackageName returns the Go package name to use for the domain.
func (*Domain) PackageRefName ¶
PackageRefName returns the Go package name to use for the domain.
type DomainType ¶
type DomainType string
DomainType is the Chrome domain type.
const ( DomainAccessibility DomainType = "Accessibility" DomainAnimation DomainType = "Animation" DomainApplicationCache DomainType = "ApplicationCache" DomainCacheStorage DomainType = "CacheStorage" DomainConsole DomainType = "Console" DomainCSS DomainType = "CSS" DomainDatabase DomainType = "Database" DomainDebugger DomainType = "Debugger" DomainDeviceOrientation DomainType = "DeviceOrientation" DomainDOM DomainType = "DOM" DomainDOMDebugger DomainType = "DOMDebugger" DomainDOMStorage DomainType = "DOMStorage" DomainEmulation DomainType = "Emulation" DomainHeapProfiler DomainType = "HeapProfiler" DomainIndexedDB DomainType = "IndexedDB" DomainInput DomainType = "Input" DomainInspector DomainType = "Inspector" DomainIO DomainType = "IO" DomainLayerTree DomainType = "LayerTree" DomainLog DomainType = "Log" DomainMemory DomainType = "Memory" DomainNetwork DomainType = "Network" DomainPage DomainType = "Page" DomainProfiler DomainType = "Profiler" DomainRendering DomainType = "Rendering" DomainRuntime DomainType = "Runtime" DomainSchema DomainType = "Schema" DomainSecurity DomainType = "Security" DomainServiceWorker DomainType = "ServiceWorker" DomainStorage DomainType = "Storage" DomainSystemInfo DomainType = "SystemInfo" DomainTarget DomainType = "Target" DomainTethering DomainType = "Tethering" DomainTracing DomainType = "Tracing" )
generated with: '<,'>s/^\(.*\)$/Domain\1 DomainType = "\1"/
func (DomainType) MarshalJSON ¶
func (dt DomainType) MarshalJSON() ([]byte, error)
MarshalJSON satisfies json.Marshaler.
func (*DomainType) UnmarshalJSON ¶
func (dt *DomainType) UnmarshalJSON(buf []byte) error
UnmarshalJSON satisfies json.Unmarshaler.
type HandlerType ¶
type HandlerType string
HandlerType are the handler targets for commands and events.
const ( HandlerTypeBrowser HandlerType = "browser" HandlerTypeRenderer HandlerType = "renderer" )
HandlerType values.
func (HandlerType) MarshalJSON ¶
func (ht HandlerType) MarshalJSON() ([]byte, error)
MarshalJSON satisfies json.Marshaler.
func (*HandlerType) UnmarshalJSON ¶
func (ht *HandlerType) UnmarshalJSON(buf []byte) error
UnmarshalJSON satisfies json.Unmarshaler.
type ProtocolInfo ¶
type ProtocolInfo struct { // Version contains the protocol version information. Version *Version `json:"version,omitempty"` // Domains lists the available domains in the protocol. Domains []*Domain `json:"domains,omitempty"` }
ProtocolInfo holds information about the Chrome Debugging Protocol.
type Type ¶
type Type struct { // Type is the provided type enum. Type TypeEnum `json:"type,omitempty"` // ID is the ID of the type when type is an object. ID string `json:"id,omitempty"` // Name is the type name. Name string `json:"name,omitempty"` // Description is the type description. Description string `json:"description,omitempty"` // Optional indicates if the type is optional. Used for commands and event parameters. Optional Bool `json:"optional,omitempty"` // Deprecated indicates if the type is deprecated. Used for commands and event parameters. Deprecated Bool `json:"deprecated,omitempty"` // Enum are the enum values for the type (only used when type is string -- // a non empty slice marks the type as a "enum"). Enum []string `json:"enum,omitempty"` // Ref is the ID of a referenced type when type points to another type. Ref string `json:"$ref,omitempty"` // Items is the type of contained values in the array when type is array. Items *Type `json:"items,omitempty"` // Properties are the properties of the object when type is object. Properties []*Type `json:"properties,omitempty"` // Parameters is the command or event parameters. Parameters []*Type `json:"parameters,omitempty"` // Returns is the return value types. Returns []*Type `json:"returns,omitempty"` // MinItems is the minimum number of items when type is array. MinItems int64 `json:"minItems,omitempty"` // MaxItems is the maximum number of items when type is array. MaxItems int64 `json:"maxItems,omitempty"` // Handlers are the listed handlers for the command or event. Handlers []HandlerType `json:"handlers,omitempty"` // Redirect is the redirect value for the command or event. Redirect DomainType `json:"redirect,omitempty"` // NoExpose toggles whether or not to expose the type. NoExpose bool `json:"-"` // NoResolve toggles not resolving the type to a domain (ie, for special internal types). NoResolve bool `json:"-"` // EnumValueNameMap is a map to override the generated enum value name. EnumValueNameMap map[string]string `json:"-"` // EnumBitMask toggles it as a bit mask enum for TypeInteger enums. EnumBitMask bool `json:"-"` // Extra will be added as output after the the type is emitted. Extra string `json:"-"` }
Type represents a type available to the domain.
func (*Type) Base64EncodedRetParam ¶
Base64EncodedRetParam returns the base64 encoded return parameter, or nil if no parameters are base64 encoded.
func (*Type) CommandMethodType ¶
CommandMethodType returns the method type of the event.
func (*Type) CommandReturnsType ¶
CommandReturnsType returns the type of the command return type.
func (*Type) CommandType ¶
CommandType returns the type of the command.
func (*Type) EmptyRetList ¶
EmptyRetList returns a list of the empty return values.
func (*Type) EnumValueName ¶
EnumValueName returns the name for a enum value.
func (*Type) EnumValues ¶
EnumValues returns enum values for the type.
func (*Type) EventMethodType ¶
EventMethodType returns the method type of the event.
func (*Type) GetDescription ¶
GetDescription returns the cleaned description for the type.
func (*Type) GoEmptyValue ¶
GoEmptyValue returns the empty Go value for the type.
func (*Type) GoTypeDef ¶
func (t *Type) GoTypeDef(d *Domain, domains []*Domain, extra []*Type, noExposeOverride, omitOnlyWhenOptional bool) string
GoTypeDef returns the Go type definition for the type.
func (*Type) ResolveType ¶
ResolveType resolves the type relative to the Go domain.
Returns the DomainType of the underlying type, the underlying type (or the original passed type if not a reference) and the fully qualified name type name.
func (*Type) RetTypeList ¶
RetTypeList returns a list of the return types.
func (*Type) RetValueList ¶
RetValueList returns the return value list for a command.
type TypeEnum ¶
type TypeEnum string
TypeEnum is the Chrome domain type enum.
const ( TypeAny TypeEnum = "any" TypeArray TypeEnum = "array" TypeBoolean TypeEnum = "boolean" TypeInteger TypeEnum = "integer" TypeNumber TypeEnum = "number" TypeObject TypeEnum = "object" TypeString TypeEnum = "string" TypeTimestamp TypeEnum = "timestamp" )
TypeEnum values.
func (TypeEnum) GoEmptyValue ¶
GoEmptyValue returns the Go empty value for the TypeEnum.
func (TypeEnum) MarshalJSON ¶
MarshalJSON satisfies json.Marshaler.
func (*TypeEnum) UnmarshalJSON ¶
UnmarshalJSON satisfies json.Unmarshaler.