123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960openOr_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_link_env_for_unitresolverminOdoc_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|Source_tree_contentst->Odoc_file.save_source_treeoutput~warnings:[]st;Ok(`Source_treest)|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)->(* Remove the shape here so that we only depend upon odoc types
rather than odoc and ocaml types. This means we don't break
being able save an odocl file with odoc x.y compiled with one
version of the compiler and load it in odoc x.y compiled with
a different version of the compiler, provided the compiler
itself doesn't break cross-version marshalling! This ability
is currently being used by voodoo. *)letm=letopenOdoc_model.Lang.Compilation_unitin{mwithshape_info=None}inOdoc_file.save_unitoutput~warningsm;Ok(`Modulem)