Skip to content

Commit 23ecf1a

Browse files
authored
check: Accept alternate attribute section byline of No additional attributes are exported. (#48)
Reference: #43
1 parent 519f443 commit 23ecf1a

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# v0.9.1
2+
3+
BUG FIXES
4+
5+
* check: Accept alternate attribute section byline of `No additional attributes are exported.` with experimental `-enable-contents-check` flag
6+
17
# v0.9.0
28

39
BREAKING CHANGES

‎check/contents/check_attributes_section.go‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@ func (d *Document) checkAttributesSection() error {
3636
}
3737

3838
paragraphs := section.Paragraphs
39-
expectedBylineText := "In addition to all arguments above, the following attributes are exported:"
39+
expectedBylineTexts := []string{
40+
"In addition to all arguments above, the following attributes are exported:",
41+
"No additional attributes are exported.",
42+
}
4043

4144
switch len(paragraphs) {
4245
case 0:
43-
return fmt.Errorf("attributes section byline should be: %s", expectedBylineText)
46+
return fmt.Errorf("attributes section byline should be: %q or %q", expectedBylineTexts[0], expectedBylineTexts[1])
4447
case 1:
4548
paragraphText := string(paragraphs[0].Text(d.source))
4649

47-
if paragraphText != expectedBylineText {
48-
return fmt.Errorf("attributes section byline (%s) should be: %s", paragraphText, expectedBylineText)
50+
if paragraphText != expectedBylineTexts[0] && paragraphText != expectedBylineTexts[1] {
51+
return fmt.Errorf("attributes section byline (%s) should be: %q or %q", paragraphText, expectedBylineTexts[0], expectedBylineTexts[1])
4952
}
5053
}
5154

‎check/contents/check_attributes_section_test.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ func TestCheckAttributesSection(t *testing.T) {
1717
Path: "testdata/attributes/passing.md",
1818
ProviderName: "test",
1919
},
20+
{
21+
Name: "passing alternate byline",
22+
Path: "testdata/attributes/passing_alternate_byline.md",
23+
ProviderName: "test",
24+
},
2025
{
2126
Name: "missing byline",
2227
Path: "testdata/attributes/missing_byline.md",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Attributes Reference
2+
3+
No additional attributes are exported.

0 commit comments

Comments
 (0)
⌂ 换网址