Skip to content

Commit

Permalink
Fix description (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
blmhemu authored Jan 8, 2024
1 parent bf1736a commit a942954
Show file tree
Hide file tree
Showing 20 changed files with 210 additions and 70 deletions.
11 changes: 4 additions & 7 deletions formatter/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,10 @@ func (f *formatter) WriteDescription(s string) *formatter {
}

f.WriteString(`"""`)
if ss := strings.Split(s, "\n"); len(ss) > 1 {
f.WriteNewline()
for _, s := range ss {
f.WriteString(s).WriteNewline()
}
} else {
f.WriteString(s)
ss := strings.Split(s, "\n")
f.WriteNewline()
for _, s := range ss {
f.WriteString(s).WriteNewline()
}

f.WriteString(`"""`).WriteNewline()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Cat0 comment
# Cat0 comment 2
"""Cat0 description"""
"""
Cat0 description
"""
scalar Cat0
# Cat1 comment
type Cat1 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ meow!
# type comment
type Cat {
# field description comment
"""Shiny brillian name."""
"""
Shiny brillian name.
"""
# field comment
name: String
"""
Only "meow" is allowed.
"""
speaks: String
}
28 changes: 21 additions & 7 deletions formatter/testdata/baseline/FormatSchema/comments/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,50 @@ schema {
type TopMutation {
noop: Boolean
noop2(
"""noop2 foo bar"""
"""
noop2 foo bar
"""
arg: String
): Boolean
noop3(
"""noop3 foo bar"""
"""
noop3 foo bar
"""
arg: String
): Boolean
}
type TopQuery {
noop: Boolean
noop2(
"""noop2 foo bar"""
"""
noop2 foo bar
"""
arg: String
): Boolean
noop3(
"""noop3 foo bar"""
"""
noop3 foo bar
"""
arg: String
): Boolean
}
type TopSubscription {
noop: Boolean
noop2(
"""noop2 foo bar"""
"""
noop2 foo bar
"""
arg: String
): Boolean
noop3(
"""noop3 foo bar"""
"""
noop3 foo bar
"""
arg1: String

"""noop3 foo bar"""
"""
noop3 foo bar
"""
arg2: String
): Boolean
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Cat0 description"""
"""
Cat0 description
"""
scalar Cat0
type Cat1 {
name: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Cat is best kawaii animal in the world.
meow!
"""
type Cat {
"""Shiny brillian name."""
"""
Shiny brillian name.
"""
name: String
"""
Only "meow" is allowed.
"""
speaks: String
}
28 changes: 21 additions & 7 deletions formatter/testdata/baseline/FormatSchema/default/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,50 @@ schema {
type TopMutation {
noop: Boolean
noop2(
"""noop2 foo bar"""
"""
noop2 foo bar
"""
arg: String
): Boolean
noop3(
"""noop3 foo bar"""
"""
noop3 foo bar
"""
arg: String
): Boolean
}
type TopQuery {
noop: Boolean
noop2(
"""noop2 foo bar"""
"""
noop2 foo bar
"""
arg: String
): Boolean
noop3(
"""noop3 foo bar"""
"""
noop3 foo bar
"""
arg: String
): Boolean
}
type TopSubscription {
noop: Boolean
noop2(
"""noop2 foo bar"""
"""
noop2 foo bar
"""
arg: String
): Boolean
noop3(
"""noop3 foo bar"""
"""
noop3 foo bar
"""
arg1: String

"""noop3 foo bar"""
"""
noop3 foo bar
"""
arg2: String
): Boolean
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Cat0 description"""
"""
Cat0 description
"""
scalar Cat0
type Cat1 {
name: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Cat is best kawaii animal in the world.
meow!
"""
type Cat {
"""Shiny brillian name."""
"""
Shiny brillian name.
"""
name: String
"""
Only "meow" is allowed.
"""
speaks: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,50 @@ schema {
type TopMutation {
noop: Boolean
noop2(
"""noop2 foo bar"""
"""
noop2 foo bar
"""
arg: String
): Boolean
noop3(
"""noop3 foo bar"""
"""
noop3 foo bar
"""
arg: String
): Boolean
}
type TopQuery {
noop: Boolean
noop2(
"""noop2 foo bar"""
"""
noop2 foo bar
"""
arg: String
): Boolean
noop3(
"""noop3 foo bar"""
"""
noop3 foo bar
"""
arg: String
): Boolean
}
type TopSubscription {
noop: Boolean
noop2(
"""noop2 foo bar"""
"""
noop2 foo bar
"""
arg: String
): Boolean
noop3(
"""noop3 foo bar"""
"""
noop3 foo bar
"""
arg1: String

"""noop3 foo bar"""
"""
noop3 foo bar
"""
arg2: String
): Boolean
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Cat0 comment
# Cat0 comment 2
"""Cat0 description"""
"""
Cat0 description
"""
scalar Cat0
# Cat1 comment
type Cat1 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ meow!
# type comment
type Cat {
# field description comment
"""Shiny brillian name."""
"""
Shiny brillian name.
"""
# field comment
name: String
"""
Only "meow" is allowed.
"""
speaks: String
}
# end of file comment
# end of file comment 2
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# before schema description comment
"""schema description"""
"""
schema description
"""
# after schema description comment
schema {
# before query comment
Expand All @@ -13,36 +15,50 @@ schema {
type TopMutation {
noop: Boolean
noop2(
"""noop2 foo bar"""
"""
noop2 foo bar
"""
arg: String
): Boolean
noop3(
"""noop3 foo bar"""
"""
noop3 foo bar
"""
arg: String
): Boolean
}
type TopQuery {
noop: Boolean
noop2(
"""noop2 foo bar"""
"""
noop2 foo bar
"""
arg: String
): Boolean
noop3(
"""noop3 foo bar"""
"""
noop3 foo bar
"""
arg: String
): Boolean
}
type TopSubscription {
noop: Boolean
noop2(
"""noop2 foo bar"""
"""
noop2 foo bar
"""
arg: String
): Boolean
noop3(
"""noop3 foo bar"""
"""
noop3 foo bar
"""
arg1: String

"""noop3 foo bar"""
"""
noop3 foo bar
"""
arg2: String
): Boolean
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Cat0 description"""
"""
Cat0 description
"""
scalar Cat0
type Cat1 {
name: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Cat is best kawaii animal in the world.
meow!
"""
type Cat {
"""Shiny brillian name."""
"""
Shiny brillian name.
"""
name: String
"""
Only "meow" is allowed.
"""
speaks: String
}
Loading

0 comments on commit a942954

Please sign in to comment.