internal/wire: copy doc comment for generated injectors (#254)

Fixes #244
This commit is contained in:
ajjensen13
2020-06-11 10:06:02 -05:00
committed by GitHub
parent 978b7803d3
commit 4d5ab743af
7 changed files with 97 additions and 5 deletions

View File

@@ -0,0 +1,28 @@
// Copyright 2020 The Wire Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"fmt"
)
type (
Bar struct{}
Foo struct{}
)
func main() {
fmt.Println("Hello, World")
}

View File

@@ -0,0 +1,31 @@
// Copyright 2020 The Wire Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//+build wireinject
package main
import (
"github.com/google/wire"
)
/* blockComment returns Foo and has a /*- style doc comment */
func blockComment() *Foo {
panic(wire.Build(wire.Struct(new(Foo))))
}
// lineComment returns Bar and has a //- style doc comment
func lineComment() *Bar {
panic(wire.Build(wire.Struct(new(Bar))))
}

1
internal/wire/testdata/DocComment/pkg vendored Normal file
View File

@@ -0,0 +1 @@
example.com/foo

View File

@@ -0,0 +1 @@
Hello, World

View File

@@ -0,0 +1,20 @@
// Code generated by Wire. DO NOT EDIT.
//go:generate wire
//+build !wireinject
package main
// Injectors from wire.go:
/* blockComment returns Foo and has a /*- style doc comment */
func blockComment() *Foo {
foo := &Foo{}
return foo
}
// lineComment returns Bar and has a //- style doc comment
func lineComment() *Bar {
bar := &Bar{}
return bar
}

View File

@@ -7,6 +7,7 @@ package main
// Injectors from wire.go:
// initApp returns a real app.
func initApp() *app {
mainTimer := _wireRealTimeValue
mainGreeter := greeter{
@@ -22,6 +23,9 @@ var (
_wireRealTimeValue = realTime{}
)
// initMockedAppFromArgs returns an app with mocked dependencies provided via
// arguments (Approach A). Note that the argument's type is the interface
// type (timer), but the concrete mock type should be passed.
func initMockedAppFromArgs(mt timer) *app {
mainGreeter := greeter{
T: mt,
@@ -32,6 +36,8 @@ func initMockedAppFromArgs(mt timer) *app {
return mainApp
}
// initMockedApp returns an app with its mocked dependencies, created
// via providers (Approach B).
func initMockedApp() *appWithMocks {
mainMockTimer := newMockTimer()
mainGreeter := greeter{