ponzu-cms / ponzu

Headless CMS with automatic JSON API. Featuring auto-HTTPS from Let's Encrypt, HTTP/2 Server Push, and flexible server framework written in Go.
https://docs.ponzu-cms.org
BSD 3-Clause "New" or "Revised" License
5.68k stars 386 forks source link

"ponzu generate" with commented out interface implementations? #241

Closed olliephillips closed 5 years ago

olliephillips commented 6 years ago

It would be a time saver to uncomment interface method implementations in generated code rather than have to find the code snippet and copy paste it? Though I'm sure some users can key it from memory, that's not me :)

Maybe ponzu generate could also add these methods but wrap them in comments? To use, just uncomment and extend a method if required.

A flag to populate or not on ponzu generate would also provide the user with a choice?

nilslice commented 6 years ago

@olliephillips - interesting.. are you suggesting that we generate a commented out stub for interface APIs like Pushable on all generated types?

I had a thought a while back that we could decorate the ponzu gen c call with options like +push +hide etc to add this stub... but decided it was really not much work to just write that code. But I'll leave this open to get feedback from others..

cc/ @ponzu-cms/team - any thoughts?

olliephillips commented 6 years ago

@nilslice Yes, the function signatures are fairly simple but there are a quite a few interfaces that one might want to use. My thought was a single flag that would scaffold all of them. There's no bloat, since as commented, they're stripped at build. Just my thoughts. Hope others can jump in with their opinion.

nilslice commented 6 years ago

Adding a single flag to generate the commented out implementation stubs is something I feel much more comfortable with.. let's see what others think, but since it would be entirely opt-in, I don't have any problem with this at first thought. As for implementation, we'd just need to have some way to keep track of all the implementations, and/or use some tooling i.e https://github.com/josharian/impl

olliephillips commented 5 years ago

Closing this issue. No activity. Please reopen if need to.