@@ -25,6 +25,7 @@ let describe_internal_tag = function
2525 | `Closed -> " @closed"
2626 | `Hidden -> " @hidden"
2727 | `Children_order _ -> " @children_order"
28+ | `Short_title _ -> " @short_title"
2829
2930let warn_unexpected_tag { Location. value; location } =
3031 Error. raise_warning
@@ -54,45 +55,6 @@ let rec find_tags acc ~filter = function
5455 warn_unexpected_tag hd;
5556 find_tags acc ~filter tl)
5657
57- let handle_internal_tags (type a ) tags : a handle_internal_tags -> a = function
58- | Expect_status -> (
59- match
60- find_tag
61- (function (`Inline | `Open | `Closed ) as t -> Some t | _ -> None )
62- tags
63- with
64- | Some (status , _ ) -> status
65- | None -> `Default )
66- | Expect_canonical -> (
67- match find_tag (function `Canonical p -> Some p | _ -> None ) tags with
68- | Some (`Root _ , location ) ->
69- warn_root_canonical location;
70- None
71- | Some ((`Dot _ as p ), _ ) -> Some p
72- | None -> None )
73- | Expect_page_tags ->
74- let unparsed_lines =
75- find_tags []
76- ~filter: (function `Children_order _ as p -> Some p | _ -> None )
77- tags
78- in
79- let lines =
80- List. filter_map
81- (function
82- | `Children_order co , loc -> (
83- match Frontmatter. parse_children_order loc co with
84- | Ok co -> Some co
85- | Error e ->
86- Error. raise_warning e;
87- None ))
88- unparsed_lines
89- in
90- Frontmatter. of_lines lines |> Error. raise_warnings
91- | Expect_none ->
92- (* Will raise warnings. *)
93- ignore (find_tag (fun _ -> None ) tags);
94- ()
95-
9658(* Errors *)
9759let invalid_raw_markup_target : string -> Location.span -> Error.t =
9860 Error. make ~suggestion: " try '{%html:...%}'."
@@ -135,6 +97,7 @@ let describe_element = function
13597 | `Link (_ , _ ) -> " '{{:...} ...}' (external link)"
13698 | `Heading (level , _ , _ ) ->
13799 Printf. sprintf " '{%i ...}' (section heading)" level
100+ | `Specific s -> s
138101
139102(* End of errors *)
140103
@@ -185,7 +148,8 @@ type surrounding =
185148 | `Reference of
186149 [ `Simple | `With_text ]
187150 * string Location_ .with_location
188- * Odoc_parser.Ast .inline_element Location_ .with_location list ]
151+ * Odoc_parser.Ast .inline_element Location_ .with_location list
152+ | `Specific of string ]
189153
190154let rec non_link_inline_element :
191155 surrounding :surrounding ->
@@ -521,12 +485,13 @@ let strip_internal_tags ast : internal_tags_removed with_location list * _ =
521485 in
522486 match tag with
523487 | (`Inline | `Open | `Closed | `Hidden ) as tag -> next tag
524- | `Children_order co ->
488+ | (`Children_order _ | `Short_title _ ) as tag ->
489+ let tag_name = describe_internal_tag tag in
525490 if not start then
526491 Error. raise_warning
527- (Error. make " @children_order tag has to be before any content"
492+ (Error. make " %s tag has to be before any content" tag_name
528493 wloc.location);
529- next ( `Children_order co)
494+ next tag
530495 | `Canonical { Location. value = s ; location = r_location } -> (
531496 match
532497 Error. raise_warnings (Reference. read_path_longident r_location s)
@@ -565,6 +530,51 @@ let append_alerts_to_comment alerts
565530 in
566531 comment @ (alerts : alerts :> Comment.docs )
567532
533+ let handle_internal_tags (type a ) tags : a handle_internal_tags -> a = function
534+ | Expect_status -> (
535+ match
536+ find_tag
537+ (function (`Inline | `Open | `Closed ) as t -> Some t | _ -> None )
538+ tags
539+ with
540+ | Some (status , _ ) -> status
541+ | None -> `Default )
542+ | Expect_canonical -> (
543+ match find_tag (function `Canonical p -> Some p | _ -> None ) tags with
544+ | Some (`Root _ , location ) ->
545+ warn_root_canonical location;
546+ None
547+ | Some ((`Dot _ as p ), _ ) -> Some p
548+ | None -> None )
549+ | Expect_page_tags ->
550+ let unparsed_lines =
551+ find_tags []
552+ ~filter: (function
553+ | (`Children_order _ | `Short_title _ ) as p -> Some p | _ -> None )
554+ tags
555+ in
556+ let lines =
557+ let do_ parse loc els =
558+ let els = nestable_block_elements els in
559+ match parse loc els with
560+ | Ok res -> Some res
561+ | Error e ->
562+ Error. raise_warning e;
563+ None
564+ in
565+ List. filter_map
566+ (function
567+ | `Children_order co , loc ->
568+ do_ Frontmatter. parse_children_order loc co
569+ | `Short_title t , loc -> do_ Frontmatter. parse_short_title loc t)
570+ unparsed_lines
571+ in
572+ Frontmatter. of_lines lines |> Error. raise_warnings
573+ | Expect_none ->
574+ (* Will raise warnings. *)
575+ ignore (find_tag (fun _ -> None ) tags);
576+ ()
577+
568578let ast_to_comment ~internal_tags ~tags_allowed ~parent_of_sections
569579 (ast : Ast.t ) alerts =
570580 Error. catch_warnings (fun () ->
@@ -595,3 +605,11 @@ let parse_reference text =
595605 }
596606 in
597607 Reference. parse location text
608+
609+ let non_link_inline_element :
610+ context :string ->
611+ Odoc_parser.Ast. inline_element with_location list ->
612+ Comment. non_link_inline_element with_location list =
613+ fun ~context elements ->
614+ let surrounding = `Specific context in
615+ non_link_inline_elements ~surrounding elements
0 commit comments