Documentation ¶
Overview ¶
Package comment provides facilities for parsing comments out of a YAML sequence or mapping node recursively, keeping them as a Comment struct instance, and merging them in another YAML parsed node, so comments may be preserved when that YAML node is serialized again.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comment ¶
type Comment struct {
// contains filtered or unexported fields
}
Comment struct contains the head-comments for a sequence or mapping yaml node instance.
func LoadFrom ¶
LoadFrom expects a yaml node with the sequence or mapping kind, iterates over its keys, and loads their HeadComment strings in the created Comment instance. If contained values had sequence or mapping kinds themselves, they will be loaded recursively into new Comment instances and kept in returned Comment, so they can be saved again.
func (*Comment) SaveInto ¶
SaveInto saves comments which are recorded in the `c` instance into the given `n` yaml node. The `n` argument is expected to have a sequence or mapping kind. If its contained values had sequence or mapping kinds themselves, they will be checked recursively too (if they had some corresponding comments among the `c` nested comments).
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map struct contains head-comments which are written right before each mapping key element. If those keys are mapped to some other sequence or mapping yaml nodes themselves, they may be parsed as nested Comment instances. This Map struct also contains a mapping from the key elements to their nested Comment instances (if any).
type Seq ¶
type Seq struct {
// contains filtered or unexported fields
}
Seq struct contains head-comments which are written right before each sequence element. If those elements contain some other sequence or mapping yaml nodes themselves, they may be parsed as nested Comment instances. This Seq struct also contains a slice of *Comment instances which indicates relevant nested comments. If some of the sequence members need a nested Comment instance and some of them do not need it, the slice of *Comment instances can contain nil elements jumping over the missing *Comment instances.