Signed Files
Generated files are signed to prevent or detect manual modifications of generated code; these files can then be regenerated with new content in the future, or signatures can be disabled to generate ‘skeleton’ code, if any future changes will be manual.
Partially Generated Files
Generated code can be marked as containing manually-modifiable sections; you can use hack-codegen to rewrite the rest of the file in the future, and all manual sections will be left unmodified.
Readable Output
All built-in features handle whitespace correctly, and it’s easy to integrate this into custom code.
Extensible and Type-Safe Value Rendering
Hack Codegen can render any value as raw literal code or using
var_export()
; additionally, there’s built-in support for
pretty-printed collections, shapes, and classname<T>
.
These can be nested arbitrarily for shapes and collections, and can be extended by providing a lambda, or creating a class implementing the key or value renderer interfaces.