Skip to content

Commit

Permalink
Respect newlines in package comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pablojimpas committed May 1, 2023
1 parent 9199872 commit 84f6c16
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions mage/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,9 @@ func TestList(t *testing.T) {
}
actual := stdout.String()
expected := `
This is a comment on the package which should get turned into output with the list of targets.
This is a comment on the package which should get turned into output with the
list of targets.
Targets:
somePig* This is the synopsis for SomePig.
Expand Down Expand Up @@ -629,7 +631,9 @@ func TestListWithColor(t *testing.T) {
os.Setenv(mg.TargetColorEnv, mg.Cyan.String())

expectedPlainText := `
This is a comment on the package which should get turned into output with the list of targets.
This is a comment on the package which should get turned into output with the
list of targets.
Targets:
somePig* This is the synopsis for SomePig.
Expand All @@ -642,8 +646,8 @@ Targets:
// in the middle and join with a normal string for the target names,
// otherwise the single backslash would be taken literally and encoded as \\
expectedColorizedText := "" +
"This is a comment on the package which should get turned into output with the list of targets.\n" +
"\n" +
"This is a comment on the package which should get turned into output with the\nlist of targets.\n" +
"\n\n" +
"Targets:\n" +
" \x1b[36msomePig*\x1b[0m This is the synopsis for SomePig.\n" +
" \x1b[36mtestVerbose\x1b[0m \n" +
Expand Down Expand Up @@ -730,7 +734,9 @@ func TestIgnoreDefault(t *testing.T) {
}
actual := stdout.String()
expected := `
This is a comment on the package which should get turned into output with the list of targets.
This is a comment on the package which should get turned into output with the
list of targets.
Targets:
somePig* This is the synopsis for SomePig.
Expand Down
2 changes: 1 addition & 1 deletion parse/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func Package(path string, files []string) (*PkgInfo, error) {
pi := &PkgInfo{
AstPkg: pkg,
DocPkg: p,
Description: toOneLine(p.Doc),
Description: p.Doc,
}

setNamespaces(pi)
Expand Down

0 comments on commit 84f6c16

Please sign in to comment.