Skip to content

Commit 24aef36

Browse files
committed
Respect newlines in package comments
Closes magefile#358
1 parent c97c205 commit 24aef36

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

mage/main_test.go

+11-5
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,9 @@ func TestList(t *testing.T) {
593593
}
594594
actual := stdout.String()
595595
expected := `
596-
This is a comment on the package which should get turned into output with the list of targets.
596+
This is a comment on the package which should get turned into output with the
597+
list of targets.
598+
597599
598600
Targets:
599601
somePig* This is the synopsis for SomePig.
@@ -629,7 +631,9 @@ func TestListWithColor(t *testing.T) {
629631
os.Setenv(mg.TargetColorEnv, mg.Cyan.String())
630632

631633
expectedPlainText := `
632-
This is a comment on the package which should get turned into output with the list of targets.
634+
This is a comment on the package which should get turned into output with the
635+
list of targets.
636+
633637
634638
Targets:
635639
somePig* This is the synopsis for SomePig.
@@ -642,8 +646,8 @@ Targets:
642646
// in the middle and join with a normal string for the target names,
643647
// otherwise the single backslash would be taken literally and encoded as \\
644648
expectedColorizedText := "" +
645-
"This is a comment on the package which should get turned into output with the list of targets.\n" +
646-
"\n" +
649+
"This is a comment on the package which should get turned into output with the\nlist of targets.\n" +
650+
"\n\n" +
647651
"Targets:\n" +
648652
" \x1b[36msomePig*\x1b[0m This is the synopsis for SomePig.\n" +
649653
" \x1b[36mtestVerbose\x1b[0m \n" +
@@ -730,7 +734,9 @@ func TestIgnoreDefault(t *testing.T) {
730734
}
731735
actual := stdout.String()
732736
expected := `
733-
This is a comment on the package which should get turned into output with the list of targets.
737+
This is a comment on the package which should get turned into output with the
738+
list of targets.
739+
734740
735741
Targets:
736742
somePig* This is the synopsis for SomePig.

parse/parse.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ func Package(path string, files []string) (*PkgInfo, error) {
247247
pi := &PkgInfo{
248248
AstPkg: pkg,
249249
DocPkg: p,
250-
Description: toOneLine(p.Doc),
250+
Description: p.Doc,
251251
}
252252

253253
setNamespaces(pi)

0 commit comments

Comments
 (0)