mirror of
https://github.com/CatalaLang/catala.git
synced 2024-09-19 00:15:39 +03:00
doc(compiler): add information about the html generation logic + complete the doc of the Utils module
This commit is contained in:
parent
70672088fa
commit
f30dc376fd
@ -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\
|
||||
|
@ -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
|
||||
|
@ -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
145989
french_law/js/french_law.js
generated
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user