doc: Allow top-level comments for variables when description missing

Documenting variables with description and outputs with top-level
comments breaks workflow, depending on what one is used to.

This update allows variables to be documented with top-level comments
in the same way that outputs are, if no description is present.
This commit is contained in:
Chris Marchesi
2016-11-20 12:03:03 -08:00
parent 1089829ed8
commit 8632ee6d21

View File

@@ -77,7 +77,13 @@ func inputs(list *ast.ObjectList) []Input {
if is(item, "variable") {
name, _ := strconv.Unquote(item.Keys[1].Token.Text)
items := item.Val.(*ast.ObjectType).List.Items
desc := description(items)
var desc string
switch {
case description(items) != "":
desc = description(items)
case item.LeadComment != nil:
desc = comment(item.LeadComment.List)
}
def := get(items, "default")
ret = append(ret, Input{
Name: name,