123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128(*
* Copyright (c) 2016 Thomas Refis <trefis@janestreet.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)openStdLabelsopenOdoc_model.Pathsletfunctor_arg_pos{Odoc_model.Lang.FunctorParameter.id;_}=matchidwith|`Argument(_,nb,_)->nb|_->failwith"TODO"(* let id = string_of_sexp @@ Identifier.sexp_of_t id in
invalid_arg (Printf.sprintf "functor_arg_pos: %s" id) *)letrecunit~package(t:Odoc_model.Lang.Compilation_unit.t):stringlist=letname=Printf.sprintf"%s/%s"package(Identifier.namet.id)inletrest=matcht.contentwith|Modulesign->signature~prefix:namesign|Pack_->[]inname::restandsignature~prefix(t:Odoc_model.Lang.Signature.t)=letrecadd_items~don'tacc=function|[]->List.concat(List.revacc)|i::is->matchiwith|Odoc_model.Lang.Signature.Comment`Stop->add_items~don't:(notdon't)accis|_whendon't->add_items~don'taccis|Module(_,md)->add_items~don't(module_~prefixmd::acc)is|ModuleTypemty->add_items~don't(module_type~prefixmty::acc)is|Includeincl->add_items~don't(include_~prefixincl::acc)is|ModuleSubstitution_|TypeSubstitution_|Type_|TypExt_|Exception_|Value_|External_|Class_|ClassType_|Comment(`Docs_)->add_items~don'taccisinadd_items~don't:false[]tandfunctor_argument~prefixarg=letopenOdoc_model.Lang.FunctorParameterinmatcharg.expansionwith|None->[]|Someexpansion->letname=Identifier.namearg.idinletnb=functor_arg_posargin(* FIXME: reuse [Url] somehow. *)letpage=Printf.sprintf"%s/argument-%d-%s"prefixnbnameinletsubpages=module_expansion~prefix:pageexpansioninpage::subpagesandmodule_expansion~prefix(t:Odoc_model.Lang.Module.expansion)=matchtwith|AlreadyASig->[](* FIXME. *)|Signaturesg->signature~prefixsg|Functor(args,sg)->letsubpages=signature~prefixsginList.fold_leftargs~init:subpages~f:(funsubpagesarg->matchargwith|Odoc_model.Lang.FunctorParameter.Unit->subpages|Namedarg->letarg_subpages=functor_argument~prefixarginarg_subpages@subpages)andmodule_~prefix(t:Odoc_model.Lang.Module.t)=matcht.expansionwith|None->[]|Someexpansion->letexpansion=matchexpansionwith|AlreadyASig->beginmatcht.type_with|ModuleType(Odoc_model.Lang.ModuleType.Signaturesg)->Odoc_model.Lang.Module.Signaturesg|_->assertfalseend|e->einletpage=Printf.sprintf"%s/%s"prefix(Identifier.namet.id)inletsubpages=module_expansion~prefix:pageexpansioninpage::subpagesandmodule_type~prefix(t:Odoc_model.Lang.ModuleType.t)=matcht.expansionwith|None->[]|Someexpansion->letexpansion=matchexpansionwith|AlreadyASig->beginmatcht.exprwith|Some(Signaturesg)->Odoc_model.Lang.Module.Signaturesg|_->assertfalseend|e->ein(* FIXME: reuse [Url] somehow. *)letpage=Printf.sprintf"%s/module-type-%s"prefix(Identifier.namet.id)inletsubpages=module_expansion~prefix:pageexpansioninpage::subpagesandinclude_~prefix(t:Odoc_model.Lang.Include.t)=signature~prefixt.expansion.content