Skip to content

Commit

Permalink
Addressing NITs raised in 1375 to improve the documentation of the sc…
Browse files Browse the repository at this point in the history
…affolder

Signed-off-by: Adrian Orive <[email protected]>
  • Loading branch information
Adirio committed Feb 25, 2020
1 parent 18721ec commit 232a8d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/model/file/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type Template interface {
Builder
// GetBody returns the template body
GetBody() string
// SetTemplateDefaults returns the TemplateMixin for creating a scaffold file
// SetTemplateDefaults sets the default values for templates
SetTemplateDefaults() error
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/model/file/marker.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ var commentsByExt = map[string]string{
// this is a backwards incompatible change, and thus should be done for next project version.
".go": "// ",
".yaml": "# ",
// When adding additional file extensions, update also the NewMarkerFor documentation and error
}

// Marker represents a comment LoC that will be used to insert code fragments by update operations
// Marker represents a machine-readable comment that will be used for scaffolding purposes
type Marker struct {
comment string
value string
}

// NewMarkerFor creates a new marker customized for the specific file
// Supported file extensions: .go, .ext
func NewMarkerFor(path string, value string) Marker {
ext := filepath.Ext(path)
if comment, found := commentsByExt[ext]; found {
Expand All @@ -51,6 +53,9 @@ func (m Marker) String() string {
return m.comment + prefix + m.value
}

// CodeFragments represents a set of code fragments
// A code fragment is a piece of code provided as a Go string, it may have multiple lines
type CodeFragments []string

// CodeFragmentsMap binds Markers and CodeFragments together
type CodeFragmentsMap map[Marker]CodeFragments

0 comments on commit 232a8d0

Please sign in to comment.