Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file generator.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468openOdoc_document.TypesopenTypesmoduleDoctree=Odoc_document.Doctreeletreclist_concat_map?sep~f=function|[]->[]|[x]->fx|x::xs->(lethd=fxinlettl=list_concat_map?sep~fxsinmatchsepwithNone->hd@tl|Somesep->hd@(sep::tl))moduleLink=structletrecflatten_pathppf(x:Odoc_document.Url.Path.t)=matchx.parentwith|Somep->Fmt.pfppf"%a-%a-%s"flatten_pathpOdoc_document.Url.Path.pp_kindx.kindx.name|None->Fmt.pfppf"%a-%s"Odoc_document.Url.Path.pp_kindx.kindx.nameletpagep=Format.asprintf"%a"flatten_pathpletlabel(x:Odoc_document.Url.t)=matchx.anchorwith|""->pagex.page|anchor->Format.asprintf"%a-%s"flatten_pathx.pageanchorletrecis_class_or_module_path(url:Odoc_document.Url.Path.t)=matchurl.kindwith|`Module|`LeafPage|`Class|`Page->(matchurl.parentwith|None->true|Someurl->is_class_or_module_pathurl)|_->falseletshould_inlinestatusurl=matchstatuswith|`Inline|`Open->true|`Closed->false|`Default->not@@is_class_or_module_pathurlletget_dir_and_fileurl=letopenOdoc_documentinletl=Url.Path.to_listurlinletis_dir=function`Page->`IfNotLast|_->`Neverinletdir,file=Url.Path.split~is_dirlinletsegment_to_string(_kind,name)=namein(List.mapsegment_to_stringdir,String.concat"."(List.mapsegment_to_stringfile))letfilenameurl=letdir,file=get_dir_and_fileurlinletfile=Fpath.(v(String.concatdir_sep(dir@[file])))inFpath.(add_ext"tex"file)endletstyle=function|`Emphasis|`Italic->Raw.emph|`Bold->Raw.bold|`Subscript->Raw.subscript|`Superscript->Raw.superscriptletgen_hyperrefpprppf=match(r.target,r.text)with|"",None->()|"",Somecontent->Raw.inline_codeppppfcontent|s,None->Raw.refppfs|s,Somecontent->letpp=ifr.shortthenRaw.inline_codeppelsefunppfx->Fmt.pfppf"%a[p%a]"(Raw.inline_codepp)xRaw.pageref_starsinRaw.hyperrefsppppfcontentletlabel=function|None->[]|Somex(* {Odoc_document.Url.Anchor.anchor ; page; _ }*)->[Label(Link.labelx)]letlevel_macro=function|0->Raw.section|1->Raw.subsection|2->Raw.subsubsection|3|_->Raw.subsubsectionletnone_ppf()=()letlistkindppppfx=letlist=matchkindwithBlock.Ordered->Raw.enumerate|Unordered->Raw.itemizeinleteltppf=Raw.itemppppfinmatchxwith|[]->(* empty list are not supported *)()|_->list(Fmt.list~sep:(funppf()->Raw.breakppfAesthetic)elt)ppfxletescape_entity=function"#45"->"-"|"gt"->">"|s->sletfilter_mapfx=List.rev@@List.fold_left(funaccx->matchfxwithSomex->x::acc|None->acc)[]xletelt_size(x:elt)=matchxwith|Txt_|Internal_ref_|External_ref_|Label_|Style_|Inlined_code_|Code_fragment_|Tag_|Break_|Ligaturable_->Small|List_|Section_|Verbatim_|Raw_|Code_block_|Indented_|Description_->Large|Table_->Hugelettable=function|[]->[]|a::_asm->letstart=List.map(fun_->Empty)ainletcontent_sizel=List.fold_left(funsx->maxs(elt_sizex))Emptylinletrowmaskl=List.map2(funxy->maxx@@content_sizey)masklinletmask=List.fold_leftrowstartminletfilter_empty=function|Empty,_->None|(Small|Large|Huge),x->Somexinletfilter_rowrow=filter_mapfilter_empty@@List.combinemaskrowinletrow_size=List.fold_leftmaxEmptymaskin[Table{row_size;tbl=List.mapfilter_rowm}]lettxt~verbatim~in_sourcews=ifverbatimthen[Txtws]elseletescaped=List.map(Raw.Escape.text~code_hyphenation:in_source)wsinmatchList.filter((<>)"")escapedwith[]->[]|l->[Txtl]letentity~in_source~verbatimx=ifin_source&¬verbatimthenLigaturable(escape_entityx)elseTxt[escape_entityx](** Tables with too many rows are hard to typeset correctly on
the same page.
Splitting tables on multiple pages is unreliable with longtable + hyperref.
Thus we limit the height of the tables that we render as latex tables.
This variable is kept separated because we may want to make it tunable
by the user.
*)letsmall_table_height_limit=10letrecpp_eltppf=function|Txtwords->Fmt.listFmt.string~sep:noneppfwords|Section{level;label;content}->letwith_labelppf(label,content)=ppppfcontent;matchlabelwithNone->()|Somelabel->Raw.labelppflabelinlevel_macrolevelwith_labelppf(label,content)|Breaklvl->Raw.breakppflvl|Raws->Fmt.stringppfs|Verbatims->Raw.verbatimppfs|Internal_refr->hyperrefppfr|External_ref(l,x)->hrefppf(l,x)|Style(s,x)->stylesppppfx|Code_block[]->()|Code_blockx->Raw.code_blockppppfx|Inlined_codex->Raw.inline_codeppppfx|Code_fragmentx->Raw.code_fragmentppppfx|List{typ;items}->listtypppppfitems|Descriptionitems->Raw.descriptionppppfitems|Table{row_size=Large|Huge;tbl}->large_tableppftbl|Table{row_size=Small|Empty;tbl}->ifList.lengthtbl<=small_table_height_limitthenRaw.small_tableppppftblelselarge_tableppftbl|Labelx->Raw.labelppfx|Indentedx->Raw.indentppppfx|Ligaturables->Fmt.stringppfs|Tag(s,t)->tagsppftandppppf=function|[]->()|Break_::(Table_::_asq)->ppppfq|(Table_ast)::Break_::q->ppppf(t::q)|Breaka::Breakb::q->ppppf(Break(maxab)::q)|Ligaturable"-"::Ligaturable">"::q->Raw.rightarrowppf;ppppfq|a::q->pp_eltppfa;ppppfqandhyperrefppfr=gen_hyperrefpprppfandhrefppf(l,txt)=matchtxtwith|Sometxt->Raw.hreflppppftxt;Raw.footnoteppfl|None->Raw.urlppflandlarge_tableppftbl=letrecrowppf=function|[]->Raw.breakppfLine|[a]->ppppfa;Raw.breakppfLine|[a;b]->Fmt.pfppf"%a%a%a"ppaRaw.breakAesthetic(Raw.indentpp)b|a::(_::_asq)->Fmt.pfppf"%a%a%a"ppaRaw.breakAesthetic(Raw.indentrow)qinletmatrixppfm=List.iter(rowppf)minRaw.indentmatrixppftblandtagsppfx=Raw.ocamltagsppppfxletraw_markup(t:Raw_markup.t)=lettarget,content=tinmatchAstring.String.Ascii.lowercasetargetwith|"latex"|"tex"->[Rawcontent]|_->[]letsourcek(t:Source.t)=letrectoken(x:Source.token)=matchxwith|Elti->ki|Tag(None,l)->tokensl|Tag(Somes,l)->[Tag(s,tokensl)]andtokenst=list_concat_mapt~f:tokenintokenstletrecinternalref~verbatim~in_source(t:InternalLink.t)=matchtwith|Resolved(uri,content)->lettarget=Link.labeluriinlettext=Some(inline~verbatim~in_sourcecontent)inletshort=in_sourceinInternal_ref{short;text;target}|Unresolvedcontent->lettarget="xref-unresolved"inlettext=Some(inline~verbatim~in_sourcecontent)inletshort=in_sourceinInternal_ref{short;target;text}andinline~in_source~verbatim(l:Inline.t)=letone(t:Inline.one)=matcht.descwith|Text_s->assertfalse|Linebreak->[BreakLine]|Styled(style,c)->[Style(style,inline~verbatim~in_sourcec)]|Link(ext,c)->letcontent=inline~verbatim:false~in_source:falsecin[External_ref(ext,Somecontent)]|InternalLinkc->[internalref~in_source~verbatimc]|Sourcec->[Inlined_code(source(inline~verbatim:false~in_source:true)c)]|Raw_markupr->raw_markupr|Entitys->[entity~in_source~verbatims]inlettake_text(l:Inline.t)=Doctree.Take.untill~classify:(function|{Inline.desc=Textcode;_}->Accum[code]|{desc=Entitye;_}->Accum[escape_entitye]|_->Stop_and_keep)in(* if in_source then block_code_txt s else if_not_empty (fun x -> Txt x) s *)letrecprettify=function|{Inline.desc=Inline.Text_;_}::_asl->letwords,_,rest=take_textlintxt~in_source~verbatimwords@prettifyrest|o::q->oneo@prettifyq|[]->[]inprettifylletheading(h:Heading.t)=letcontent=inline~in_source:false~verbatim:falseh.titlein[Section{label=h.label;level=h.level;content};BreakAesthetic]letnon_empty_block_codec=lets=source(inline~verbatim:true~in_source:true)cinmatchswith|[]->[]|_::_asl->[BreakSeparation;Code_blockl;BreakSeparation]letnon_empty_code_fragmentc=lets=source(inline~verbatim:false~in_source:true)cinmatchswith[]->[]|_::_asl->[Code_fragmentl]letrecblock~in_source(l:Block.t)=letone(t:Block.one)=matcht.descwith|Inlinei->inline~verbatim:false~in_source:falsei|Paragraphi->inline~in_source:false~verbatim:falsei@ifin_sourcethen[]else[BreakParagraph]|List(typ,l)->[List{typ;items=List.map(block~in_source:false)l}]|Descriptionl->[(letitemi=(inline~in_source~verbatim:falsei.Description.key,block~in_sourcei.Description.definition)inDescription(List.mapiteml));]|Raw_markupr->raw_markupr|Verbatims->[Verbatims]|Sourcec->non_empty_block_codecinlist_concat_mapl~f:oneletrecis_only_textl=letis_text:Item.t->_=function|Heading_|Text_->true|Declaration_->false|Include{content=items;_}->is_only_textitems.contentinList.for_allis_textlletrecdocumentedSrc(t:DocumentedSrc.t)=letopenDocumentedSrcinletrecto_latext=matchtwith|[]->[]|Code_::_->lettake_codel=Doctree.Take.untill~classify:(function|Codecode->Accumcode|_->Stop_and_keep)inletcode,_,rest=take_codetinnon_empty_code_fragmentcode@to_latexrest|Alternative(Expansione)::rest->(ifLink.should_inlinee.statuse.urlthento_latexe.expansionelsenon_empty_code_fragmente.summary)@to_latexrest|Subpagesubp::rest->Indented(itemssubp.content.items)::to_latexrest|(Documented_|Nested_)::_->lettake_descrl=Doctree.Take.untill~classify:(function|Documented{attrs;anchor;code;doc;markers}->Accum[{DocumentedSrc.attrs;anchor;code=`Dcode;doc;markers;};]|Nested{attrs;anchor;code;doc;markers}->Accum[{DocumentedSrc.attrs;anchor;code=`Ncode;doc;markers;};]|_->Stop_and_keep)inletl,_,rest=take_descrtinletonedsrc=letcontent=matchdsrc.codewith|`Dcode->inline~verbatim:false~in_source:truecode|`Nn->to_latexninletdoc=[block~in_source:truedsrc.doc]in(content@labeldsrc.anchor)::docintable(List.maponel)@to_latexrestinto_latextanditemsl=letrecwalk_items~only_textacc(t:Item.tlist)=letcontinue_withrestelts=walk_items~only_text(List.rev_appendeltsacc)restinmatchtwith|[]->List.revacc|Text_::_ast->lettext,_,rest=Doctree.Take.untilt~classify:(function|Item.Texttext->Accumtext|_->Stop_and_keep)inletcontent=block~in_source:falsetextinletelts=contentinelts|>continue_withrest|Headingh::rest->headingh|>continue_withrest|Include{attr=_;anchor;doc;content={summary;status=_;content}}::rest->letincluded=itemscontentinletdocs=block~in_source:truedocinletsummary=source(inline~verbatim:false~in_source:true)summaryinletcontent=includedinlabelanchor@docs@summary@content|>continue_withrest|Declaration{Item.attr=_;anchor;content;doc}::rest->letcontent=labelanchor@documentedSrccontentinletelts=matchdocwith|[]->content@[BreakLine]|docs->content@[Indented(block~in_source:truedocs);BreakSeparation]incontinue_withresteltsanditemsl=walk_items~only_text:(is_only_textl)[]linitemslmoduleDoc=structletlink_childrenppfchildren=letinput_childppfchild=Raw.inputppfchild.Odoc_document.Renderer.filenameinFmt.listinput_childppfchildrenletmake~with_childrenurlcontentchildren=letfilename=Link.filenameurlinletlabel=Label(Link.pageurl)inletcontent=matchcontentwith|[]->[label]|(Section_ass)::q->s::label::q|q->label::qinletchildren_inputppf=ifwith_childrenthenlink_childrenppfchildrenelse()inletcontentppf=Fmt.pfppf"@[<v>%a@,%t@]@."ppcontentchildren_inputin{Odoc_document.Renderer.filename;content;children}endmodulePage=structleton_sub=function`Page_->Some1|`Include_->Noneletrecsubpage~with_children(p:Subpage.t)=ifLink.should_inlinep.statusp.content.urlthen[]else[page~with_childrenp.content]andsubpages~with_childrensubpages=List.flatten@@List.map(subpage~with_children)subpagesandpage~with_childrenp=let{Page.title=_;header;items=i;url}=Doctree.Labels.disambiguate_pagepandsubpages=subpages~with_children@@Doctree.Subpages.computepinleti=Doctree.Shift.compute~on_subiinletheader=itemsheaderinletcontent=itemsiinletpage=Doc.make~with_childrenurl(header@content)subpagesinpageendletrender~with_childrenpage=Page.page~with_childrenpageletfiles_of_urlurl=ifLink.is_class_or_module_pathurlthen[Link.filenameurl]else[]