Skip to content

Commit ac65504

Browse files
committed
Remove sections_allowed as it was not used (apart from in a test)
1 parent 97eddcb commit ac65504

File tree

5 files changed

+464
-491
lines changed

5 files changed

+464
-491
lines changed

src/loader/doc_attr.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ let pad_loc loc =
114114
{ loc.Location.loc_start with pos_cnum = loc.loc_start.pos_cnum + 3 }
115115

116116
let ast_to_comment ~internal_tags parent ast_docs alerts =
117-
Odoc_model.Semantics.ast_to_comment ~internal_tags ~sections_allowed:`All
117+
Odoc_model.Semantics.ast_to_comment ~internal_tags
118118
~tags_allowed:true ~parent_of_sections:parent ast_docs alerts
119119
|> Error.raise_warnings
120120

@@ -150,7 +150,6 @@ let attached_no_tag parent attrs =
150150
let read_string ~tags_allowed internal_tags parent location str =
151151
Odoc_model.Semantics.parse_comment
152152
~internal_tags
153-
~sections_allowed:`All
154153
~tags_allowed
155154
~containing_definition:parent
156155
~location

src/markdown/odoc_md.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ let parse id input_s =
1313
Doc_of_md.parse_comment ~location ~text:str ()
1414
in
1515
let (content, ()), semantics_warnings =
16-
Semantics.ast_to_comment ~internal_tags:Expect_none ~sections_allowed:`All
17-
~tags_allowed:false
16+
Semantics.ast_to_comment ~internal_tags:Expect_none ~tags_allowed:false
1817
~parent_of_sections:(id :> Paths.Identifier.LabelParent.t)
1918
content []
2019
|> Error.unpack_warnings

src/model/semantics.ml

Lines changed: 28 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
111105
let 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

161155
type 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

490468
let 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

src/model/semantics.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ type alerts =
1313

1414
val ast_to_comment :
1515
internal_tags:'tags handle_internal_tags ->
16-
sections_allowed:sections_allowed ->
1716
tags_allowed:bool ->
1817
parent_of_sections:Paths.Identifier.LabelParent.t ->
1918
Odoc_parser.Ast.t ->
@@ -22,7 +21,6 @@ val ast_to_comment :
2221

2322
val parse_comment :
2423
internal_tags:'tags handle_internal_tags ->
25-
sections_allowed:sections_allowed ->
2624
tags_allowed:bool ->
2725
containing_definition:Paths.Identifier.LabelParent.t ->
2826
location:Lexing.position ->

0 commit comments

Comments
 (0)