@@ -252,52 +252,43 @@ module Make (Syntax : SYNTAX) = struct
252252 let path id = Url.Path. from_identifier id
253253 let url id = Url. from_path (path id)
254254
255+ let to_link documentation implementation =
256+ let documentation =
257+ let open Paths.Path.Resolved in
258+ match documentation with
259+ | Some (`Resolved p ) when not (is_hidden (p :> t )) -> (
260+ let id = identifier (p :> t ) in
261+ match Url. from_identifier ~stop_before: false id with
262+ | Ok link -> Some link
263+ | _ -> None )
264+ | _ -> None
265+ in
266+ let implementation =
267+ match implementation with
268+ | None -> None
269+ | Some id -> (
270+ match Url.Anchor. from_identifier (id :> Paths.Identifier.t ) with
271+ | Ok url -> Some url
272+ | Error _ -> None )
273+ in
274+ Some (Source_page. Link { implementation; documentation })
275+
255276 let info_of_info : Lang.Source_info.annotation -> Source_page.info option =
256277 function
257- | Value id -> (
258- match Url.Anchor. from_identifier (id :> Paths.Identifier.t ) with
259- | Ok url -> Some (Link url)
260- | Error _ -> None )
261278 | Definition id -> (
262279 match id.iv with
263280 | `SourceLocation (_ , def ) -> Some (Anchor (DefName. to_string def))
264281 | `SourceLocationInternal (_ , local ) ->
265282 Some (Anchor (LocalName. to_string local))
266283 | _ -> None )
267- | ModulePath (`Resolved p)
268- when not (Paths.Path.Resolved. is_hidden (p :> Paths.Path.Resolved.t ))
269- -> (
270- let id = Paths.Path.Resolved. (identifier (p :> t )) in
271- match Url. from_identifier ~stop_before: false id with
272- | Ok link -> Some (Link link)
273- | _ -> None )
274- | TypePath (`Resolved p)
275- when not (Paths.Path.Resolved. is_hidden (p :> Paths.Path.Resolved.t ))
276- -> (
277- let id = Paths.Path.Resolved. (identifier (p :> t )) in
278- match Url. from_identifier ~stop_before: false id with
279- | Ok link -> Some (Link link)
280- | _ -> None )
281- | ValuePath (`Resolved p)
282- when not (Paths.Path.Resolved. is_hidden (p :> Paths.Path.Resolved.t ))
283- -> (
284- let id = Paths.Path.Resolved. (identifier (p :> t )) in
285- match Url. from_identifier ~stop_before: false id with
286- | Ok link -> Some (Link link)
287- | _ -> None )
288- | ConstructorPath (`Resolved p)
289- when not (Paths.Path.Resolved. is_hidden (p :> Paths.Path.Resolved.t ))
290- -> (
291- let id = Paths.Path.Resolved. (identifier (p :> t )) in
292- match Url. from_identifier ~stop_before: false id with
293- | Ok link -> Some (Link link)
294- | _ -> None )
295- | ModulePath _ -> None
296- | ClassPath _ -> None
297- | TypePath _ -> None
298- | MtyPath _ -> None
299- | ValuePath _ -> None
300- | ConstructorPath _ -> None
284+ | Module { documentation; _ } -> to_link documentation None
285+ | ModuleType { documentation; _ } -> to_link documentation None
286+ | Type { documentation; _ } -> to_link documentation None
287+ | Class { documentation; _ } -> to_link documentation None
288+ | Value { documentation; implementation } ->
289+ to_link documentation implementation
290+ | Constructor { documentation; _ } -> to_link documentation None
291+
301292
302293 let source id syntax_info infos source_code =
303294 let url = path id in
0 commit comments