@@ -102,12 +102,6 @@ let default_raw_markup_target_not_supported : Location.span -> Error.t =
102102 Error. make ~suggestion: " try '{%html:...%}'."
103103 " '{%%...%%}' (raw markup) needs a target language."
104104
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-
111105let bad_heading_level : int -> Location.span -> Error.t =
112106 Error. make " '%d': bad heading level (0-5 allowed)."
113107
@@ -159,7 +153,6 @@ type alerts =
159153 [ `Tag of [ `Alert of string * string option ] ] Location_ .with_location list
160154
161155type status = {
162- sections_allowed : sections_allowed ;
163156 tags_allowed : bool ;
164157 parent_of_sections : Paths.Identifier.LabelParent .t ;
165158}
@@ -450,42 +443,27 @@ let section_heading :
450443 in
451444 (top_heading_level, element)
452445 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'
489467
490468let validate_first_page_heading status ast_element =
491469 match status.parent_of_sections.iv with
@@ -508,7 +486,7 @@ let top_level_block_elements status ast_elements =
508486 | [] -> List. rev comment_elements_acc
509487 | ast_element :: ast_elements -> (
510488 (* 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
512490 validate_first_page_heading status ast_element;
513491
514492 match ast_element with
@@ -597,23 +575,23 @@ let append_alerts_to_comment alerts
597575 in
598576 comment @ (alerts : alerts :> Comment.docs )
599577
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 =
602580 Error. catch_warnings (fun () ->
603- let status = { sections_allowed; tags_allowed; parent_of_sections } in
581+ let status = { tags_allowed; parent_of_sections } in
604582 let ast, tags = strip_internal_tags ast in
605583 let elts =
606584 top_level_block_elements status ast |> append_alerts_to_comment alerts
607585 in
608586 (elts, handle_internal_tags tags internal_tags))
609587
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 =
612590 Error. catch_warnings (fun () ->
613591 let ast =
614592 Odoc_parser. parse_comment ~location ~text |> Error. raise_parser_warnings
615593 in
616- ast_to_comment ~internal_tags ~sections_allowed ~ tags_allowed
594+ ast_to_comment ~internal_tags ~tags_allowed
617595 ~parent_of_sections: containing_definition ast []
618596 |> Error. raise_warnings)
619597
0 commit comments