@@ -25,6 +25,7 @@ let describe_internal_tag = function
25
25
| `Closed -> " @closed"
26
26
| `Hidden -> " @hidden"
27
27
| `Children_order _ -> " @children_order"
28
+ | `Short_title _ -> " @short_title"
28
29
29
30
let warn_unexpected_tag { Location. value; location } =
30
31
Error. raise_warning
@@ -54,45 +55,6 @@ let rec find_tags acc ~filter = function
54
55
warn_unexpected_tag hd;
55
56
find_tags acc ~filter tl)
56
57
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
-
96
58
(* Errors *)
97
59
let invalid_raw_markup_target : string -> Location.span -> Error.t =
98
60
Error. make ~suggestion: " try '{%html:...%}'."
@@ -135,6 +97,7 @@ let describe_element = function
135
97
| `Link (_ , _ ) -> " '{{:...} ...}' (external link)"
136
98
| `Heading (level , _ , _ ) ->
137
99
Printf. sprintf " '{%i ...}' (section heading)" level
100
+ | `Specific s -> s
138
101
139
102
(* End of errors *)
140
103
@@ -185,7 +148,8 @@ type surrounding =
185
148
| `Reference of
186
149
[ `Simple | `With_text ]
187
150
* 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 ]
189
153
190
154
let rec non_link_inline_element :
191
155
surrounding :surrounding ->
@@ -521,12 +485,13 @@ let strip_internal_tags ast : internal_tags_removed with_location list * _ =
521
485
in
522
486
match tag with
523
487
| (`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
525
490
if not start then
526
491
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
528
493
wloc.location);
529
- next ( `Children_order co)
494
+ next tag
530
495
| `Canonical { Location. value = s ; location = r_location } -> (
531
496
match
532
497
Error. raise_warnings (Reference. read_path_longident r_location s)
@@ -565,6 +530,51 @@ let append_alerts_to_comment alerts
565
530
in
566
531
comment @ (alerts : alerts :> Comment.docs )
567
532
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
+
568
578
let ast_to_comment ~internal_tags ~tags_allowed ~parent_of_sections
569
579
(ast : Ast.t ) alerts =
570
580
Error. catch_warnings (fun () ->
@@ -595,3 +605,11 @@ let parse_reference text =
595
605
}
596
606
in
597
607
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