@@ -8,9 +8,13 @@ let styles_file : string =
88 let (module Sites ) = EcRelocate. sites in
99 Filename. concat Sites. doc " styles.css"
1010
11- let stdlib_doc_root : string =
11+ let stdlib_doc_dp ( th : string ) : string =
1212 " "
1313
14+ (* -------------------------------------------------------------------- *)
15+ let from_stdlib (th : string ) : bool =
16+ false
17+
1418(* -------------------------------------------------------------------- *)
1519let c_filename ?(ext : string option ) (nms : string list ) =
1620 match ext with
@@ -34,26 +38,25 @@ let itemkind_str_pl (ik : itemkind) : string =
3438 | `Module -> " Modules"
3539 | `Theory -> " Theories"
3640
41+ (* -------------------------------------------------------------------- *)
3742
3843(* -------------------------------------------------------------------- *)
3944let md_pre_format ~kind (s : string ) =
4045 match kind with | _ -> pre [txt s]
4146
42- let md_href_format (env : EcEnv.env ) (hr : Markdown.href ) : Html_types.phrasing elt =
47+ let md_href_format (rth : string ) ( env : EcEnv.env ) (hr : Markdown.href ) : Html_types.phrasing elt =
4348 let il_format = Str. regexp " ^>\\ ([^|]+\\ )|\\ ([^|]+\\ )$" in
4449 if Str. string_match il_format hr.href_target 0 then
4550 let tkind = Str. matched_group 1 hr.href_target in
4651 let tname = Str. matched_group 2 hr.href_target in
4752 let tqs = EcSymbols. qsymbol_of_string tname in
48- Printf. eprintf " QSymbol: %s\t " (EcSymbols. string_of_qsymbol tqs);
4953 let env =
5054 match fst tqs with
51- | [] -> env
52- | [" Top" ] -> env
55+ | [] | [" Top" ] -> env
5356 | _ ->
54- let ttopqs = EcSymbols. qsymbol_of_top tqs in
55- let ttopp = EcEnv.Theory. lookup_path ~mode: `All ttopqs env in
56- EcEnv.Theory. env_of_theory ttopp env
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
5760 in
5861 let ikstr, path =
5962 match tkind with
@@ -73,23 +76,33 @@ let md_href_format (env : EcEnv.env) (hr : Markdown.href) : Html_types.phrasing
7376 | "Th" | "Theory" -> itemkind_str_pl `Theory , EcEnv.Theory. lookup_path ~mode: (`All ) tqs env
7477 | _ -> failwith " Invalid item/entity kind."
7578 in
76- Printf. eprintf " Root Path: %s\n " (EcPath. tostring (EcEnv. root env));
77- Printf. eprintf " QSymbol: %s\t Path: %s\n " (EcSymbols. string_of_qsymbol tqs) (EcPath. tostring path);
78- let nm = " DocGen" in
79- let il = nm ^ " .html" ^ " #" ^ ikstr ^ tname 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 il = fn ^ " #" ^ ikstr ^ snd tqs in
8093 a ~a: [a_href (uri_of_string il)] [txt hr.href_desc]
8194 else
8295 a ~a: [a_href (uri_of_string hr.href_target)] [txt hr.href_desc]
8396
8497let md_img_format (_ : Markdown.img_ref ) =
8598 failwith " Image embedding not supported."
8699
87- let c_markdown (input : string ) (env : EcEnv.env ) =
100+ let c_markdown (input : string ) (rth : string ) ( env : EcEnv.env ) =
88101 let input = Markdown. parse_text input in
89102
90103 MarkdownHTML. to_html
91104 ~render_pre: md_pre_format
92- ~render_link: (md_href_format env)
105+ ~render_link: (md_href_format rth env)
93106 ~render_img: md_img_format
94107 input
95108
@@ -125,19 +138,19 @@ let c_sidebar (th : string) (lents : EcScope.docentity list) =
125138 ]
126139
127140(* -------------------------------------------------------------------- *)
128- let c_section_intro (gdoc : string list ) (env : EcEnv.env ) =
141+ let c_section_intro (rth : string ) ( gdoc : string list ) (env : EcEnv.env ) =
129142 match gdoc with
130143 | [] -> []
131144 | _ -> [
132145 let ids = " Introduction" in
133146 section ~a: [a_id ids; a_title ids; a_class [" intro-section" ]] [
134147 div ~a: [a_class [" intro-text-container" ]]
135- (List. map (fun s -> div ~a: [a_class [" intro-par-container" ]] (c_markdown s env)) gdoc)
148+ (List. map (fun s -> div ~a: [a_class [" intro-par-container" ]] (c_markdown s rth env)) gdoc)
136149 ]
137150 ]
138151
139152(* -------------------------------------------------------------------- *)
140- let c_section_main_itemkind_li ?(supthf : string option ) (th : string ) (lent_ik : EcScope.docentity ) (env : EcEnv.env ) =
153+ let c_section_main_itemkind_li ?(supthf : string option ) (rth : string ) ( th : string ) (lent_ik : EcScope.docentity ) (env : EcEnv.env ) =
141154 match lent_ik with
142155 | SubDoc ((doc , (_ , ik , subth , _ )), _ ) ->
143156 begin
@@ -156,11 +169,11 @@ let c_section_main_itemkind_li ?(supthf : string option) (th : string) (lent_ik
156169 li ~a: [a_id (itemkind_str_pl ik ^ subth); a_class [" item-entry" ]] ([
157170 div ~a: [a_class [" item-name-desc-container" ]] [
158171 div ~a: [a_class [" item-name" ]] [a ~a: [a_href (Xml. uri_of_string hn)] [txt subth]];
159- div ~a: [a_class [" item-basic-desc" ]] (c_markdown hdoc env)
172+ div ~a: [a_class [" item-basic-desc" ]] (c_markdown hdoc rth env)
160173 ]
161174 ] @ (if tdoc <> []
162175 then [details ~a: [a_class [" item-details" ]] (summary [] )
163- (List. map (fun d -> div ~a: [a_class [" item-details-par" ]] (c_markdown d env)) tdoc)]
176+ (List. map (fun d -> div ~a: [a_class [" item-details-par" ]] (c_markdown d rth env)) tdoc)]
164177 else [] ))
165178 | _ -> assert false
166179 end
@@ -177,23 +190,23 @@ let c_section_main_itemkind_li ?(supthf : string option) (th : string) (lent_ik
177190 li ~a: [a_id (itemkind_str_pl ik ^ nm) ; a_class [" item-entry" ]] [
178191 div ~a: [a_class [" item-name-desc-container" ]] [
179192 div ~a: [a_class [" item-name" ]] [txt nm];
180- div ~a: [a_class [" item-basic-desc" ]] (c_markdown hdoc env)
193+ div ~a: [a_class [" item-basic-desc" ]] (c_markdown hdoc rth env)
181194 ];
182195 details ~a: [a_class [" item-details" ]] (summary [] )
183- (List. map (fun d -> div ~a: [a_class [" item-details-par" ]] (c_markdown d env)) tdoc
196+ (List. map (fun d -> div ~a: [a_class [" item-details-par" ]] (c_markdown d rth env)) tdoc
184197 @ [div ~a: [a_class [" source-container" ]]
185198 [txt " Source:" ; pre ~a: [a_class [" source" ]] [txt psrc]]])
186199 ]
187200
188201(* -------------------------------------------------------------------- *)
189- let c_section_main_itemkind ?(supthf : string option ) (th : string ) (lents_ik : EcScope.docentity list ) (env : EcEnv.env ) =
202+ let c_section_main_itemkind ?(supthf : string option ) (rth : string ) ( th : string ) (lents_ik : EcScope.docentity list ) (env : EcEnv.env ) =
190203 [
191204 ul ~a: [a_class [" item-list" ]]
192- (List. map (fun lent_ik -> c_section_main_itemkind_li ?supthf th lent_ik env) lents_ik)
205+ (List. map (fun lent_ik -> c_section_main_itemkind_li ?supthf rth th lent_ik env) lents_ik)
193206 ]
194207
195208(* -------------------------------------------------------------------- *)
196- let c_section_main ?(supthf : string option ) (th : string ) (lents : EcScope.docentity list ) (env : EcEnv.env ) =
209+ let c_section_main ?(supthf : string option ) (rth : string ) ( th : string ) (lents : EcScope.docentity list ) (env : EcEnv.env ) =
197210 let iks = [`Type ; `Operator ; `Axiom ; `Lemma ; `ModuleType ; `Module ; `Theory ] in
198211 List. concat
199212 (List. map (fun ik ->
@@ -208,13 +221,13 @@ let c_section_main ?(supthf : string option) (th : string) (lents : EcScope.doce
208221 let iks = itemkind_str_pl ik in
209222 section ~a: [a_id iks; a_title iks; a_class [" item-section" ]] [
210223 h2 ~a: [a_class [" section-heading" ]] [txt iks];
211- div ~a: [a_class [" item-list-container" ]] (c_section_main_itemkind ?supthf th lents_ik env)
224+ div ~a: [a_class [" item-list-container" ]] (c_section_main_itemkind ?supthf rth th lents_ik env)
212225 ]
213226 ]
214227 )
215228 iks)
216229
217- let c_body ?(supths : string option ) ?(supthf : string option ) (th : string ) (tstr : string ) (gdoc : string list ) (ldocents : EcScope.docentity list ) (env : EcEnv.env ) : [> Html_types.body] elt =
230+ let c_body ?(supths : string option ) ?(supthf : string option ) (rth : string ) ( th : string ) (tstr : string ) (gdoc : string list ) (ldocents : EcScope.docentity list ) (env : EcEnv.env ) : [> Html_types.body] elt =
218231 let sidebar = c_sidebar th ldocents in
219232 let page_heading =
220233 div ~a: [a_class [" page-heading-container" ]]
@@ -233,13 +246,13 @@ let c_body ?(supths : string option) ?(supthf : string option) (th : string) (ts
233246 ]
234247 ])
235248 in
236- let sec_intro = c_section_intro gdoc env in
237- let sec_main = c_section_main ?supthf th ldocents env in
249+ let sec_intro = c_section_intro rth gdoc env in
250+ let sec_main = c_section_main ?supthf rth th ldocents env in
238251 body (sidebar :: [main (page_heading :: sec_intro @ sec_main)])
239252
240253(* -------------------------------------------------------------------- *)
241- let c_page ?(supths : string option ) ?(supthf : string option ) (th : string ) (tstr : string ) (gdoc : string list ) (ldocents : EcScope.docentity list ) (env : EcEnv.env ) : [> Html_types.html] elt =
242- html (c_head tstr) (c_body ?supths ?supthf th tstr gdoc ldocents env)
254+ let c_page ?(supths : string option ) ?(supthf : string option ) (rth : string ) ( th : string ) (tstr : string ) (gdoc : string list ) (ldocents : EcScope.docentity list ) (env : EcEnv.env ) : [> Html_types.html] elt =
255+ html (c_head tstr) (c_body ?supths ?supthf rth th tstr gdoc ldocents env)
243256
244257(* -------------------------------------------------------------------- *)
245258let emit_page (dp : string ) (fn : string ) (page : [> Html_types.html ] elt ) =
@@ -266,13 +279,13 @@ let emit_pages (dp : string) (th : string) (tstr : string) (gdoc : string list)
266279 | Some supf -> c_filename [supf; th]
267280 in
268281 let stf = c_filename [stsupf; sth] in
269- (stf, c_page ~supths: th ~supthf: stsupf sth ststr sgdoc sldocents env)
282+ (stf, c_page ~supths: th ~supthf: stsupf th sth ststr sgdoc sldocents env)
270283 :: c_subpages ~supths: th ~supthf: stsupf sth sldocents
271284 @ c_subpages ?supths ?supthf th docents'
272285 in
273286 let spgs = c_subpages th ldocents in
274287 List. iter (fun fnpg -> emit_page dp (fst fnpg) (snd fnpg)) spgs;
275- emit_page dp th (c_page th tstr gdoc ldocents env)
288+ emit_page dp th (c_page th th tstr gdoc ldocents env)
276289
277290(* -------------------------------------------------------------------- *)
278291(* input = input name, scope contains all documentation items *)
0 commit comments