@@ -102,12 +102,6 @@ let default_raw_markup_target_not_supported : Location.span -> Error.t =
102
102
Error. make ~suggestion: " try '{%html:...%}'."
103
103
" '{%%...%%}' (raw markup) needs a target language."
104
104
105
- let headings_not_allowed : Location.span -> Error.t =
106
- Error. make " Headings not allowed in this comment."
107
-
108
- let titles_not_allowed : Location.span -> Error.t =
109
- Error. make " Title-level headings {0 ...} are only allowed in pages."
110
-
111
105
let bad_heading_level : int -> Location.span -> Error.t =
112
106
Error. make " '%d': bad heading level (0-5 allowed)."
113
107
@@ -159,7 +153,6 @@ type alerts =
159
153
[ `Tag of [ `Alert of string * string option ] ] Location_ .with_location list
160
154
161
155
type status = {
162
- sections_allowed : sections_allowed ;
163
156
tags_allowed : bool ;
164
157
parent_of_sections : Paths.Identifier.LabelParent .t ;
165
158
}
@@ -450,42 +443,27 @@ let section_heading :
450
443
in
451
444
(top_heading_level, element)
452
445
in
453
-
454
- match (status.sections_allowed, level) with
455
- | `None , _any_level ->
456
- Error. raise_warning (headings_not_allowed location);
457
- let text = (text :> Comment.inline_element with_location list ) in
458
- let element =
459
- Location. at location
460
- (`Paragraph [ Location. at location (`Styled (`Bold , text)) ])
461
- in
462
- (top_heading_level, element)
463
- | `No_titles , 0 ->
464
- Error. raise_warning (titles_not_allowed location);
465
- mk_heading `Title
466
- | _ , level ->
467
- let level' =
468
- match level with
469
- | 0 -> `Title
470
- | 1 -> `Section
471
- | 2 -> `Subsection
472
- | 3 -> `Subsubsection
473
- | 4 -> `Paragraph
474
- | 5 -> `Subparagraph
475
- | _ ->
476
- Error. raise_warning (bad_heading_level level location);
477
- (* Implicitly promote to level-5. *)
478
- `Subparagraph
479
- in
480
- (match top_heading_level with
481
- | Some top_level
482
- when status.sections_allowed = `All && level < = top_level && level < = 5
483
- ->
484
- Error. raise_warning
485
- (heading_level_should_be_lower_than_top_level level top_level
486
- location)
487
- | _ -> () );
488
- mk_heading level'
446
+ let level' =
447
+ match level with
448
+ | 0 -> `Title
449
+ | 1 -> `Section
450
+ | 2 -> `Subsection
451
+ | 3 -> `Subsubsection
452
+ | 4 -> `Paragraph
453
+ | 5 -> `Subparagraph
454
+ | _ ->
455
+ Error. raise_warning (bad_heading_level level location);
456
+ (* Implicitly promote to level-5. *)
457
+ `Subparagraph
458
+ in
459
+ let () =
460
+ match top_heading_level with
461
+ | Some top_level when level < = top_level && level < = 5 ->
462
+ Error. raise_warning
463
+ (heading_level_should_be_lower_than_top_level level top_level location)
464
+ | _ -> ()
465
+ in
466
+ mk_heading level'
489
467
490
468
let validate_first_page_heading status ast_element =
491
469
match status.parent_of_sections.iv with
@@ -508,7 +486,7 @@ let top_level_block_elements status ast_elements =
508
486
| [] -> List. rev comment_elements_acc
509
487
| ast_element :: ast_elements -> (
510
488
(* The first [ast_element] in pages must be a title or section heading. *)
511
- if status.sections_allowed = `All && top_heading_level = None then
489
+ if top_heading_level = None then
512
490
validate_first_page_heading status ast_element;
513
491
514
492
match ast_element with
@@ -597,23 +575,23 @@ let append_alerts_to_comment alerts
597
575
in
598
576
comment @ (alerts : alerts :> Comment.docs )
599
577
600
- let ast_to_comment ~internal_tags ~sections_allowed ~ tags_allowed
601
- ~ parent_of_sections (ast : Ast.t ) alerts =
578
+ let ast_to_comment ~internal_tags ~tags_allowed ~ parent_of_sections
579
+ (ast : Ast.t ) alerts =
602
580
Error. catch_warnings (fun () ->
603
- let status = { sections_allowed; tags_allowed; parent_of_sections } in
581
+ let status = { tags_allowed; parent_of_sections } in
604
582
let ast, tags = strip_internal_tags ast in
605
583
let elts =
606
584
top_level_block_elements status ast |> append_alerts_to_comment alerts
607
585
in
608
586
(elts, handle_internal_tags tags internal_tags))
609
587
610
- let parse_comment ~internal_tags ~sections_allowed ~ tags_allowed
611
- ~containing_definition ~ location ~ text =
588
+ let parse_comment ~internal_tags ~tags_allowed ~ containing_definition ~ location
589
+ ~text =
612
590
Error. catch_warnings (fun () ->
613
591
let ast =
614
592
Odoc_parser. parse_comment ~location ~text |> Error. raise_parser_warnings
615
593
in
616
- ast_to_comment ~internal_tags ~sections_allowed ~ tags_allowed
594
+ ast_to_comment ~internal_tags ~tags_allowed
617
595
~parent_of_sections: containing_definition ast []
618
596
|> Error. raise_warnings)
619
597
0 commit comments