@@ -28,8 +28,8 @@ let load_template template_filename =
2828 lexbuf.lex_curr_p < - { lexbuf.lex_curr_p with pos_fname = template_filename };
2929 in
3030 try Mustache. parse_lx lexbuf
31- with Mustache. Template_parse_error err ->
32- Format. eprintf " Template parse error:@ \n %a@."
31+ with Mustache. Parse_error err ->
32+ Format. eprintf " %a@."
3333 Mustache. pp_template_parse_error err;
3434 exit 3
3535
@@ -49,48 +49,47 @@ let run search_path json_filename template_filename =
4949 print_string output;
5050 flush stdout
5151 with Mustache. Render_error err ->
52- Format. eprintf " Template render error:@ \n %a@."
52+ Format. eprintf " %a@."
5353 Mustache. pp_render_error err;
5454 exit 2
5555
56- let run_command =
57- let open Cmdliner in
58- let doc = " renders Mustache template from JSON data files" in
59- let man = [
60- `S Manpage. s_description;
61- `P " $(tname) is a command-line tool coming with the $(i,ocaml-mustache) library,
62- an OCaml implementation of the Mustache template format.
63- $(tname) takes a data file and a template file as command-line parameters;
64- it renders the populated template on standard output." ;
65-
66- `P " Mustache is a simple and popular template format,
67- with library implementations in many programming languages.
68- It is named from its {{..}} delimiters." ;
69-
70- `I (" Mustache website" ,
71- " https://mustache.github.io/" );
72- `I (" Mustache templates documentation" ,
73- " https://mustache.github.io/mustache.5.html" );
74- `I (" ocaml-mustache website:" ,
75- " https://github.com/rgrinberg/ocaml-mustache" );
76-
77- `P " The $(i,ocaml-mustache) implementation is tested against
78- the Mustache specification testsuite.
79- All features are supported, except for lambdas and setting delimiter tags." ;
80- `S Manpage. s_options;
81- `S " PARTIALS" ;
82- `P " The $(i,ocaml-mustache) library gives programmatic control over the meaning of partials {{>foo}}.
83- For the $(tname) tool, partials are interpreted as template file inclusion: '{{>foo}}' includes
84- the template file 'foo.mustache'." ;
85- `P " Included files are resolved in a search path, which contains the current working directory
86- (unless the $(b,--no-working-dir) option is used)
87- and include directories passed through $(b,-I DIR) options." ;
88- `P " If a file exists in several directories of the search path, the directory included first
89- (leftmost $(b,-I) option) has precedence, and the current working directory has precedence
90- over include directories." ;
91- `S Manpage. s_examples;
92- `Pre
93- {|
56+ let manpage = Cmdliner. [
57+ `S Manpage. s_description;
58+ `P " $(tname) is a command-line tool coming with the $(i,ocaml-mustache) library,
59+ an OCaml implementation of the Mustache template format.
60+ $(tname) takes a data file and a template file as command-line parameters;
61+ it renders the populated template on standard output." ;
62+
63+ `P " Mustache is a simple and popular template format,
64+ with library implementations in many programming languages.
65+ It is named from its {{..}} delimiters." ;
66+
67+ `I (" Mustache website" ,
68+ " https://mustache.github.io/" );
69+ `I (" Mustache templates documentation" ,
70+ " https://mustache.github.io/mustache.5.html" );
71+ `I (" $(i,ocaml-mustache) website:" ,
72+ " https://github.com/rgrinberg/ocaml-mustache" );
73+
74+ `S Manpage. s_options;
75+ (* The content of this section is filled by Cmdliner; it is used here
76+ to enforce the placement of the non-standard sections below. *)
77+
78+ `S " PARTIALS" ;
79+ `P " The $(i,ocaml-mustache) library gives programmatic control over the meaning of partials {{>foo}}.
80+ For the $(tname) tool, partials are interpreted as template file inclusion: '{{>foo}}' includes
81+ the template file 'foo.mustache'." ;
82+ `P " Included files are resolved in a search path, which contains the current working directory
83+ (unless the $(b,--no-working-dir) option is used)
84+ and include directories passed through $(b,-I DIR) options." ;
85+ `P " If a file exists in several directories of the search path, the directory included first
86+ (leftmost $(b,-I) option) has precedence, and the current working directory has precedence
87+ over include directories." ;
88+
89+ `S Manpage. s_examples;
90+ `Pre {|
91+ # # Simple usage.
92+
9493\$ cat data.json
9594{ " name" : " OCaml" ,
9695 " qualities" : [{" name" : " simple" }, {" name" : " fun" }] }
@@ -109,6 +108,8 @@ Mustache is:
109108- fun
110109
111110
111+ ## Using a partial to include a subpage ; see $(b ,PARTIALS).
112+
112113\$ cat page .mustache
113114<html >
114115 <body >
@@ -124,13 +125,24 @@ Mustache is:
124125 - simple
125126 - fun
126127 </body >
127- </html >
128+ </html >|};
128129
129- |};
130- `S Manpage. s_bugs ;
131- `P "Report bugs on https://github.com/rgrinberg/ocaml-mustache/issues" ;
132- ]
133- in
130+ `S "CONFORMING TO" ;
131+
132+ `P "The $(i,ocaml-mustache) implementation is tested against
133+ the Mustache specification testsuite.
134+ All features are supported, except for lambdas and setting delimiter tags." ;
135+
136+ `I ("Mustache specification testsuite" ,
137+ "https://github.com/mustache/spec" );
138+
139+ `S "REPORTING BUGS" ;
140+ `P "Report bugs on https://github.com/rgrinberg/ocaml-mustache/issues" ;
141+ ]
142+
143+ let run_command =
144+ let open Cmdliner in
145+ let doc = "renders Mustache template from JSON data files" in
134146 let json_file =
135147 let doc = "data file in JSON format" in
136148 Arg. (required & pos 0 (some file ) None & info [] ~docv :"DATA.json" ~doc )
@@ -156,7 +168,7 @@ Mustache is:
156168 Term. (const search_path $ includes $ no_working_dir )
157169 in
158170 Term. (const run $ search_path $ json_file $ template_file ),
159- Term. info "mustache" ~doc ~man
171+ Term. info "mustache" ~doc ~man : manpage
160172
161173let () =
162174 let open Cmdliner in
0 commit comments