@@ -111,6 +111,22 @@ let open_modules =
111
111
let default = [ " Stdlib" ] in
112
112
Arg. (value & opt_all string default & info ~docv: " MODULE" ~doc [ " open" ])
113
113
114
+ let section_pipeline = " COMMANDS: Compilation pipeline"
115
+ let section_generators = " COMMANDS: Alternative generators"
116
+ let section_support = " COMMANDS: Scripting"
117
+ let section_legacy = " COMMANDS: Legacy pipeline"
118
+ let section_deprecated = " COMMANDS: Deprecated"
119
+
120
+ (* * Sections in the order they should appear. *)
121
+ let sections =
122
+ [
123
+ section_pipeline;
124
+ section_generators;
125
+ section_support;
126
+ section_legacy;
127
+ section_deprecated;
128
+ ]
129
+
114
130
module Compile : sig
115
131
val output_file : dst :string option -> input :Fs .file -> Fs .file
116
132
@@ -224,7 +240,7 @@ end = struct
224
240
$ warnings_options))
225
241
226
242
let info =
227
- Term. info " compile"
243
+ Term. info " compile" ~docs: section_pipeline
228
244
~doc: " Compile a cmti, cmt, cmi or mld file to an odoc file."
229
245
end
230
246
@@ -243,7 +259,7 @@ module Support_files_command = struct
243
259
" Copy the support files (e.g. default theme, JavaScript files) to the \
244
260
output directory."
245
261
in
246
- Term. info ~doc " support-files"
262
+ Term. info ~docs: section_pipeline ~ doc " support-files"
247
263
end
248
264
249
265
module Css = struct
@@ -254,7 +270,7 @@ module Css = struct
254
270
" DEPRECATED: Use `odoc support-files' to copy the CSS file for the \
255
271
default theme."
256
272
in
257
- Term. info ~doc " css"
273
+ Term. info ~docs: section_deprecated ~ doc " css"
258
274
end
259
275
260
276
module Odoc_link : sig
@@ -295,7 +311,8 @@ end = struct
295
311
$ (const link $ odoc_file_directories $ input $ dst $ warnings_options
296
312
$ open_modules))
297
313
298
- let info = Term. info ~doc: " Link odoc files together" " link"
314
+ let info =
315
+ Term. info ~docs: section_pipeline ~doc: " Link odoc files together" " link"
299
316
end
300
317
301
318
module type S = sig
@@ -304,6 +321,8 @@ module type S = sig
304
321
val renderer : args Odoc_document.Renderer .t
305
322
306
323
val extra_args : args Cmdliner.Term .t
324
+
325
+ val generate_docs : string
307
326
end
308
327
309
328
module Make_renderer (R : S ) : sig
@@ -345,7 +364,7 @@ end = struct
345
364
let doc =
346
365
Format. sprintf " Render %s files from an odoc one" R. renderer.name
347
366
in
348
- Term. info ~doc R. renderer.name
367
+ Term. info ~docs: section_legacy ~ doc R. renderer.name
349
368
end
350
369
351
370
let process = Process. (cmd, info)
@@ -375,7 +394,7 @@ end = struct
375
394
let doc =
376
395
Format. sprintf " Generate %s files from an odocl one" R. renderer.name
377
396
in
378
- Term. info ~doc (R. renderer.name ^ " -generate" )
397
+ Term. info ~docs: R. generate_docs ~ doc (R. renderer.name ^ " -generate" )
379
398
end
380
399
381
400
let generate = Generate. (cmd, info)
@@ -407,7 +426,10 @@ end = struct
407
426
const handle_error
408
427
$ (const list_targets $ dst () $ back_compat $ R. extra_args $ input))
409
428
410
- let info = Term. info (R. renderer.name ^ " -targets" ) ~doc: " TODO: Fill in."
429
+ let info =
430
+ Term. info
431
+ (R. renderer.name ^ " -targets" )
432
+ ~docs: section_support ~doc: " TODO: Fill in."
411
433
end
412
434
413
435
let targets = Targets. (cmd, info)
@@ -430,8 +452,8 @@ end = struct
430
452
$ (const reference_to_url $ odoc_file_directories $ reference))
431
453
432
454
let info =
433
- Term. info ~doc: " Resolve a reference and output its corresponding url "
434
- " latex-url"
455
+ Term. info ~docs: section_support
456
+ ~doc: " Resolve a reference and output its corresponding url " " latex-url"
435
457
end
436
458
437
459
module Odoc_html_args = struct
@@ -534,6 +556,8 @@ module Odoc_html_args = struct
534
556
Term. (
535
557
const config $ semantic_uris $ closed_details $ indent $ theme_uri
536
558
$ support_uri $ flat $ as_json)
559
+
560
+ let generate_docs = section_pipeline
537
561
end
538
562
539
563
module Odoc_html = Make_renderer (Odoc_html_args )
@@ -563,8 +587,8 @@ end = struct
563
587
$ odoc_file_directories $ reference))
564
588
565
589
let info =
566
- Term. info ~doc: " Resolve a reference and output its corresponding url "
567
- " html-url"
590
+ Term. info ~docs: section_support
591
+ ~doc: " Resolve a reference and output its corresponding url " " html-url"
568
592
end
569
593
570
594
module Html_fragment : sig
@@ -612,8 +636,8 @@ end = struct
612
636
$ input $ warnings_options))
613
637
614
638
let info =
615
- Term. info ~doc: " Generates an html fragment file from an mld one "
616
- " html-fragment"
639
+ Term. info ~docs: section_legacy
640
+ ~doc: " Generates an html fragment file from an mld one " " html-fragment"
617
641
end
618
642
619
643
module Odoc_manpage = Make_renderer (struct
@@ -622,6 +646,8 @@ module Odoc_manpage = Make_renderer (struct
622
646
let renderer = Man_page. renderer
623
647
624
648
let extra_args = Term. const ()
649
+
650
+ let generate_docs = section_generators
625
651
end )
626
652
627
653
module Odoc_latex = Make_renderer (struct
@@ -636,6 +662,8 @@ module Odoc_latex = Make_renderer (struct
636
662
let extra_args =
637
663
let f with_children = { Latex. with_children } in
638
664
Term. (const f $ with_children)
665
+
666
+ let generate_docs = section_generators
639
667
end )
640
668
641
669
module Depends = struct
@@ -660,7 +688,7 @@ module Depends = struct
660
688
Term. (const list_dependencies $ input)
661
689
662
690
let info =
663
- Term. info " compile-deps"
691
+ Term. info " compile-deps" ~docs: section_legacy
664
692
~doc:
665
693
" List units (with their digest) which needs to be compiled in order \
666
694
to compile this one. The unit itself and its digest is also \
@@ -706,7 +734,7 @@ module Depends = struct
706
734
Term. (const handle_error $ (const list_dependencies $ input))
707
735
708
736
let info =
709
- Term. info " link-deps"
737
+ Term. info " link-deps" ~docs: section_legacy
710
738
~doc:
711
739
" lists the packages which need to be in odoc's load path to link the \
712
740
.odoc files in the given directory"
@@ -728,7 +756,9 @@ module Depends = struct
728
756
let cmd _ = Link. list_dependencies in
729
757
Term. (const handle_error $ (const cmd $ includes $ input))
730
758
731
- let info = Term. info " html-deps" ~doc: " DEPRECATED: alias for link-deps"
759
+ let info =
760
+ Term. info " html-deps" ~docs: section_deprecated
761
+ ~doc: " DEPRECATED: alias for link-deps"
732
762
end
733
763
end
734
764
@@ -742,7 +772,8 @@ module Targets = struct
742
772
743
773
let cmd = Term. (const list_targets $ Compile. dst $ Compile. input)
744
774
745
- let info = Term. info " compile-targets" ~doc: " TODO: Fill in."
775
+ let info =
776
+ Term. info " compile-targets" ~docs: section_legacy ~doc: " TODO: Fill in."
746
777
end
747
778
748
779
module Support_files = struct
@@ -753,7 +784,7 @@ module Targets = struct
753
784
Term. (const list_targets $ Support_files_command. without_theme $ dst () )
754
785
755
786
let info =
756
- Term. info " support-files-targets"
787
+ Term. info " support-files-targets" ~docs: section_support
757
788
~doc: " Lists the names of the files that 'odoc support-files' outputs."
758
789
end
759
790
end
@@ -774,7 +805,7 @@ module Odoc_error = struct
774
805
let cmd = Term. (const handle_error $ (const errors $ input))
775
806
776
807
let info =
777
- Term. info " errors"
808
+ Term. info " errors" ~docs: section_support
778
809
~doc: " Print errors that occurred while an .odoc file was generated."
779
810
end
780
811
@@ -815,8 +846,12 @@ let () =
815
846
" Available subcommands: %s\n See --help for more information.\n %!"
816
847
(String. concat ~sep: " , " available_subcommands)
817
848
in
849
+ let man =
850
+ (* Show sections in a defined order. *)
851
+ List. map ~f: (fun s -> `S s) sections
852
+ in
818
853
( Term. (const print_default $ const () ),
819
- Term. info ~version: " %%VERSION%%" " odoc" )
854
+ Term. info ~man ~ version:" %%VERSION%%" " odoc" )
820
855
in
821
856
match Term. eval_choice ~err: Format. err_formatter default subcommands with
822
857
| `Error _ ->
0 commit comments