@@ -20,7 +20,7 @@ let c_filename ?(ext : string option) (nms : string list) =
2020 match ext with
2121 | None -> String. concat " !" nms
2222 | Some ext -> String. concat " !" nms ^ ext
23-
23+
2424(* -------------------------------------------------------------------- *)
2525let thkind_str (kind : EcLoader.kind ) : string =
2626 match kind with
@@ -39,7 +39,27 @@ let itemkind_str_pl (ik : itemkind) : string =
3939 | `Theory -> " Theories"
4040
4141(* -------------------------------------------------------------------- *)
42+ let rec bot_env_of_qsymbol (q : EcSymbols.qsymbol ) (env : EcEnv.env )=
43+ match fst q with
44+ | [] | [" Top" ] -> env
45+ | x :: xs ->
46+ let p = EcEnv.Theory. lookup_path ~mode: `All ([] , x) env in
47+ let env = EcEnv.Theory. env_of_theory p env in
48+ bot_env_of_qsymbol (xs, snd q) env
4249
50+ let filename_of_path ?(ext : string option ) (rth : string ) (p : EcPath.path ) =
51+ let qs = EcPath. toqsymbol p in
52+ match fst qs with
53+ | [] -> assert false
54+ | [" Top" ] -> c_filename ?ext [rth]
55+ | "Top" :: ts ->
56+ let reqrt = (List. hd ts) in
57+ if from_stdlib reqrt then
58+ Filename. concat (stdlib_doc_dp reqrt) (c_filename ?ext ts)
59+ else
60+ (c_filename ?ext (rth :: ts))
61+ | _ -> assert false
62+
4363(* -------------------------------------------------------------------- *)
4464let md_pre_format ~kind (s : string ) =
4565 match kind with | _ -> pre [txt s]
@@ -50,14 +70,7 @@ let md_href_format (rth : string) (env : EcEnv.env) (hr : Markdown.href) : Html_
5070 let tkind = Str. matched_group 1 hr.href_target in
5171 let tname = Str. matched_group 2 hr.href_target in
5272 let tqs = EcSymbols. qsymbol_of_string tname in
53- let env =
54- match fst tqs with
55- | [] | [" Top" ] -> env
56- | _ ->
57- let tsupqs = EcSymbols. qsymbol_of_sup tqs in
58- let tsupp = EcEnv.Theory. lookup_path ~mode: `All tsupqs env in
59- EcEnv.Theory. env_of_theory tsupp env
60- in
73+ let env = bot_env_of_qsymbol tqs env in
6174 let ikstr, path =
6275 match tkind with
6376 | "Ty" | "Type" -> itemkind_str_pl `Type , EcEnv.Ty. lookup_path tqs env
@@ -73,22 +86,10 @@ let md_href_format (rth : string) (env : EcEnv.env) (hr : Markdown.href) : Html_
7386 | `Concrete (_ , Some _ ) -> failwith " Linking to sub-modules not supported."
7487 | `Local _ -> failwith " Linking to local/declared modules not supported."
7588 end
76- | "Th" | "Theory" -> itemkind_str_pl `Theory , EcEnv.Theory. lookup_path ~mode: ( `All ) tqs env
89+ | "Th" | "Theory" -> itemkind_str_pl `Theory , EcEnv.Theory. lookup_path ~mode: `All tqs env
7790 | _ -> failwith " Invalid item/entity kind."
7891 in
79- let tqs = EcPath. toqsymbol path in
80- let fn =
81- match fst tqs with
82- | [] -> assert false
83- | [" Top" ] -> c_filename ~ext: " .html" [rth]
84- | "Top" :: ts ->
85- let reqrt = (List. hd ts) in
86- if from_stdlib reqrt then
87- Filename. concat (stdlib_doc_dp reqrt) (c_filename ~ext: " .html" ts)
88- else
89- (c_filename ~ext: " .html" (rth :: ts))
90- | _ -> assert false
91- in
92+ let fn = filename_of_path ~ext: " .html" rth path in
9293 let il = fn ^ " #" ^ ikstr ^ snd tqs in
9394 a ~a: [a_href (uri_of_string il)] [txt hr.href_desc]
9495 else
0 commit comments