golang / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
9.3k stars 611 forks source link

Generate (some) documentation for generated interface methods #650

Open jamietanna opened 2 years ago

jamietanna commented 2 years ago

Requested feature

Generate more appropriate GoDoc for generated interface methods, taking into account the existing docs, if any, and describe the method parameter names.

Why the feature is needed

When generating mocks for a method, for instance database/sql/driver's Conn.Prepare, we get the following GoDoc generated:

// Prepare mocks base method.
func (m *MockConn) Prepare(arg0 string) (driver.Stmt, error) {

This does not make it as easy to understand what arg0, or any other information from the method we're calling, so IDEs can't easily provide hints to the caller what the parameters are/were called.

(Optional) Proposed solution

This would instead generate the following format, or similar:

// Prepare mocks base method.
// Prepare returns a prepared statement, bound to this connection.
// Method signature:
//   (query string) (Stmt, error)
func (m *MockConn) Prepare(arg0 string) (driver.Stmt, error) {

Not sure if the use of the signature there will make sense, so happy to hear suggestions.