Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
add SampleYAML function #6
Conversation
mhilton
reviewed
Aug 28, 2015
| + descr := strings.TrimSpace(f.Description) | ||
| + if descr != "" { | ||
| + section() | ||
| + if !strings.HasSuffix(descr, ".") { |
mhilton
Aug 28, 2015
Member
Are you sure you want to do this? Sentences might end with a ! or a ? (although that might be unusual for a description)
rogpeppe
Aug 28, 2015
Owner
Yeah, I agree (particularly since something might easily end up with an exclamation mark). Done.
mhilton
reviewed
Aug 28, 2015
| + | ||
| +const textWidth = 80 | ||
| + | ||
| +func writeSampleDescription(w io.Writer, f Attr, indent string) { |
mhilton
reviewed
Aug 28, 2015
| + section() | ||
| +} | ||
| + | ||
| +func emptyLine(w io.Writer, indent string) { |
urosj
reviewed
Aug 28, 2015
| + return nil | ||
| +} | ||
| + | ||
| +const textWidth = 80 |
urosj
Aug 28, 2015
Owner
I know it's just a bit of paperwork to deal with indenting, however, i wonder if this is really required? What if we rather leave this to a user?
rogpeppe
Aug 28, 2015
Owner
I think it's worth doing, as it means we don't need to bother too much
about formatting and line lengths in the descriptions - they'll all be
formatted consistently (like Go doc comments)
mhilton
reviewed
Aug 28, 2015
| + f[i], f[j] = f[j], f[i] | ||
| +} | ||
| + | ||
| +func (f fieldsByGroup) Less(i0, i1 int) bool { |
mhilton
Aug 28, 2015
Member
I think I'd like to see the same parameters for Less as Swap. I don't mind which ones you choose.
mhilton
reviewed
Aug 28, 2015
| + if canUseSameLine(x) { | ||
| + w.Write(space) | ||
| + } else { | ||
| + w.Write(nl) |
mhilton
Aug 28, 2015
Member
previously you've used fmt.Fprintf(w, "\n") to do the same thing. I'm not following why this one should be different.
urosj
reviewed
Aug 28, 2015
| + fields: environschema.Fields{ | ||
| + "foo": { | ||
| + Type: environschema.Tstring, | ||
| + Description: "foo is a string.", |
mhilton
reviewed
Aug 28, 2015
| + } | ||
| + data = bytes.TrimSuffix(data, nl) | ||
| + lines := bytes.Split(data, nl) | ||
| + for i, line := range lines { |
mhilton
Aug 28, 2015
Member
any particular reason not to merge this and the above line together?
for i, line := bytes.Split(data, nl) No particular reason to do so either.
urosj
reviewed
Aug 28, 2015
| + |# This attribute is immutable and considered secret. | ||
| + |# | ||
| + |# e: "" | ||
| + `, |
|
Looks ok. I have some reservations about how output is generated (vs if user defines it), but as it is under our control, it shouldn't be a problem. |
|
|
|
|
rogpeppe commentedAug 28, 2015
This will enable us to generate environment provider boilerplate
YAML files.