Skip to content

Commit e146a6d

Browse files
committed
Fix styling with markdown generation and add additional logic for getting right theory path/environment.
1 parent 9bfb08b commit e146a6d

4 files changed

Lines changed: 34 additions & 23 deletions

File tree

resources/styles/styles.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ main {
133133
margin-left: 10px;
134134
}
135135

136+
.item-basic-desc p {
137+
margin-top: 0px;
138+
}
139+
136140
.item-details {
137141
margin-left: 210px;
138142
}

src/ecDoc.ml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,25 @@ let itemkind_str_pl (ik : itemkind) : string =
3636

3737

3838
(* -------------------------------------------------------------------- *)
39-
let md_pre_format ~(kind : string) (s : string) =
40-
pre [txt s]
39+
let md_pre_format ~kind (s : string) =
40+
match kind with | _ -> pre [txt s]
4141

4242
let md_href_format (env : EcEnv.env) (hr : Markdown.href) : Html_types.phrasing elt =
4343
let il_format = Str.regexp "^>\\([^|]+\\)|\\([^|]+\\)$" in
4444
if Str.string_match il_format hr.href_target 0 then
4545
let tkind = Str.matched_group 1 hr.href_target in
4646
let tname = Str.matched_group 2 hr.href_target in
47-
(*
48-
let tscope : string option = assert false in
49-
let env =
50-
match tscope with
51-
| None -> env
52-
| Some tscope ->
53-
let tscope = EcSymbols.qsymbol_of_string tscope in
54-
let tscope = EcEnv.Theory.lookup_path ~mode:`All tscope in
55-
EcEnv.Theory.env_of_theory tscope env (* Merge with main to have this *)
56-
in
57-
*)
5847
let tqs = EcSymbols.qsymbol_of_string tname in
48+
Printf.eprintf "QSymbol: %s\t" (EcSymbols.string_of_qsymbol tqs);
49+
let env =
50+
match fst tqs with
51+
| [] -> env
52+
| ["Top"] -> env
53+
| _ ->
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+
in
5958
let ikstr, path =
6059
match tkind with
6160
| "Ty" | "Type" -> itemkind_str_pl `Type, EcEnv.Ty.lookup_path tqs env
@@ -68,11 +67,11 @@ let md_href_format (env : EcEnv.env) (hr : Markdown.href) : Html_types.phrasing
6867
begin
6968
match (EcEnv.Mod.lookup_path tqs env).m_top with
7069
| `Concrete (p, None) -> p
71-
| `Concrete (_, Some _) -> raise (failwith "Linking to sub-modules not supported.")
72-
| `Local _ -> raise (failwith "Linking to local/declared modules not supported.")
70+
| `Concrete (_, Some _) -> failwith "Linking to sub-modules not supported."
71+
| `Local _ -> failwith "Linking to local/declared modules not supported."
7372
end
7473
| "Th" | "Theory" -> itemkind_str_pl `Theory, EcEnv.Theory.lookup_path ~mode:(`All) tqs env
75-
| _ -> raise (failwith "Invalid item/entity kind.")
74+
| _ -> failwith "Invalid item/entity kind."
7675
in
7776
Printf.eprintf "Root Path: %s\n" (EcPath.tostring (EcEnv.root env));
7877
Printf.eprintf "QSymbol: %s\t Path: %s\n" (EcSymbols.string_of_qsymbol tqs) (EcPath.tostring path);
@@ -82,8 +81,8 @@ let md_href_format (env : EcEnv.env) (hr : Markdown.href) : Html_types.phrasing
8281
else
8382
a ~a:[a_href (uri_of_string hr.href_target)] [txt hr.href_desc]
8483

85-
let md_img_format (ir : Markdown.img_ref) =
86-
raise (failwith "Image embedding not supported.")
84+
let md_img_format (_ : Markdown.img_ref) =
85+
failwith "Image embedding not supported."
8786

8887
let c_markdown (input : string) (env : EcEnv.env) =
8988
let input = Markdown.parse_text input in
@@ -133,7 +132,7 @@ let c_section_intro (gdoc : string list) (env : EcEnv.env) =
133132
let ids = "Introduction" in
134133
section ~a:[a_id ids; a_title ids; a_class ["intro-section"]] [
135134
div ~a:[a_class ["intro-text-container"]]
136-
(List.map (fun s -> div ~a:[a_class ["item-details-par"]] (c_markdown s env)) gdoc)
135+
(List.map (fun s -> div ~a:[a_class ["intro-par-container"]] (c_markdown s env)) gdoc)
137136
]
138137
]
139138

@@ -201,7 +200,7 @@ let c_section_main ?(supthf : string option) (th : string) (lents : EcScope.doce
201200
let lents_ik = List.filter (fun ent ->
202201
match ent with
203202
| ItemDoc (_, (md, ikp, _, _)) -> md = `Specific && ikp = ik
204-
| SubDoc ((_, (md, ikp, _, _)), _) -> ikp = ik) lents
203+
| SubDoc ((_, (_, ikp, _, _)), _) -> ikp = ik) lents
205204
in
206205
match lents_ik with
207206
| [] -> []
@@ -259,7 +258,7 @@ let emit_pages (dp : string) (th : string) (tstr : string) (gdoc : string list)
259258
| de :: docents' ->
260259
match de with
261260
| ItemDoc _ -> c_subpages ?supths ?supthf th docents'
262-
| SubDoc ((sgdoc, (smd, sik, sth, _)), sldocents) ->
261+
| SubDoc ((sgdoc, (smd, _, sth, _)), sldocents) ->
263262
let ststr = (if smd = `Abstract then "Abstract " else "") ^ "Theory " ^ sth in
264263
let stsupf =
265264
match supthf with

src/ecSymbols.ml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,11 @@ let qsymbol_of_string (s : string) : qsymbol =
9494
match List.rev sspl with
9595
| [] -> assert false
9696
| [x] -> ([], x)
97-
| x :: xs -> (List.rev xs, x)
97+
| x :: xs -> (List.rev xs, x)
98+
99+
100+
let qsymbol_of_top (q : qsymbol) : qsymbol =
101+
match List.rev (fst q) with
102+
| [] -> assert false
103+
| [x] -> ([], x)
104+
| x :: xs -> (List.rev xs, x)

src/ecSymbols.mli

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ val pp_msymbol : Format.formatter -> msymbol -> unit
3333

3434
val string_of_qsymbol : qsymbol -> string
3535

36-
val qsymbol_of_string : string -> qsymbol
36+
val qsymbol_of_string : string -> qsymbol
37+
val qsymbol_of_top : qsymbol -> qsymbol

0 commit comments

Comments
 (0)