@@ -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
@@ -540,6 +562,8 @@ module Odoc_html_args = struct
540
562
Term. (
541
563
const config $ semantic_uris $ closed_details $ indent $ theme_uri
542
564
$ support_uri $ flat $ omit_breadcrumbs $ omit_toc $ content_only)
565
+
566
+ let generate_docs = section_pipeline
543
567
end
544
568
545
569
module Odoc_html = Make_renderer (Odoc_html_args )
@@ -569,8 +593,8 @@ end = struct
569
593
$ odoc_file_directories $ reference))
570
594
571
595
let info =
572
- Term. info ~doc: " Resolve a reference and output its corresponding url "
573
- " html-url"
596
+ Term. info ~docs: section_support
597
+ ~doc: " Resolve a reference and output its corresponding url " " html-url"
574
598
end
575
599
576
600
module Html_fragment : sig
@@ -618,8 +642,8 @@ end = struct
618
642
$ input $ warnings_options))
619
643
620
644
let info =
621
- Term. info ~doc: " Generates an html fragment file from an mld one "
622
- " html-fragment"
645
+ Term. info ~docs: section_legacy
646
+ ~doc: " Generates an html fragment file from an mld one " " html-fragment"
623
647
end
624
648
625
649
module Odoc_manpage = Make_renderer (struct
@@ -628,6 +652,8 @@ module Odoc_manpage = Make_renderer (struct
628
652
let renderer = Man_page. renderer
629
653
630
654
let extra_args = Term. const ()
655
+
656
+ let generate_docs = section_generators
631
657
end )
632
658
633
659
module Odoc_latex = Make_renderer (struct
@@ -642,6 +668,8 @@ module Odoc_latex = Make_renderer (struct
642
668
let extra_args =
643
669
let f with_children = { Latex. with_children } in
644
670
Term. (const f $ with_children)
671
+
672
+ let generate_docs = section_generators
645
673
end )
646
674
647
675
module Depends = struct
@@ -666,7 +694,7 @@ module Depends = struct
666
694
Term. (const list_dependencies $ input)
667
695
668
696
let info =
669
- Term. info " compile-deps"
697
+ Term. info " compile-deps" ~docs: section_legacy
670
698
~doc:
671
699
" List units (with their digest) which needs to be compiled in order \
672
700
to compile this one. The unit itself and its digest is also \
@@ -712,7 +740,7 @@ module Depends = struct
712
740
Term. (const handle_error $ (const list_dependencies $ input))
713
741
714
742
let info =
715
- Term. info " link-deps"
743
+ Term. info " link-deps" ~docs: section_legacy
716
744
~doc:
717
745
" lists the packages which need to be in odoc's load path to link the \
718
746
.odoc files in the given directory"
@@ -734,7 +762,9 @@ module Depends = struct
734
762
let cmd _ = Link. list_dependencies in
735
763
Term. (const handle_error $ (const cmd $ includes $ input))
736
764
737
- let info = Term. info " html-deps" ~doc: " DEPRECATED: alias for link-deps"
765
+ let info =
766
+ Term. info " html-deps" ~docs: section_deprecated
767
+ ~doc: " DEPRECATED: alias for link-deps"
738
768
end
739
769
end
740
770
@@ -748,7 +778,8 @@ module Targets = struct
748
778
749
779
let cmd = Term. (const list_targets $ Compile. dst $ Compile. input)
750
780
751
- let info = Term. info " compile-targets" ~doc: " TODO: Fill in."
781
+ let info =
782
+ Term. info " compile-targets" ~docs: section_legacy ~doc: " TODO: Fill in."
752
783
end
753
784
754
785
module Support_files = struct
@@ -759,7 +790,7 @@ module Targets = struct
759
790
Term. (const list_targets $ Support_files_command. without_theme $ dst () )
760
791
761
792
let info =
762
- Term. info " support-files-targets"
793
+ Term. info " support-files-targets" ~docs: section_support
763
794
~doc: " Lists the names of the files that 'odoc support-files' outputs."
764
795
end
765
796
end
@@ -780,7 +811,7 @@ module Odoc_error = struct
780
811
let cmd = Term. (const handle_error $ (const errors $ input))
781
812
782
813
let info =
783
- Term. info " errors"
814
+ Term. info " errors" ~docs: section_support
784
815
~doc: " Print errors that occurred while an .odoc file was generated."
785
816
end
786
817
@@ -821,8 +852,12 @@ let () =
821
852
" Available subcommands: %s\n See --help for more information.\n %!"
822
853
(String. concat ~sep: " , " available_subcommands)
823
854
in
855
+ let man =
856
+ (* Show sections in a defined order. *)
857
+ List. map ~f: (fun s -> `S s) sections
858
+ in
824
859
( Term. (const print_default $ const () ),
825
- Term. info ~version: " %%VERSION%%" " odoc" )
860
+ Term. info ~man ~ version:" %%VERSION%%" " odoc" )
826
861
in
827
862
match Term. eval_choice ~err: Format. err_formatter default subcommands with
828
863
| `Error _ ->
0 commit comments