Caravela.Gen.Custom (Caravela v0.6.0)

Copy Markdown View Source

Preserves user-authored code across regenerations.

Generators emit a # --- CUSTOM --- marker before the closing end of every regenerable module. Anything the developer writes below that marker in the generated file is preserved verbatim when the generator runs again.

Summary

Functions

The marker string.

Reusable marker block appended by generators. Terminates the module with end once custom content is merged in.

Merge custom content from an existing file into a newly-generated source. If the existing file does not contain the marker, the new source is returned unchanged.

Merge custom content from disk. Reads path if it exists; otherwise returns the generated source unchanged.

Functions

marker()

The marker string.

marker_block()

Reusable marker block appended by generators. Terminates the module with end once custom content is merged in.

merge(new_source, existing_source)

Merge custom content from an existing file into a newly-generated source. If the existing file does not contain the marker, the new source is returned unchanged.

merge_with_file(new_source, path)

Merge custom content from disk. Reads path if it exists; otherwise returns the generated source unchanged.