vburenin / ifacemaker

Generate interfaces from structure methods.
Apache License 2.0
320 stars 43 forks source link

Add option to copy struct documentation to interface #25

Closed markus-wa closed 5 years ago

markus-wa commented 5 years ago

Currently only method docs are copied to the interface.

I think it would be beneficial in some cases to have the same doc on the interface type as on the struct.

Specifically I would like that the consumers of my library have the same IDE experience (type docs) when they are working with the interface as they have with the original struct.

example:

// MyType can do some interesting stuff.
type MyType struct {
}

ifacemaker -f mytype.go -s MyType --copy-typedoc -i MyInterface

// MyInterface can do some interesting stuff.
type MyInterface struct {
}
vburenin commented 5 years ago

It definitely might be helpful if the struct doc is generic enough. In my particular case it was not the case. Usually structure description describes the implementation details, requirements, limitations, etc which is not applicable for the interface type. thus there is an option "-y" to provide a custom interface doc. However, if you think it is needed, you are more than welcome to contribute this change.