12345678910111213141516171819202122232425262728293031323334353637383940414243444546openOr_errorletlink_page~resolver~filenamepage=letenv=Resolver.build_env_for_pageresolverpageinOdoc_xref2.Link.resolve_page~filenameenvpageletlink_unit~resolver~filenamem=letopenOdoc_modelinletopenLang.Compilation_unitinletm=ifRoot.Odoc_file.hiddenm.root.filethen{mwithcontent=Module{items=[];compiled=false;doc=[]};expansion=None;}elseminletenv=Resolver.build_env_for_unitresolver~linking:trueminOdoc_xref2.Link.link~filenameenvm(** [~input_warnings] are the warnings stored in the input file *)lethandle_warnings~input_warnings~warnings_optionsww=let_,warnings=Odoc_model.Error.unpack_warningswwinOdoc_model.Error.handle_warnings~warnings_optionsww>>=funres->Ok(res,input_warnings@warnings)(** Read the input file and write to the output file.
Also return the resulting tree. *)letfrom_odoc~resolver~warnings_optionsinputoutput=letfilename=Fs.File.to_stringinputinOdoc_file.loadinput>>=fununit->letinput_warnings=unit.Odoc_file.warningsinmatchunit.contentwith|Page_contentpage->link_page~resolver~filenamepage|>handle_warnings~input_warnings~warnings_options>>=fun(page,warnings)->Odoc_file.save_pageoutput~warningspage;Ok(`Pagepage)|Unit_contentm->link_unit~resolver~filenamem|>handle_warnings~input_warnings~warnings_options>>=fun(m,warnings)->Odoc_file.save_unitoutput~warningsm;Ok(`Modulem)