Documentation
¶
Overview ¶
Copyright 2021 Lee R. Boynton
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 Lee R. Boynton
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 Lee R. Boynton
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 Lee R. Boynton
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 Lee R. Boynton
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 Lee R. Boynton
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 Lee R. Boynton
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 Lee R. Boynton
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func Capitalize(s string) string
- func Debug(args ...interface{})
- func FormatComment(indent, prefix, comment string, maxcol int, extraPad bool) string
- func FormattedAnnotation(filename string, source string, prefix string, msg string, tok *Token, ...) string
- func IsDigit(ch rune) bool
- func IsLetter(ch rune) bool
- func IsLowercaseLetter(ch rune) bool
- func IsPreludeType(name string) bool
- func IsSymbolChar(ch rune, first bool) bool
- func IsUppercaseLetter(ch rune) bool
- func IsWhitespace(ch rune) bool
- func StripNamespace(target string) string
- func TrimLeftSpace(s string) string
- func TrimRightSpace(s string) string
- func TrimSpace(s string) string
- func Uncapitalize(s string) string
- type AST
- func (ast *AST) ExternalRefs(ns string) []string
- func (ast *AST) Filter(tags []string)
- func (ast *AST) GetShape(id string) *Shape
- func (ast *AST) IDL(ns string) string
- func (ast *AST) Merge(src *AST) error
- func (ast *AST) NamespaceAndServiceVersion() (string, string, string)
- func (ast *AST) Namespaces() []string
- func (ast *AST) PutShape(id string, shape *Shape)
- func (ast *AST) RequiresDocumentType() bool
- func (ast *AST) ShapeNames() []string
- func (ast *AST) Validate() error
- type AstGenerator
- type BaseGenerator
- func (gen *BaseGenerator) Configure(conf *data.Object) error
- func (gen *BaseGenerator) Emit(text string, filename string, separator string) error
- func (gen *BaseGenerator) FileExists(path string) bool
- func (gen *BaseGenerator) FileName(ns string, suffix string) string
- func (gen *BaseGenerator) WriteFile(path string, content string) error
- type Generator
- type IdlGenerator
- type IdlWriter
- func (w *IdlWriter) Begin()
- func (w *IdlWriter) Emit(format string, args ...interface{})
- func (w *IdlWriter) EmitBlobShape(name string, shape *Shape)
- func (w *IdlWriter) EmitBooleanShape(name string, shape *Shape)
- func (w *IdlWriter) EmitBooleanTrait(b bool, tname, indent string)
- func (w *IdlWriter) EmitCollectionShape(shapeName, name string, shape *Shape)
- func (w *IdlWriter) EmitCustomTrait(k string, v interface{}, indent string)
- func (w *IdlWriter) EmitDeprecatedTrait(v interface{}, indent string)
- func (w *IdlWriter) EmitDocumentation(doc, indent string)
- func (w *IdlWriter) EmitEnumTrait(v interface{}, indent string)
- func (w *IdlWriter) EmitExamplesTrait(opname string, raw interface{})
- func (w *IdlWriter) EmitHttpErrorTrait(rv interface{}, indent string)
- func (w *IdlWriter) EmitHttpTrait(rv interface{}, indent string)
- func (w *IdlWriter) EmitLengthTrait(v interface{}, indent string)
- func (w *IdlWriter) EmitMapShape(name string, shape *Shape)
- func (w *IdlWriter) EmitNumericShape(shapeName, name string, shape *Shape)
- func (w *IdlWriter) EmitOperationShape(name string, shape *Shape)
- func (w *IdlWriter) EmitPaginatedTrait(d interface{})
- func (w *IdlWriter) EmitRangeTrait(v interface{}, indent string)
- func (w *IdlWriter) EmitResourceShape(name string, shape *Shape)
- func (w *IdlWriter) EmitServiceShape(name string, shape *Shape)
- func (w *IdlWriter) EmitShape(name string, shape *Shape)
- func (w *IdlWriter) EmitSimpleShape(shapeName, name string)
- func (w *IdlWriter) EmitStringShape(name string, shape *Shape)
- func (w *IdlWriter) EmitStringTrait(v, tname, indent string)
- func (w *IdlWriter) EmitStructureShape(name string, shape *Shape)
- func (w *IdlWriter) EmitTagsTrait(v interface{}, indent string)
- func (w *IdlWriter) EmitTimestampShape(name string, shape *Shape)
- func (w *IdlWriter) EmitTraitTrait(v interface{})
- func (w *IdlWriter) EmitTraits(traits *data.Object, indent string)
- func (w *IdlWriter) EmitUnionShape(name string, shape *Shape)
- func (w *IdlWriter) End() string
- type Member
- type Members
- type Parser
- func (p *Parser) EndOfFileError() error
- func (p *Parser) Error(msg string) error
- func (p *Parser) ExpectIdentifier() (string, error)
- func (p *Parser) ExpectIdentifierArray() ([]string, error)
- func (p *Parser) ExpectIdentifierMap() (map[string]string, error)
- func (p *Parser) ExpectInt() (int, error)
- func (p *Parser) ExpectNumber() (*data.Decimal, error)
- func (p *Parser) ExpectString() (string, error)
- func (p *Parser) ExpectStringArray() ([]string, error)
- func (p *Parser) GetToken() *Token
- func (p *Parser) MergeComment(comment1 string, comment2 string) string
- func (p *Parser) Parse() error
- func (p *Parser) SyntaxError() error
- func (p *Parser) UngetToken()
- type SadlGenerator
- type SadlWriter
- func (w *SadlWriter) Begin()
- func (w *SadlWriter) Emit(format string, args ...interface{})
- func (w *SadlWriter) EmitBlobShape(name string, shape *Shape)
- func (w *SadlWriter) EmitBooleanShape(name string, shape *Shape)
- func (w *SadlWriter) EmitCollectionShape(shapeName, name string, shape *Shape)
- func (w *SadlWriter) EmitEnum(name string, shape *Shape, lst []interface{})
- func (w *SadlWriter) EmitMapShape(name string, shape *Shape)
- func (w *SadlWriter) EmitNumericShape(shapeName, name string, shape *Shape)
- func (w *SadlWriter) EmitOperationShape(name string, shape *Shape, opts []string)
- func (w *SadlWriter) EmitShape(name string, shape *Shape)
- func (w *SadlWriter) EmitShapeComment(shape *Shape)
- func (w *SadlWriter) EmitStringShape(name string, shape *Shape)
- func (w *SadlWriter) EmitStructureShape(name string, shape *Shape, opts []string)
- func (w *SadlWriter) EmitTimestampShape(name string, shape *Shape)
- func (w *SadlWriter) EmitUnionShape(name string, shape *Shape)
- func (w *SadlWriter) End() string
- type Scanner
- type Shape
- type ShapeRef
- type Shapes
- type Token
- type TokenType
Constants ¶
const BLACK = "\033[0;0m"
const BLUE = "\033[94m"
const GREEN = "\033[92m"
const IndentAmount = " "
const RED = "\033[0;31m"
const SmithyVersion = "1.0"
const UnspecifiedNamespace = "example"
const UnspecifiedVersion = "0.0"
const YELLOW = "\033[0;33m"
Variables ¶
var ToolVersion string = "development version"
var Verbose bool
Functions ¶
func Capitalize ¶
func FormatComment ¶
func FormattedAnnotation ¶
func IsLowercaseLetter ¶
func IsPreludeType ¶
func IsSymbolChar ¶
func IsUppercaseLetter ¶
func IsWhitespace ¶
func StripNamespace ¶
func TrimLeftSpace ¶ added in v0.1.2
func TrimRightSpace ¶ added in v0.1.2
func Uncapitalize ¶
Types ¶
type AST ¶
type AST struct {
Smithy string `json:"smithy"`
Metadata *data.Object `json:"metadata,omitempty"`
Shapes *Shapes `json:"shapes,omitempty"`
}
func (*AST) ExternalRefs ¶
func (*AST) NamespaceAndServiceVersion ¶
ASTs don't have a preferred namespace, but IDL files do. When going back to IDL, getting the preferred namespace is desirable. The algorithm here is to prefer the first service's namespace, if present, or the first non-smithy, non-aws namespace encountered.
func (*AST) Namespaces ¶ added in v0.2.6
func (*AST) RequiresDocumentType ¶ added in v0.2.4
func (*AST) ShapeNames ¶ added in v0.2.6
type AstGenerator ¶
type AstGenerator struct {
BaseGenerator
}
type BaseGenerator ¶
type BaseGenerator struct {
Config *data.Object
OutDir string
ForceOverwrite bool
Err error
// contains filtered or unexported fields
}
func (*BaseGenerator) Configure ¶ added in v0.1.2
func (gen *BaseGenerator) Configure(conf *data.Object) error
func (*BaseGenerator) Emit ¶ added in v0.1.2
func (gen *BaseGenerator) Emit(text string, filename string, separator string) error
func (*BaseGenerator) FileExists ¶
func (gen *BaseGenerator) FileExists(path string) bool
type IdlGenerator ¶
type IdlGenerator struct {
BaseGenerator
}
type IdlWriter ¶
type IdlWriter struct {
// contains filtered or unexported fields
}
func (*IdlWriter) EmitBlobShape ¶
func (*IdlWriter) EmitBooleanShape ¶
func (*IdlWriter) EmitBooleanTrait ¶
func (*IdlWriter) EmitCollectionShape ¶
func (*IdlWriter) EmitCustomTrait ¶
func (*IdlWriter) EmitDeprecatedTrait ¶
func (*IdlWriter) EmitDocumentation ¶
func (*IdlWriter) EmitEnumTrait ¶
func (*IdlWriter) EmitExamplesTrait ¶
func (*IdlWriter) EmitHttpErrorTrait ¶
func (*IdlWriter) EmitHttpTrait ¶
func (*IdlWriter) EmitLengthTrait ¶
func (*IdlWriter) EmitMapShape ¶
func (*IdlWriter) EmitNumericShape ¶
func (*IdlWriter) EmitOperationShape ¶
func (*IdlWriter) EmitPaginatedTrait ¶
func (w *IdlWriter) EmitPaginatedTrait(d interface{})
func (*IdlWriter) EmitRangeTrait ¶
func (*IdlWriter) EmitResourceShape ¶
func (*IdlWriter) EmitServiceShape ¶
func (*IdlWriter) EmitSimpleShape ¶
func (*IdlWriter) EmitStringShape ¶
func (*IdlWriter) EmitStringTrait ¶
func (*IdlWriter) EmitStructureShape ¶
func (*IdlWriter) EmitTagsTrait ¶
func (*IdlWriter) EmitTimestampShape ¶
func (*IdlWriter) EmitTraitTrait ¶
func (w *IdlWriter) EmitTraitTrait(v interface{})
func (*IdlWriter) EmitUnionShape ¶
type Members ¶ added in v0.2.0
type Members struct {
// contains filtered or unexported fields
}
a Members object is a map from string to *Member. It preserves the order of its keys, unlike a Go map
func NewMembers ¶ added in v0.2.6
func NewMembers() *Members
func (Members) MarshalJSON ¶ added in v0.2.0
func (*Members) UnmarshalJSON ¶ added in v0.2.0
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) EndOfFileError ¶
func (*Parser) ExpectIdentifier ¶
func (*Parser) ExpectIdentifierArray ¶
func (*Parser) ExpectIdentifierMap ¶
func (*Parser) ExpectString ¶
func (*Parser) ExpectStringArray ¶
func (*Parser) MergeComment ¶
func (*Parser) SyntaxError ¶
func (*Parser) UngetToken ¶
func (p *Parser) UngetToken()
type SadlGenerator ¶ added in v0.2.0
type SadlGenerator struct {
BaseGenerator
}
type SadlWriter ¶ added in v0.2.0
type SadlWriter struct {
// contains filtered or unexported fields
}
func (*SadlWriter) Begin ¶ added in v0.2.0
func (w *SadlWriter) Begin()
func (*SadlWriter) Emit ¶ added in v0.2.0
func (w *SadlWriter) Emit(format string, args ...interface{})
func (*SadlWriter) EmitBlobShape ¶ added in v0.2.0
func (w *SadlWriter) EmitBlobShape(name string, shape *Shape)
func (*SadlWriter) EmitBooleanShape ¶ added in v0.2.0
func (w *SadlWriter) EmitBooleanShape(name string, shape *Shape)
func (*SadlWriter) EmitCollectionShape ¶ added in v0.2.0
func (w *SadlWriter) EmitCollectionShape(shapeName, name string, shape *Shape)
func (*SadlWriter) EmitEnum ¶ added in v0.2.0
func (w *SadlWriter) EmitEnum(name string, shape *Shape, lst []interface{})
func (*SadlWriter) EmitMapShape ¶ added in v0.2.0
func (w *SadlWriter) EmitMapShape(name string, shape *Shape)
func (*SadlWriter) EmitNumericShape ¶ added in v0.2.0
func (w *SadlWriter) EmitNumericShape(shapeName, name string, shape *Shape)
func (*SadlWriter) EmitOperationShape ¶ added in v0.2.0
func (w *SadlWriter) EmitOperationShape(name string, shape *Shape, opts []string)
func (*SadlWriter) EmitShape ¶ added in v0.2.0
func (w *SadlWriter) EmitShape(name string, shape *Shape)
func (*SadlWriter) EmitShapeComment ¶ added in v0.2.0
func (w *SadlWriter) EmitShapeComment(shape *Shape)
func (*SadlWriter) EmitStringShape ¶ added in v0.2.0
func (w *SadlWriter) EmitStringShape(name string, shape *Shape)
func (*SadlWriter) EmitStructureShape ¶ added in v0.2.0
func (w *SadlWriter) EmitStructureShape(name string, shape *Shape, opts []string)
func (*SadlWriter) EmitTimestampShape ¶ added in v0.2.0
func (w *SadlWriter) EmitTimestampShape(name string, shape *Shape)
func (*SadlWriter) EmitUnionShape ¶ added in v0.2.0
func (w *SadlWriter) EmitUnionShape(name string, shape *Shape)
func (*SadlWriter) End ¶ added in v0.2.0
func (w *SadlWriter) End() string
type Shape ¶
type Shape struct {
Type string `json:"type"`
Traits *data.Object `json:"traits,omitempty"` //service, resource, operation, apply
//List and Set
Member *Member `json:"member,omitempty"`
//Map
Key *Member `json:"key,omitempty"`
Value *Member `json:"value,omitempty"`
//Structure and Union
Members *Members `json:"members,omitempty"` //keys must be case-insensitively unique. For union, len(Members) > 0,
//Resource
Identifiers map[string]*ShapeRef `json:"identifiers,omitempty"`
//FIXME preserve resource identifier order?
Create *ShapeRef `json:"create,omitempty"`
Put *ShapeRef `json:"put,omitempty"`
Read *ShapeRef `json:"read,omitempty"`
Update *ShapeRef `json:"update,omitempty"`
Delete *ShapeRef `json:"delete,omitempty"`
List *ShapeRef `json:"list,omitempty"`
CollectionOperations []*ShapeRef `json:"collectionOperations,omitempty"`
//Resource and Service
Operations []*ShapeRef `json:"operations,omitempty"`
Resources []*ShapeRef `json:"resources,omitempty"`
//Operation
Input *ShapeRef `json:"input,omitempty"`
Output *ShapeRef `json:"output,omitempty"`
Errors []*ShapeRef `json:"errors,omitempty"`
//Service
Version string `json:"version,omitempty"`
}
type Shapes ¶
type Shapes struct {
// contains filtered or unexported fields
}
a Shapes object is a map from Shape ID to *Shape. It preserves the order of its keys, unlike a Go map