Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect newlines in package comments #459

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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: string(p.Text(p.Doc)),
}

setNamespaces(pi)
Expand Down