module OASISFileTemplate:sig..end
This module allow to generate files using template. Each template files is split into three parts: an header, a body and a footer. We target at changing the body part. If target file already exists, we load the header and the footer from it. We merge the three parts and repalce the target files.
There are some safety limits:
type comment
val comment_ml : commentval comment_sh : commentval comment_makefile : commentval comment_ocamlbuild : commentval comment_bat : commentval comment_meta : commentval comment_markdown : commenttypeline =string
type body =
| |
NoBody |
| |
Body of |
| |
BodyWithDigest of |
type template = {
|
fn : |
|||
|
comment : |
|||
|
header : |
|||
|
body : |
|||
|
: |
|||
|
perm : |
|||
|
important : |
(* |
Determine if should be kept in dynamic mode.
| *) |
|
disable_oasis_section : |
(* |
Determine if OASIS section comments and digest should be omitted.
| *) |
val template_make : OASISUnixPath.host_filename ->
comment ->
line list ->
line list ->
line list -> templatetemplate_make fn cmt header body footer Create a template for which
target file is fn.val template_of_string_list : ctxt:OASISContext.t ->
template:bool ->
?disable_oasis_section:bool ->
OASISUnixPath.host_filename ->
comment ->
line list -> templatetemplate_of_string_list ~ctxt ~template ~pure fn cmt lst Split the list
lst into a header, body and footer, using comment cmt to determine each
part. Set ~template if this is an embedded template (i.e. not a file
loaded from disk). If ~disable_oasis_section is set, then the list is
processed on the assumption that there is no header and footer. See
OASISFileTemplate.template_make for other options.val template_of_mlfile : OASISUnixPath.host_filename ->
line list ->
line list ->
line list -> templatetemplate_of_ml_file fn Create an OCaml file template taking into account
subtleties, like line modifier. See OASISFileTemplate.template_make for other options.val to_string_list : template -> line listtype file_generate_change =
| |
Create of |
(* | Create fn, fn is the target file, nothing exists before | *) |
| |
Change of |
(* | Change (fn, bak), bak is the backup file, an existing file
has been changed. | *) |
| |
NoChange |
(* |
Nothing done, the file doesn't need to be updated
| *) |
val file_rollback : ctxt:OASISContext.t -> file_generate_change -> unitval file_generate : ctxt:OASISContext.t ->
?remove:bool ->
backup:bool ->
template -> file_generate_change~remove is true, then an existing file
will be deleted iff the template body is [] and the header and footer of
the file match the template's (used by the -remove option for setup-clean).exception AlreadyExists of OASISUnixPath.host_filename
type templates
val create : disable_oasis_section:OASISUnixPath.unix_filename list ->
unit -> templatesval find : OASISUnixPath.host_filename ->
templates -> templateval add : template ->
templates -> templatesval remove : OASISUnixPath.host_filename ->
templates -> templatesval replace : template ->
templates -> templatesval fold : (template -> 'b -> 'b) ->
templates -> 'b -> 'b