jennifer icon indicating copy to clipboard operation
jennifer copied to clipboard

Feature proposal: Generate jennifer code from existing go code

Open aloder opened this issue 5 years ago • 9 comments

I wanted to take an existing file like the one in #50 and convert it so that jennifer generates it. Right now I am doing this by hand. I would like a function that takes in a go file and outputs the code that generates that go file using jennifer.

This would discourage workarounds like Op and allow quick generation of static files.

Similar to #44 Solves #50

aloder avatar Jan 27 '19 08:01 aloder

This would be great, but more appropriate as a standalone utility - e.g. not integrated into the jennifer codebase. Similar to my html2vecty utility for doing the same thing with vecty syntax. I definitely won't have time to do this in the next 6 months so feel free to have a go. I'll happily include a link in the readme when it's finished.

dave avatar Jan 27 '19 08:01 dave

I agree, I'll look into making it but I have little experience with ASTs.

The more I think about it the more appealing a tool like this becomes. You can use this tool as a starting point for generating code, filling in the logic and the variables after. Eliminating most of the monotony of writing generated code.

aloder avatar Jan 27 '19 08:01 aloder

Yes it would be useful. Feel free to fork html2vecty and use that as a base...

dave avatar Jan 27 '19 08:01 dave

Alright just got the project up to a usable standard: https://github.com/aloder/jenjen

Let me know what you think.

aloder avatar Feb 13 '19 03:02 aloder

Wow this looks great! Won't have time to look at it today or tomorrow but Friday I can have a good play.

dave avatar Feb 13 '19 07:02 dave

p.s. Are you set on the jenjen name? The jennifer project has a genjen package that generates the API... might be rather confusing...

dave avatar Feb 13 '19 07:02 dave

Yea, I noticed that right after I pushed the name. I can change it. I'll start thinking of others.

aloder avatar Feb 13 '19 07:02 aloder

Awesome. I took a very quick look at the code and it looks great!

dave avatar Feb 13 '19 07:02 dave

Thank you, I will be improving the code and features as I use it in my own products.

Let me know if you have any suggestions.

aloder avatar Feb 13 '19 17:02 aloder