Skip to content

Commit

Permalink
gir/girgen/cmt: Don't print param/ret labels if we don't print the list
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeShu committed May 2, 2024
1 parent a26850e commit 2d1f99a
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 1,589 deletions.
18 changes: 13 additions & 5 deletions gir/girgen/cmt/cmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,14 @@ func goDoc(v interface{}, indentLvl int, opts []Option) string {
tail.Grow(256)

if len(inf.ParamDocs) > 0 {
tail.WriteString("\n\nThe function takes the following parameters:\n")
writeParamDocs(&tail, indentLvl+1, inf.ParamDocs)
writeParamDocs(&tail, indentLvl+1,
"\n\nThe function takes the following parameters:\n",
inf.ParamDocs)
}
if len(inf.ReturnDocs) > 0 {
tail.WriteString("\n\nThe function returns the following values:\n")
writeParamDocs(&tail, indentLvl+1, inf.ReturnDocs)
writeParamDocs(&tail, indentLvl+1,
"\n\nThe function returns the following values:\n",
inf.ReturnDocs)
}

if tail.Len() > 0 {
Expand All @@ -293,12 +295,14 @@ func addPeriod(cmt string) string {
return cmt
}

func writeParamDocs(tail *strings.Builder, indent int, params []ParamDoc) {
func writeParamDocs(tail *strings.Builder, indent int, label string, params []ParamDoc) {
col := calculateCol(indent)

line1Indent := strings.Repeat(" ", CommentsTabWidth) + "- "
lineNIndent := strings.Repeat(" ", CommentsTabWidth+2)

written := false

for _, param := range params {
name := param.Name
if param.Optional {
Expand Down Expand Up @@ -329,6 +333,10 @@ func writeParamDocs(tail *strings.Builder, indent int, params []ParamDoc) {
doc = line1Indent + name
}

if !written {
tail.WriteString(label)
written = true
}
tail.WriteString("\n")
tail.WriteString(doc)
}
Expand Down
36 changes: 3 additions & 33 deletions pkg/atk/atk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions pkg/gdk/v3/gdk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 1 addition & 15 deletions pkg/gdk/v4/gdk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pkg/gdkpixbuf/v2/gdkpixbuf.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions pkg/gdkx11/v3/gdkx11.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2d1f99a

Please sign in to comment.