From 8632ee6d2146d66d720424fdc1ad2835f5858851 Mon Sep 17 00:00:00 2001 From: Chris Marchesi Date: Sun, 20 Nov 2016 12:03:03 -0800 Subject: [PATCH] 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. --- doc/doc.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/doc.go b/doc/doc.go index a246fed..ddb447f 100644 --- a/doc/doc.go +++ b/doc/doc.go @@ -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,