func SampleYAML(w io.Writer, indent int, attrs map[string]interface{}, fields Fields) error {
	indentStr := strings.Repeat(" ", indent)
	orderedFields := make(fieldsByGroup, 0, len(fields))
	for name, f := range fields {
		orderedFields = append(orderedFields, attrWithName{
			name: name,
			Attr: f,
		})
	}
	sort.Sort(orderedFields)
	for i, f := range orderedFields {
		if i > 0 {
			w.Write(nl)
		}
		writeSampleDescription(w, f.Attr, indentStr+"# ")
		val, ok := attrs[f.name]
		if ok {
			fmt.Fprintf(w, "%s:", f.name)
			indentVal(w, val, indentStr)
		} else {
			if f.Example != nil {
				val = f.Example
			} else {
				val = sampleValue(f.Type)
			}
			fmt.Fprintf(w, "# %s:", f.name)
			indentVal(w, val, indentStr+"# ")
		}
	}
	return nil
}
// SampleYAML writes YAML output to w, indented by indent spaces
// that holds the attributes in attrs with descriptions found
// in the given fields. An entry for any attribute in fields not
// in attrs will be generated but commented out.
SampleYAML writes YAML output to w, indented by indent spaces
that holds the attributes in attrs with descriptions found
in the given fields. An entry for any attribute in fields not
in attrs will be generated but commented out.
// SampleYAML writes YAML output to w indented by indent spaces // that holds the attributes in attrs with descriptions found // in the given fields . An entry for any attribute in fields not // in attrs will be generated but commented out .
func SampleYAML(w io.Writer, indent int, attrs map[string]interface{}, fields Fields) error {
	indentStr := strings.Repeat(" ", indent)
	orderedFields := make(fieldsByGroup, 0, len(fields))
	for name, f := range fields {
		orderedFields = append(orderedFields, attrWithName{
			name: name,
			Attr: f,
		})
	}
	sort.Sort(orderedFields)
	for i, f := range orderedFields {
		if i > 0 {
			w.Write(nl)
		}
		writeSampleDescription(w, f.Attr, indentStr+"# ")
		val, ok := attrs[f.name]
		if ok {
			fmt.Fprintf(w, "%s:", f.name)
			indentVal(w, val, indentStr)
		} else {
			if f.Example != nil {
				val = f.Example
			} else {
				val = sampleValue(f.Type)
			}
			fmt.Fprintf(w, "# %s:", f.name)
			indentVal(w, val, indentStr+"# ")
		}
	}
	return nil
}
func SampleYAML ( w io . Writer , indent int , attrs map [ string ] interface { } , fields Fields ) error { indentStr := strings . Repeat ( " " , indent ) orderedFields := make ( fieldsByGroup , 0 , len ( fields ) ) for name , f := range fields { orderedFields = append ( orderedFields , attrWithName { name : name , Attr : f , } ) } sort . Sort ( orderedFields ) for i , f := range orderedFields { if i > 0 { w . Write ( nl ) } writeSampleDescription ( w , f . Attr , indentStr + " " ) val , ok := attrs [ f . name ] if ok { fmt . Fprintf ( w , " " , f . name ) indentVal ( w , val , indentStr ) } else { if f . Example != nil { val = f . Example } else { val = sampleValue ( f . Type ) } fmt . Fprintf ( w , " " , f . name ) indentVal ( w , val , indentStr + " " ) } } return nil }
SampleYAML writes YAML output to w, indented by indent spaces
that holds the attributes in attrs with descriptions found
in the given fields.
SampleYAML writes YAML output to w indented by indent spaces that holds the attributes in attrs with descriptions found in the given fields .