Skip to content

Commit

Permalink
check: Accept alternate attribute section byline of `No additional at…
Browse files Browse the repository at this point in the history
…tributes are exported.` (#48)

Reference: #43
  • Loading branch information
bflad authored Feb 25, 2021
1 parent 519f443 commit 23ecf1a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v0.9.1

BUG FIXES

* check: Accept alternate attribute section byline of `No additional attributes are exported.` with experimental `-enable-contents-check` flag

# v0.9.0

BREAKING CHANGES
Expand Down
11 changes: 7 additions & 4 deletions check/contents/check_attributes_section.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,19 @@ func (d *Document) checkAttributesSection() error {
}

paragraphs := section.Paragraphs
expectedBylineText := "In addition to all arguments above, the following attributes are exported:"
expectedBylineTexts := []string{
"In addition to all arguments above, the following attributes are exported:",
"No additional attributes are exported.",
}

switch len(paragraphs) {
case 0:
return fmt.Errorf("attributes section byline should be: %s", expectedBylineText)
return fmt.Errorf("attributes section byline should be: %q or %q", expectedBylineTexts[0], expectedBylineTexts[1])
case 1:
paragraphText := string(paragraphs[0].Text(d.source))

if paragraphText != expectedBylineText {
return fmt.Errorf("attributes section byline (%s) should be: %s", paragraphText, expectedBylineText)
if paragraphText != expectedBylineTexts[0] && paragraphText != expectedBylineTexts[1] {
return fmt.Errorf("attributes section byline (%s) should be: %q or %q", paragraphText, expectedBylineTexts[0], expectedBylineTexts[1])
}
}

Expand Down
5 changes: 5 additions & 0 deletions check/contents/check_attributes_section_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ func TestCheckAttributesSection(t *testing.T) {
Path: "testdata/attributes/passing.md",
ProviderName: "test",
},
{
Name: "passing alternate byline",
Path: "testdata/attributes/passing_alternate_byline.md",
ProviderName: "test",
},
{
Name: "missing byline",
Path: "testdata/attributes/missing_byline.md",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Attributes Reference

No additional attributes are exported.

0 comments on commit 23ecf1a

Please sign in to comment.