4 ms·
A metaprogramming technique like source-code generation is not a serious issue in any design. It's especially helpful if the source of truth in your design is e
by whilenot-dev 3y ago
A metaprogramming technique like source-code generation is not a serious issue in any design. It's especially helpful if the source of truth in your design is external to the current code base. You can generate:
- documentation from source-code files, some CLI frameworks are offering this (eg. oclif[0])
- types from schema files, and schemas from types (eg. quicktype[1])
- API clients and servers from specifications (eg. openapi-generator[2])
...these are all repetitive tasks that can be automated.
That being said, I wouldn't personally generate it in the build step, but rather introduce an additional generate step for it and sync the generated output with the VCS of choice. I recently wrote about it a bit here[3].
[0]: https://github.com/oclif/oclif#oclif-readme https://github.com/oclif/oclif#oclif-readme
[1]: https://app.quicktype.io/ https://app.quicktype.io/
[2]: https://github.com/OpenAPITools/openapi-generator https://github.com/OpenAPITools/openapi-generator
[3]: https://blog.whilenot.dev/posts/typescript-source-code-generation/ https://blog.whilenot.dev/posts/typescript-source-code-gener...
- sureglymop 3y agoExactly. I've used something like this before when writing a lexer and a parser and it was really helpful.