doc(compiler): add information about the html generation logic + complete the doc of the Utils module

This commit is contained in:
Emile Rolley 2022-08-05 18:33:32 +02:00
parent 70672088fa
commit f30dc376fd
4 changed files with 9641 additions and 136367 deletions

View File

@ -75,7 +75,6 @@ let wrap_html
Format.fprintf fmt
"<head>\n\
<style>\n\
summary { cursor: pointer; font-style: italic; }\n\
%s\n\
</style>\n\
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>\n\
@ -185,15 +184,22 @@ let rec law_structure_to_html
| A.CodeBlock _ -> ()
| A.LawHeading (heading, children) ->
let h_number = heading.law_heading_precedence + 1 in
let is_a_section_to_collapse =
(* Only 2 depth sections are collasped in a <details> tag. Indeed, this
allow to significantly reduce rendering time (~= 100x for the
[aides_logement] example in the catala-website), while remaining
practicable. *)
h_number = 2
in
let h_name = Marked.unmark heading.law_heading_name in
let complete_headings = parents_headings @ [h_name] in
let id = complete_headings |> String.concat "-" |> sanitize_html_href in
let fmt_details_open fmt () =
if 2 = h_number then
if is_a_section_to_collapse then
Format.fprintf fmt "<details><summary>%s</summary>" h_name
in
let fmt_details_close fmt () =
if 2 = h_number then Format.fprintf fmt "</details>"
if is_a_section_to_collapse then Format.fprintf fmt "</details>"
in
Format.fprintf fmt
"<h%d class='law-heading' id=\"%s\"><a href=\"#%s\">%s</a>%s</h%d>@\n\

View File

@ -14,8 +14,7 @@
License for the specific language governing permissions and limitations under
the License. *)
(** Helper functions manipulating strings common to all Catala compiler
internals. *)
(** Helper functions used for string manipulation. *)
val to_ascii : string -> string
(** Removes all non-ASCII diacritics from a string by converting them to their

View File

@ -37,8 +37,8 @@ Related modules:
{!modules: Utils.Errors}
{1 File utilities}
{1 Other utilies}
Related modules:
{!modules: Utils.File}
{!modules: Utils.File Utils.String_common}

145989
french_law/js/french_law.js generated

File diff suppressed because one or more lines are too long