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

fix(gengapic): fix service-specific constructor name in doc_file.go #1099

Merged
merged 1 commit into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions internal/gengapic/doc_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ func (g *generator) genDocFile(year int, scopes []string, serv *descriptor.Servi
p("//")
p("// To get started with this package, create a client.")
// Code block for client creation
servName := pbinfo.ReduceServName(serv.GetName(), g.opts.pkgName)
tmpClient := g.pt
g.pt = printer.P{}
g.exampleInitClient(g.opts.pkgName, pbinfo.ReduceServName(serv.GetName(), g.opts.pkgName))
g.exampleInitClient(g.opts.pkgName, servName)
snipClient := g.pt.String()
g.pt = tmpClient
g.codesnippet(snipClient)
Expand All @@ -89,15 +90,15 @@ func (g *generator) genDocFile(year int, scopes []string, serv *descriptor.Servi
// Code block for client using the first method of the service
tmpMethod := g.pt
g.pt = printer.P{}
g.exampleMethodBody(g.opts.pkgName, pbinfo.ReduceServName(serv.GetName(), g.opts.pkgName), serv.GetMethod()[0])
g.exampleMethodBody(g.opts.pkgName, servName, serv.GetMethod()[0])
snipMethod := g.pt.String()
g.pt = tmpMethod
g.codesnippet(snipMethod)
}

p("// Use of Context")
p("//")
p("// The ctx passed to NewClient is used for authentication requests and")
p("// The ctx passed to New%sClient is used for authentication requests and", servName)
p("// for creating the underlying connection, but is not used for subsequent calls.")
p("// Individual methods on the client use the ctx given to them.")
p("//")
Expand Down
4 changes: 3 additions & 1 deletion internal/gengapic/doc_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package gengapic

import (
"fmt"
"path/filepath"
"testing"

Expand Down Expand Up @@ -143,7 +144,8 @@ func TestDocFileEmptyService(t *testing.T) {
} {
g.opts.relLvl = tst.relLvl
g.genDocFile(43, []string{"https://foo.bar.com/auth", "https://zip.zap.com/auth"}, serv)
txtdiff.Diff(t, "doc_file", g.pt.String(), tst.want)
name := fmt.Sprintf("doc_file: %s", tst.want)
txtdiff.Diff(t, name, g.pt.String(), tst.want)
g.reset()
}
}
2 changes: 1 addition & 1 deletion internal/gengapic/testdata/doc_file.want
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
//
// Use of Context
//
// The ctx passed to NewClient is used for authentication requests and
// The ctx passed to NewFooClient is used for authentication requests and
// for creating the underlying connection, but is not used for subsequent calls.
// Individual methods on the client use the ctx given to them.
//
Expand Down
2 changes: 1 addition & 1 deletion internal/gengapic/testdata/doc_file_alpha.want
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
//
// Use of Context
//
// The ctx passed to NewClient is used for authentication requests and
// The ctx passed to NewFooClient is used for authentication requests and
// for creating the underlying connection, but is not used for subsequent calls.
// Individual methods on the client use the ctx given to them.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
//
// Use of Context
//
// The ctx passed to NewClient is used for authentication requests and
// The ctx passed to NewFooClient is used for authentication requests and
// for creating the underlying connection, but is not used for subsequent calls.
// Individual methods on the client use the ctx given to them.
//
Expand Down
2 changes: 1 addition & 1 deletion internal/gengapic/testdata/doc_file_beta.want
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
//
// Use of Context
//
// The ctx passed to NewClient is used for authentication requests and
// The ctx passed to NewFooClient is used for authentication requests and
// for creating the underlying connection, but is not used for subsequent calls.
// Individual methods on the client use the ctx given to them.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
//
// Use of Context
//
// The ctx passed to NewClient is used for authentication requests and
// The ctx passed to NewFooClient is used for authentication requests and
// for creating the underlying connection, but is not used for subsequent calls.
// Individual methods on the client use the ctx given to them.
//
Expand Down
2 changes: 1 addition & 1 deletion internal/gengapic/testdata/doc_file_emptyservice.want
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
//
// Use of Context
//
// The ctx passed to NewClient is used for authentication requests and
// The ctx passed to NewFooClient is used for authentication requests and
// for creating the underlying connection, but is not used for subsequent calls.
// Individual methods on the client use the ctx given to them.
//
Expand Down