···49495050let source_anchor locs =
5151 match locs with
5252- | Some { Odoc_model.Lang.Locations.anchor = Some anchor; source_parent } ->
5353- Some (Url.Anchor.source_file_from_identifier source_parent ~anchor)
5454- | Some { Odoc_model.Lang.Locations.anchor = None; source_parent } ->
5555- let path = Url.Path.source_file_from_identifier source_parent in
5656- Some (Url.from_path path)
5252+ | Some id ->
5353+ Url.Anchor.from_identifier
5454+ (id : Paths.Identifier.SourceLocation.t :> Paths.Identifier.t)
5555+ |> Result.to_option
5756 | _ -> None
58575958let attach_expansion ?(status = `Default) (eq, o, e) page text =
···242241 string ->
243242 Source_page.t
244243 end = struct
245245- let path id = Url.Path.source_file_from_identifier id
244244+ let path id = Url.Path.from_identifier id
246245 let url id = Url.from_path (path id)
247246248247 let info_of_info url = function
···17921791 | `SourceDir (parent, _) ->
17931792 let mmap = add parent (add_dir dir) mmap in
17941793 dir_ancestors_add parent mmap
17951795- | `SourceRoot _ -> mmap
17941794+ | `Page _ -> mmap
17961795 in
17971796 let file_ancestors_add ({ iv = `SourcePage (parent, _); _ } as file)
17981797 mmap =
···18041803 M.empty dir_pages
18051804 in
18061805 let page_of_dir (dir : SourceDir.t) (dir_children, file_children) =
18071807- let url = Url.Path.source_dir_from_identifier dir in
18061806+ let url = Url.Path.from_identifier dir in
18081807 let block ?(attr = []) desc = Block.{ attr; desc } in
18091808 let inline ?(attr = []) desc = Inline.[ { attr; desc } ] in
18101809 let header =
18111811- let title = inline (Text (SourceDir.name dir)) in
18101810+ let title = inline (Text (name dir)) in
18121811 Item.Heading
18131812 Heading.{ label = None; level = 0; title; source_anchor = None }
18141813 in
···18221821 in
18231822 let li_of_child child =
18241823 match child with
18251825- | { iv = `SourceRoot _; _ } ->
18261826- assert false (* No [`SourceRoot] is child of a [`SourceDir] *)
18241824+ | { iv = `Page _; _ } ->
18251825+ assert false (* No [`Page] is child of a [`SourceDir] *)
18271826 | { iv = `SourceDir (_, name); _ } ->
18281828- let url =
18291829- child |> Url.Path.source_dir_from_identifier |> Url.from_path
18301830- in
18271827+ let url = child |> Url.Path.from_identifier |> Url.from_path in
18311828 (name, url)
18321829 in
18331830 let li_of_file_child ({ iv = `SourcePage (_, name); _ } as child) =
18341834- let url =
18351835- child |> Url.Path.source_file_from_identifier |> Url.from_path
18361836- in
18311831+ let url = child |> Url.Path.from_identifier |> Url.from_path in
18371832 (name, url)
18381833 in
18391834 let items =
+21-23
src/document/url.ml
···8282let ( >>= ) x f = match x with Ok x -> f x | Error _ as e -> e
83838484module Path = struct
8585- type source_pv =
8585+ type nonsrc_pv =
8686 [ Identifier.Page.t_pv
8787 | Identifier.Signature.t_pv
8888 | Identifier.ClassSignature.t_pv ]
8989+9090+ type source_pv =
9191+ [ nonsrc_pv | Identifier.SourcePage.t_pv | Identifier.SourceDir.t_pv ]
89929093 and source = source_pv Odoc_model.Paths.Identifier.id
9194···174177 let name = ClassTypeName.to_string name in
175178 mk ~parent kind name
176179 | { iv = `Result p; _ } -> from_identifier (p :> source)
180180+ | { iv = `SourceDir (parent, name); _ }
181181+ | { iv = `SourcePage (parent, name); _ } ->
182182+ let parent = from_identifier (parent :> source) in
183183+ let kind = `Page in
184184+ mk ~parent kind name
177185178186 let from_identifier p =
179187 from_identifier
180188 (p : [< source_pv ] Odoc_model.Paths.Identifier.id :> source)
181181-182182- let rec source_dir_from_identifier id =
183183- match id.Odoc_model.Paths.Identifier.iv with
184184- | `SourceRoot container -> from_identifier (container :> source)
185185- | `SourceDir (parent, name) ->
186186- let parent = source_dir_from_identifier parent in
187187- let kind = `Page in
188188- mk ~parent kind name
189189-190190- let source_file_from_identifier id =
191191- let (`SourcePage (parent, name)) = id.Odoc_model.Paths.Identifier.iv in
192192- let parent = source_dir_from_identifier parent in
193193- let kind = `SourcePage in
194194- mk ~parent kind name
195189196190 let to_list url =
197191 let rec loop acc { parent; name; kind } =
···369363 happen, [`Type] may not happen either but just in case, use the
370364 grand-parent. *)
371365 match parent with
372372- | { iv = #Path.source_pv; _ } as parent ->
373373- mk ~kind:`Section parent str_name
374366 | { iv = `CoreType _; _ } ->
375367 Error (Unexpected_anchor "core_type label parent")
376376- | { iv = `Type (gp, _); _ } -> mk ~kind:`Section gp str_name)
377377-378378- let source_file_from_identifier id ~anchor =
379379- let kind = `SourceAnchor in
380380- let page = Path.source_file_from_identifier id in
381381- { page; anchor; kind }
368368+ | { iv = `Type (gp, _); _ } -> mk ~kind:`Section gp str_name
369369+ | { iv = #Path.nonsrc_pv; _ } as p ->
370370+ mk ~kind:`Section (p :> Path.source) str_name)
371371+ | { iv = `SourceLocation (parent, loc); _ } ->
372372+ let page = Path.from_identifier (parent :> Path.source) in
373373+ Ok { page; kind = `SourceAnchor; anchor = DefName.to_string loc }
374374+ | { iv = `SourceLocationMod parent; _ } ->
375375+ let page = Path.from_identifier (parent :> Path.source) in
376376+ Ok { page; kind = `SourceAnchor; anchor = "" }
377377+ | { iv = `SourcePage (p, _name); _ } | { iv = `SourceDir (p, _name); _ } ->
378378+ let page = Path.from_identifier (p :> Path.source) in
379379+ Ok { page; kind = `Page; anchor = "" }
382380383381 let polymorphic_variant ~type_ident elt =
384382 let name_of_type_constr te =
+4-11
src/document/url.mli
···29293030 type t = { kind : kind; parent : t option; name : string }
31313232- type source_pv =
3232+ type nonsrc_pv =
3333 [ Identifier.Page.t_pv
3434 | Identifier.Signature.t_pv
3535 | Identifier.ClassSignature.t_pv ]
36363737+ type source_pv =
3838+ [ nonsrc_pv | Identifier.SourcePage.t_pv | Identifier.SourceDir.t_pv ]
3939+3740 and source = source_pv Odoc_model.Paths.Identifier.id
38413942 val from_identifier : [< source_pv ] Odoc_model.Paths.Identifier.id -> t
4040-4141- val source_dir_from_identifier : Odoc_model.Paths.Identifier.SourceDir.t -> t
4242- (** A path to a source dir. *)
4343-4444- val source_file_from_identifier :
4545- Odoc_model.Paths.Identifier.SourcePage.t -> t
4646- (** A path to a source file. *)
47434844 val to_list : t -> (kind * string) list
4945···9288 }
93899490 val from_identifier : Identifier.t -> (t, Error.t) result
9595-9696- val source_file_from_identifier :
9797- Odoc_model.Paths.Identifier.SourcePage.t -> anchor:string -> t
98919992 val polymorphic_variant :
10093 type_ident:Identifier.t ->
+7-5
src/loader/lookup_def.ml
···11111212(** Project an identifier into a shape. *)
1313let rec shape_of_id lookup_shape :
1414- [< Identifier.t_pv ] Identifier.id -> Shape.t option =
1414+ [< Identifier.NonSrc.t_pv ] Identifier.id -> Shape.t option =
1515 let proj parent kind name =
1616 let item = Shape.Item.make name kind in
1717- match shape_of_id lookup_shape (parent :> Identifier.t) with
1717+ match shape_of_id lookup_shape (parent :> Identifier.NonSrc.t) with
1818 | Some shape -> Some (Shape.proj shape item)
1919 | None -> None
2020 in
···2929 (* Apply the functor to an empty signature. This doesn't seem to cause
3030 any problem, as the shape would stop resolve on an item inside the
3131 result of the function, which is what we want. *)
3232- shape_of_id lookup_shape (parent :> Identifier.t) >>= fun parent ->
3232+ shape_of_id lookup_shape (parent :> Identifier.NonSrc.t) >>= fun parent ->
3333 Some (Shape.app parent ~arg:(Shape.str Shape.Item.Map.empty))
3434 | `ModuleType (parent, name) ->
3535 proj parent Kind.Module_type (ModuleTypeName.to_string name)
···6969 Uid.unpack_uid (Uid.of_shape_uid uid) >>= fun (unit_name, id) ->
7070 lookup_unit unit_name >>= fun (unit, _) ->
7171 unit.Lang.Compilation_unit.source_info >>= fun sources ->
7272- let anchor = id >>= fun id -> Some (Uid.anchor_of_id id) in
7373- Some { Lang.Locations.source_parent = sources.id; anchor }
7272+ let anchor_opt = id >>= fun id -> Some (Uid.anchor_of_id id) in
7373+ match anchor_opt with
7474+ | Some anchor -> Some (Paths.Identifier.Mk.source_location (sources.id,Odoc_model.Names.DefName.make_std anchor))
7575+ | None -> Some (Paths.Identifier.Mk.source_location_mod sources.id)
74767577let of_cmt (cmt : Cmt_format.cmt_infos) = cmt.cmt_impl_shape
7678
+2-2
src/loader/lookup_def.mli
···4455val lookup_def :
66 (string -> (Lang.Compilation_unit.t * t) option) ->
77- Identifier.t ->
88- Lang.Locations.t option
77+ Identifier.NonSrc.t ->
88+ Identifier.SourceLocation.t option
99(** Returns the root module containing the definition of the given identifier
1010 and the corresponding anchor. *)
1111
+10-21
src/model/lang.ml
···16161717open Paths
18181919-module Locations = struct
2020- type t = {
2121- source_parent : Identifier.SourcePage.t;
2222- (** Correspond to where the source code is stored. Might be different
2323- from the root component of the identifier inside expansions. *)
2424- anchor : string option;
2525- (** Location of the definition in the implementation file. *)
2626- }
2727-end
2828-1919+(** {3 Modules} *)
2920module Source_info = struct
3021 type anchor = { anchor : string }
3122···4031 type t = { id : Identifier.SourcePage.t; infos : infos }
4132end
42334343-(** {3 Modules} *)
4444-4534module rec Module : sig
4635 type decl =
4736 | Alias of (Path.Module.t * ModuleType.simple_expansion option)
···49385039 type t = {
5140 id : Identifier.Module.t;
5252- locs : Locations.t option;
5353- (** Locations might not be set when the module is artificially constructed from a functor argument. *)
4141+ locs : Identifier.SourceLocation.t option;
4242+ (** Identifier.SourceLocation might not be set when the module is artificially constructed from a functor argument. *)
5443 doc : Comment.docs;
5544 type_ : decl;
5645 canonical : Path.Module.t option;
···127116128117 type t = {
129118 id : Identifier.ModuleType.t;
130130- locs : Locations.t option;
119119+ locs : Identifier.SourceLocation.t option;
131120 (** Can be [None] for module types created by a type substitution. *)
132121 doc : Comment.docs;
133122 canonical : Path.ModuleType.t option;
···268257269258 type t = {
270259 id : Identifier.Type.t;
271271- locs : Locations.t option;
260260+ locs : Identifier.SourceLocation.t option;
272261 doc : Comment.docs;
273262 canonical : Path.Type.t option;
274263 equation : Equation.t;
···283272 module Constructor : sig
284273 type t = {
285274 id : Identifier.Extension.t;
286286- locs : Locations.t option;
275275+ locs : Identifier.SourceLocation.t option;
287276 doc : Comment.docs;
288277 args : TypeDecl.Constructor.argument;
289278 res : TypeExpr.t option;
···305294and Exception : sig
306295 type t = {
307296 id : Identifier.Exception.t;
308308- locs : Locations.t option;
297297+ locs : Identifier.SourceLocation.t option;
309298 doc : Comment.docs;
310299 args : TypeDecl.Constructor.argument;
311300 res : TypeExpr.t option;
···320309321310 type t = {
322311 id : Identifier.Value.t;
323323- locs : Locations.t option;
312312+ locs : Identifier.SourceLocation.t option;
324313 value : value;
325314 doc : Comment.docs;
326315 type_ : TypeExpr.t;
···337326338327 type t = {
339328 id : Identifier.Class.t;
340340- locs : Locations.t option;
329329+ locs : Identifier.SourceLocation.t option;
341330 doc : Comment.docs;
342331 virtual_ : bool;
343332 params : TypeDecl.param list;
···356345357346 type t = {
358347 id : Identifier.ClassType.t;
359359- locs : Locations.t option;
348348+ locs : Identifier.SourceLocation.t option;
360349 doc : Comment.docs;
361350 virtual_ : bool;
362351 params : TypeDecl.param list;
···5151 | `Method (_, name) -> MethodName.to_string name
5252 | `InstanceVariable (_, name) -> InstanceVariableName.to_string name
5353 | `Label (_, name) -> LabelName.to_string name
5454+ | `SourcePage (_, name) -> name
5555+ | `SourceDir (_, name) -> name
5656+ | `SourceLocation (_, anchor) -> DefName.to_string anchor
5757+ | `SourceLocationMod x -> name_aux (x :> t)
54585559 let name : [< t_pv ] id -> string = fun n -> name_aux (n :> t)
56605761 let rec label_parent_aux =
5862 let open Id in
5959- fun (n : t) ->
6363+ fun (n : non_src) ->
6064 match n with
6161- | { iv = `Result i; _ } -> label_parent_aux (i :> any)
6565+ | { iv = `Result i; _ } -> label_parent_aux (i :> non_src)
6266 | { iv = `CoreType _; _ } | { iv = `CoreException _; _ } -> assert false
6367 | { iv = `Root _; _ } as p -> (p :> label_parent)
6468 | { iv = `Page _; _ } as p -> (p :> label_parent)
···7983 | { iv = `Constructor (p, _); _ } -> (p : datatype :> label_parent)
8084 | { iv = `Field (p, _); _ } -> (p : parent :> label_parent)
81858282- let label_parent n = label_parent_aux (n :> t)
8686+ let label_parent n = label_parent_aux (n :> Id.non_src)
83878488 let equal x y = x.ihash = y.ihash && x.ikey = y.ikey
8589···255259 type t_pv = Id.container_page_pv
256260 end
257261262262+ module NonSrc = struct
263263+ type t = Paths_types.Identifier.non_src
264264+ type t_pv = Paths_types.Identifier.non_src_pv
265265+ end
266266+258267 module SourceDir = struct
259268 type t = Id.source_dir
260269 type t_pv = Id.source_dir_pv
261270 let equal = equal
262271 let hash = hash
263272 let compare = compare
264264- let rec name = function
265265- | { iv = `SourceDir (p, n); _ } -> name p ^ n ^ "/"
266266- | { iv = `SourceRoot _; _ } -> "./"
267273 end
268274269275 module SourcePage = struct
270276 type t = Id.source_page
271277 type t_pv = Id.source_page_pv
272272- let equal = equal
273273- let name { iv = `SourcePage (p, name); _ } = SourceDir.name p ^ name
274274-278278+ end
279279+280280+ module SourceLocation = struct
281281+ type t = Paths_types.Identifier.source_location
282282+ type t_pv = Paths_types.Identifier.source_location_pv
275283 end
276284277285 module OdocId = struct
···367375 let source_page (container_page, path) =
368376 let rec source_dir dir =
369377 match dir with
370370- | [] ->
371371- mk_parent
372372- (fun () -> "")
373373- "sr"
374374- (fun (p, ()) -> `SourceRoot p)
375375- (container_page, ())
378378+ | [] -> (container_page : ContainerPage.t :> SourceDir.t)
376379 | a :: q ->
377380 let parent = source_dir q in
378381 mk_parent
···478481 LabelParent.t * LabelName.t ->
479482 [> `Label of LabelParent.t * LabelName.t ] id =
480483 mk_parent LabelName.to_string "l" (fun (p, n) -> `Label (p, n))
484484+485485+ let source_location :
486486+ SourcePage.t * DefName.t ->
487487+ [> `SourceLocation of SourcePage.t * DefName.t ] id =
488488+ mk_parent DefName.to_string "sl" (fun (p, n) -> `SourceLocation (p, n))
489489+490490+ let source_location_mod :
491491+ SourcePage.t -> [> `SourceLocationMod of SourcePage.t ] id =
492492+ fun s ->
493493+ mk_parent
494494+ (fun () -> "__slm__")
495495+ ""
496496+ (fun (s, ()) -> `SourceLocationMod s)
497497+ (s, ())
481498 end
482499end
483500
+23-10
src/model/paths.mli
···60606161 module Type : IdSig with type t = Id.type_ and type t_pv = Id.type_pv
62626363- module SourceDir : sig
6464-6565- include IdSig with type t = Id.source_dir and type t_pv = Id.source_dir_pv
6666- val name : t -> string
6767- end
6363+ module SourceDir :
6464+ IdSig with type t = Id.source_dir and type t_pv = Id.source_dir_pv
68656966 module Class : IdSig with type t = Id.class_ and type t_pv = Id.class_pv
7067···121118 end
122119 module Label :
123120 IdSig
124124- with type t = Paths_types.Identifier.label
125125- and type t_pv = Paths_types.Identifier.label_pv
121121+ with type t = Id.label
122122+ and type t_pv = Id.label_pv
126123127124 module Page : sig
128125 type t = Id.page
···134131 type t_pv = Id.container_page_pv
135132 end
136133134134+ module NonSrc : sig
135135+ type t = Id.non_src
136136+ type t_pv = Id.non_src_pv
137137+ end
138138+137139 module SourcePage : sig
138140 type t = Id.source_page
139141 type t_pv = Id.source_page_pv
140140- val name : t -> string
141141- val equal : t -> t -> bool
142142+ end
143143+144144+ module SourceLocation : sig
145145+ type t = Id.source_location
146146+ type t_pv = Id.source_location_pv
142147 end
148148+143149 module OdocId : sig
144150 type t = Id.odoc_id
145151 type t_pv = Id.odoc_id_pv
···177183178184 val equal : ([< t_pv ] id as 'a) -> 'a -> bool
179185180180- val label_parent : [< t_pv ] id -> LabelParent.t
186186+ val label_parent : [< NonSrc.t_pv ] id -> LabelParent.t
181187182188 module Maps : sig
183189 module Any : Map.S with type key = Any.t
···277283 val label :
278284 LabelParent.t * LabelName.t ->
279285 [> `Label of LabelParent.t * LabelName.t ] id
286286+287287+ val source_location :
288288+ SourcePage.t * DefName.t ->
289289+ [> `SourceLocation of SourcePage.t * DefName.t ] id
290290+291291+ val source_location_mod :
292292+ SourcePage.t -> [> `SourceLocationMod of SourcePage.t ] id
280293 end
281294end
282295
+22-3
src/model/paths_types.ml
···1818 and page = page_pv id
1919 (** @canonical Odoc_model.Paths.Identifier.Page.t *)
20202121- type source_dir_pv =
2222- [ `SourceRoot of container_page | `SourceDir of source_dir * string ]
2121+ type source_dir_pv = [ container_page_pv | `SourceDir of source_dir * string ]
2222+ (** @canonical Odoc_model.Paths.Identifier.SourceDir.t_pv *)
23232424 and source_dir = source_dir_pv id
2525+ (** @canonical Odoc_model.Paths.Identifier.SourceDir.t *)
25262627 type source_page_pv = [ `SourcePage of source_dir * string ]
2728 (** The second argument is the filename.
···30313132 type source_page = source_page_pv id
3233 (** @canonical Odoc_model.Paths.Identifier.SourcePage.t *)
3434+3535+ type source_location_pv =
3636+ [ `SourceLocationMod of source_page
3737+ | `SourceLocation of source_page * DefName.t ]
3838+ (** @canonical Odoc_model.Paths.Identifier.SourceLocation.t *)
3939+4040+ and source_location = source_location_pv id
4141+ (** @canonical Odoc_model.Paths.Identifier.SourceLocation.t_pv *)
33423443 type odoc_id_pv = [ page_pv | `Root of container_page option * ModuleName.t ]
3544 (** @canonical Odoc_model.Paths.Identifier.OdocId.t_pv *)
···177186 and label = label_pv id
178187 (** @canonical Odoc_model.Paths.Identifier.Label.t *)
179188180180- type any_pv =
189189+ type non_src_pv =
181190 [ signature_pv
182191 | class_signature_pv
183192 | datatype_pv
···199208 | instance_variable_pv
200209 | label_pv
201210 | page_pv ]
211211+ (** @canonical Odoc_model.Paths.Identifier.NonSrc.t_pv *)
212212+213213+ and non_src = non_src_pv id
214214+ (** @canonical Odoc_model.Paths.Identifier.NonSrc.t *)
215215+216216+ type any_pv =
217217+ [ non_src_pv
218218+ | source_page_pv
219219+ | source_dir_pv
220220+ | source_location_pv ]
202221 (** @canonical Odoc_model.Paths.Identifier.t_pv *)
203222204223 and any = any_pv id
+10-21
src/model_desc/lang_desc.ml
···1616 | `Closed -> C0 "`Closed"
1717 | `Inline -> C0 "`Inline")
18181919-let locations =
2020- let open Lang.Locations in
2121- Record
2222- [
2323- F ("source_parent", (fun t -> t.source_parent), sourcepage_identifier);
2424- F ("anchor", (fun t -> t.anchor), Option string);
2525- ]
2626-2719let source_info =
2820 let open Lang.Source_info in
2929- Record [ F ("id", (fun t -> t.id), sourcepage_identifier) ]
2121+ Record [ F ("id", (fun t -> t.id), identifier) ]
30223123(** {3 Module} *)
3224···4638 Record
4739 [
4840 F ("id", (fun t -> t.id), identifier);
4949- F ("locs", (fun t -> t.locs), Option locations);
4141+ F ("locs", (fun t -> t.locs), Option identifier);
5042 F ("doc", (fun t -> t.doc), docs);
5143 F ("type_", (fun t -> t.type_), module_decl);
5244 F
···180172 Record
181173 [
182174 F ("id", (fun t -> t.id), identifier);
183183- F ("locs", (fun t -> t.locs), Option locations);
175175+ F ("locs", (fun t -> t.locs), Option identifier);
184176 F ("doc", (fun t -> t.doc), docs);
185177 F
186178 ( "canonical",
···370362 Record
371363 [
372364 F ("id", (fun t -> t.id), identifier);
373373- F ("locs", (fun t -> t.locs), Option locations);
365365+ F ("locs", (fun t -> t.locs), Option identifier);
374366 F ("doc", (fun t -> t.doc), docs);
375367 F ("equation", (fun t -> t.equation), typedecl_equation);
376368 F
···385377 Record
386378 [
387379 F ("id", (fun t -> t.id), identifier);
388388- F ("locs", (fun t -> t.locs), Option locations);
380380+ F ("locs", (fun t -> t.locs), Option identifier);
389381 F ("doc", (fun t -> t.doc), docs);
390382 F ("args", (fun t -> t.args), typedecl_constructor_argument);
391383 F ("res", (fun t -> t.res), Option typeexpr_t);
···409401 Record
410402 [
411403 F ("id", (fun t -> t.id), identifier);
412412- F ("locs", (fun t -> t.locs), Option locations);
404404+ F ("locs", (fun t -> t.locs), Option identifier);
413405 F ("doc", (fun t -> t.doc), docs);
414406 F ("args", (fun t -> t.args), typedecl_constructor_argument);
415407 F ("res", (fun t -> t.res), Option typeexpr_t);
···427419 Record
428420 [
429421 F ("id", (fun t -> t.id), identifier);
430430- F ("locs", (fun t -> t.locs), Option locations);
422422+ F ("locs", (fun t -> t.locs), Option identifier);
431423 F ("doc", (fun t -> t.doc), docs);
432424 F ("type_", (fun t -> t.type_), typeexpr_t);
433425 F ("value", (fun t -> t.value), value_value_t);
···451443 Record
452444 [
453445 F ("id", (fun t -> t.id), identifier);
454454- F ("locs", (fun t -> t.locs), Option locations);
446446+ F ("locs", (fun t -> t.locs), Option identifier);
455447 F ("doc", (fun t -> t.doc), docs);
456448 F ("virtual_", (fun t -> t.virtual_), bool);
457449 F ("params", (fun t -> t.params), List typedecl_param);
···474466 Record
475467 [
476468 F ("id", (fun t -> t.id), identifier);
477477- F ("locs", (fun t -> t.locs), Option locations);
469469+ F ("locs", (fun t -> t.locs), Option identifier);
478470 F ("doc", (fun t -> t.doc), docs);
479471 F ("virtual_", (fun t -> t.virtual_), bool);
480472 F ("params", (fun t -> t.params), List typedecl_param);
···712704 F ("name", (fun t -> t.name), identifier);
713705 F ("root", (fun t -> t.root), root);
714706 F ("digest", (fun t -> t.digest), Digest.t);
715715- F
716716- ( "source_children",
717717- (fun t -> t.source_children),
718718- List sourcepage_identifier );
707707+ F ("source_children", (fun t -> t.source_children), List identifier);
719708 ]
+17-20
src/model_desc/paths_desc.ml
···3737 let pagename = To_string PageName.to_string
38383939 let parametername = To_string ModuleName.to_string
4040+4141+ let defname = To_string DefName.to_string
4042end
41434244module General_paths = struct
···149151 C
150152 ( "`Label",
151153 ((parent :> id_t), name),
152152- Pair (identifier, Names.labelname) ))
154154+ Pair (identifier, Names.labelname) )
155155+ | `SourceDir (parent, name) ->
156156+ C ("`SourceDir", ((parent :> id_t), name), Pair (identifier, string))
157157+ | `SourcePage (parent, name) ->
158158+ C
159159+ ( "`SourcePage",
160160+ ((parent :> id_t), name),
161161+ Pair (identifier, string) )
162162+ | `SourceLocation (parent, name) ->
163163+ C
164164+ ( "`SourceLocation",
165165+ ((parent :> id_t), name),
166166+ Pair (identifier, Names.defname) )
167167+ | `SourceLocationMod parent ->
168168+ C ("`SourceLocationMod", (parent :> id_t), identifier))
153169154170 let reference_tag : tag t =
155171 Variant
···433449(* Indirection seems to be required to make the type open. *)
434450let identifier : [< Paths.Identifier.t_pv ] Paths.Identifier.id Type_desc.t =
435451 Indirect ((fun n -> (n :> Paths.Identifier.t)), General_paths.identifier)
436436-437437-let rec sourcedir_identifier : Paths.Identifier.SourceDir.t Type_desc.t =
438438- Variant
439439- (fun id ->
440440- match id.iv with
441441- | `SourceDir (parent, name) ->
442442- C ("`SourceDir", (parent, name), Pair (sourcedir_identifier, string))
443443- | `SourceRoot parent ->
444444- C
445445- ( "`SourceRoot",
446446- (parent :> Paths.Identifier.t),
447447- General_paths.identifier ))
448448-449449-let sourcepage_identifier : Paths.Identifier.SourcePage.t Type_desc.t =
450450- Indirect
451451- ( (fun id ->
452452- let (`SourcePage (parent, name)) = id.iv in
453453- (parent, name)),
454454- Pair (sourcedir_identifier, string) )
455452456453let resolved_path : [< Paths.Path.Resolved.t ] Type_desc.t =
457454 Indirect ((fun n -> (n :> General_paths.rp)), General_paths.resolved_path)
···309309 | { Paths.Identifier.iv = `Page _; _ } as parent_id ->
310310 let name = Paths.Identifier.Mk.source_page (parent_id, name) in
311311 if
312312- List.exists (Paths.Identifier.SourcePage.equal name) page.source_children
312312+ List.exists
313313+ (Paths.Identifier.equal name)
314314+ page.source_children
313315 then Ok (Some name)
314316 else err_not_parent ()
315317 | { iv = `LeafPage _; _ } -> err_not_parent ())
+1-1
src/odoc/html_page.ml
···3737 source_code;
3838 ])
3939 | Some { id; _ }, None ->
4040- let filename = Paths.Identifier.SourcePage.name id in
4040+ let filename = Paths.Identifier.name id in
4141 Error.raise_warning
4242 (Error.filename_only
4343 "The --source should be passed when generating documents from \
···6666 | ModuleType of ModuleType.expr
67676868 type t = {
6969- locs : Odoc_model.Lang.Locations.t option;
6969+ locs : Odoc_model.Paths.Identifier.SourceLocation.t option;
7070 doc : CComment.docs;
7171 type_ : decl;
7272 canonical : Odoc_model.Paths.Path.Module.t option;
···134134 module Constructor : sig
135135 type t = {
136136 name : string;
137137- locs : Odoc_model.Lang.Locations.t option;
137137+ locs : Odoc_model.Paths.Identifier.SourceLocation.t option;
138138 doc : CComment.docs;
139139 args : TypeDecl.Constructor.argument;
140140 res : TypeExpr.t option;
···152152153153and Exception : sig
154154 type t = {
155155- locs : Odoc_model.Lang.Locations.t option;
155155+ locs : Odoc_model.Paths.Identifier.SourceLocation.t option;
156156 doc : CComment.docs;
157157 args : TypeDecl.Constructor.argument;
158158 res : TypeExpr.t option;
···214214 | TypeOf of typeof_t
215215216216 type t = {
217217- locs : Odoc_model.Lang.Locations.t option;
217217+ locs : Odoc_model.Paths.Identifier.SourceLocation.t option;
218218 doc : CComment.docs;
219219 canonical : Odoc_model.Paths.Path.ModuleType.t option;
220220 expr : expr option;
···261261 end
262262263263 type t = {
264264- locs : Odoc_model.Lang.Locations.t option;
264264+ locs : Odoc_model.Paths.Identifier.SourceLocation.t option;
265265 doc : CComment.docs;
266266 canonical : Odoc_model.Paths.Path.Type.t option;
267267 equation : Equation.t;
···326326 type value = Odoc_model.Lang.Value.value
327327328328 type t = {
329329- locs : Odoc_model.Lang.Locations.t option;
329329+ locs : Odoc_model.Paths.Identifier.SourceLocation.t option;
330330 doc : CComment.docs;
331331 type_ : TypeExpr.t;
332332 value : value;
···339339 | Arrow of TypeExpr.label option * TypeExpr.t * decl
340340341341 type t = {
342342- locs : Odoc_model.Lang.Locations.t option;
342342+ locs : Odoc_model.Paths.Identifier.SourceLocation.t option;
343343 doc : CComment.docs;
344344 virtual_ : bool;
345345 params : TypeDecl.param list;
···354354 | Signature of ClassSignature.t
355355356356 type t = {
357357- locs : Odoc_model.Lang.Locations.t option;
357357+ locs : Odoc_model.Paths.Identifier.SourceLocation.t option;
358358 doc : CComment.docs;
359359 virtual_ : bool;
360360 params : TypeDecl.param list;
+3-3
src/xref2/env.ml
···1818 open_units : string list;
1919 lookup_unit : string -> lookup_unit_result;
2020 lookup_page : string -> lookup_page_result;
2121- lookup_def : Identifier.t -> Lang.Locations.t option;
2121+ lookup_def : Identifier.NonSrc.t -> Identifier.SourceLocation.t option;
2222}
23232424let unique_id =
···361361 let id = (unit.id :> Paths.Identifier.Module.t) in
362362 let locs =
363363 match unit.source_info with
364364- | Some src -> Some { Lang.Locations.source_parent = src.id; anchor = None }
364364+ | Some src -> Some (Identifier.Mk.source_location_mod src.id)
365365 | None -> None
366366 in
367367 match unit.content with
···425425 result
426426427427let lookup_def id env =
428428- let id = (id :> Paths.Identifier.Any.t) in
428428+ let id = (id :> Paths.Identifier.NonSrc.t) in
429429 match env.resolver with Some r -> r.lookup_def id | None -> None
430430431431let lookup_page name env =
+2-3
src/xref2/env.mli
···1919 open_units : string list;
2020 lookup_unit : string -> lookup_unit_result;
2121 lookup_page : string -> lookup_page_result;
2222- lookup_def : Identifier.t -> Lang.Locations.t option;
2222+ lookup_def : Identifier.NonSrc.t -> Identifier.SourceLocation.t option;
2323 (** Lookup the source code location from an identifier. Returns
2424 [Some (source_parent, anchor)] when definition is found. *)
2525}
···98989999val lookup_root_module : string -> t -> root option
100100101101-val lookup_def :
102102- [< Identifier.t_pv ] Paths.Identifier.id -> t -> Lang.Locations.t option
101101+val lookup_def : Identifier.NonSrc.t -> t -> Identifier.SourceLocation.t option
103102(** Lookup the definition of the given identifier. Returns the root module and
104103 the anchor. *)
105104
+3-2
src/xref2/link.ml
···88end
991010let locations env id locs =
1111+ let id = (id :> Id.NonSrc.t) in
1112 match locs with Some _ as locs -> locs | None -> Env.lookup_def id env
12131314(** Equivalent to {!Comment.synopsis}. *)
···360361 let open Value in
361362 {
362363 t with
363363- locs = locations env (t.id :> Id.t) t.locs;
364364+ locs = locations env t.id t.locs;
364365 doc = comment_docs env parent t.doc;
365366 type_ = type_expression env parent [] t.type_;
366367 }
···541542 else type_
542543 | Alias _ | ModuleType _ -> type_
543544 in
544544- let locs = (locations env (m.id :> Id.t)) m.locs in
545545+ let locs = locations env m.id m.locs in
545546 let doc = comment_docs env sg_id m.doc in
546547 { m with locs; doc; type_ }
547548