by lifeisstillgood · 2y ago · 0 comments
My thoughts are the python code will be most effective if it can read config or access chunks of data outside the source (ie auto-generating fetter setter style stuff). I am trying to see how much is dangerous and how much is trivial or better handled pre-commit
However, some "meta" examples: * If you have an authoritative source - a protobuf/openai/some other structured specification, then this is helpful (if there isn't a specific generator already).
* Whenever you're knee-deep in meta-classes in Python, generating code from annotations in Java or similar - then this might actually be better - the code will likely be simpler and therefore easier for teammates to maintain as well.
Note that the current source code already contains a Python code used to generate them. The code is there for future uses, but it would be too much to have an additional build step and Python dependency just for that particular file, considering that this file will rarely change. Cog would be very useful in such situations.
Agreed. I've used jinja2 quite a bit for templating C with structured data. It is very effective. Ned writes that he also considered templating engines but was not satisfied when trying to implement more complex code generation inline. I feel like I understand Ned's thought process here but I strongly disagree with his conclusion unless it's for personal use only. Cog is subject to the lisp curse.
target docs:
${VENV_PYTHON} -m cog -r ./README.md
and readme.md has cog statements in it which fully exercise my CLI’s help documentation, and every subcommand’s help, and prints them out as source blocks.