How do I create a custom generator?

I’d like to run expectations against avro or even ndjson files. Sounds like the best way to do this is through a custom generator.

How do I write one?