@@ -90,6 +90,7 @@ let match_extra_odoc_reference_kind (_location as loc) s :
9090 Some `TLabel
9191 | "module-type" -> Some `TModuleType
9292 | "page" -> Some `TPage
93+ | "asset" -> Some `TAsset
9394 | "value" ->
9495 d loc " value" " val" ;
9596 Some `TValue
@@ -352,12 +353,24 @@ let parse whole_reference_location s :
352353 )
353354 in
354355
356+ let label_parent_path { identifier; location; _ } kind next_token tokens =
357+ let path () = path [ identifier ] next_token tokens in
358+ match kind with
359+ | `TUnknown -> `Any_path (path () )
360+ | `TModule -> `Module_path (path () )
361+ | `TPage -> `Page_path (path () )
362+ | _ ->
363+ expected ~expect_paths: true [ " module" ; " page" ] location
364+ |> Error. raise_exception
365+ in
366+
355367 let any_path { identifier; location; _ } kind next_token tokens =
356368 let path () = path [ identifier ] next_token tokens in
357369 match kind with
358370 | `TUnknown -> `Any_path (path () )
359371 | `TModule -> `Module_path (path () )
360372 | `TPage -> `Page_path (path () )
373+ | `TAsset -> `Asset_path (path () )
361374 | _ ->
362375 expected ~expect_paths: true [ " module" ; " page" ] location
363376 |> Error. raise_exception
@@ -379,7 +392,7 @@ let parse whole_reference_location s :
379392 location
380393 |> Error. raise_exception)
381394 | next_token :: tokens when ends_in_slash next_token ->
382- any_path token kind next_token tokens
395+ label_parent_path token kind next_token tokens
383396 | next_token :: tokens -> (
384397 match kind with
385398 | `TUnknown -> `Dot (label_parent next_token tokens, identifier)
@@ -499,6 +512,21 @@ let parse whole_reference_location s :
499512 in
500513 (* Prefixed pages are not differentiated. *)
501514 `Page_path (path [ identifier ] next_token tokens)
515+ | `TAsset ->
516+ let () =
517+ match next_token.kind with
518+ | `End_in_slash -> ()
519+ | `None | `Prefixed _ ->
520+ let suggestion =
521+ Printf. sprintf " Reference assets as '<parent_path>/%s'."
522+ identifier
523+ in
524+ not_allowed ~what: " Asset label"
525+ ~in_what: " on the right side of a dot" ~suggestion location
526+ |> Error. raise_exception
527+ in
528+ (* Prefixed assets are not differentiated. *)
529+ `Asset_path (path [ identifier ] next_token tokens)
502530 | `TPathComponent -> assert false )
503531 in
504532
0 commit comments