struct
let check_and_remove_extension filename ~ext =
if Filename.check_suffix filename ext
then Some (Filename.chop_suffix filename ext)
else None
let identify_file filename =
begin match check_and_remove_extension filename ~ext:".md" with
| Some sub -> `Markdown sub
| None ->
begin match check_and_remove_extension filename ~ext:".ml" with
| Some sub -> `Ocaml_implementation sub
| None ->
begin match check_and_remove_extension filename ~ext:".mli" with
| Some sub -> `Ocaml_interface sub
| None -> `Other
end
end
end
end