Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file url.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294openResultopenStdLabelsopenOdoc_model.PathsopenOdoc_model.Namestypet={page:stringlist;(* in reverse order! *)anchor:string;kind:string;}letto_string{page;anchor;_}=String.concat~sep:"/"(List.revpage)^"#"^anchormoduleError=structtypenonrect=|Not_linkableofstring|Uncaught_exnofstring(* These should basicaly never happen *)|Unexpected_anchoroft*string|Missing_anchoroft*stringletto_string=function|Not_linkables->Printf.sprintf"Not_linkable %S"s|Uncaught_exns->Printf.sprintf"Uncaught_exn %S"s|Unexpected_anchor(t,s)->Printf.sprintf"Unexpected_anchor %S (parent of %s)"(to_stringt)s|Missing_anchor(t,s)->Printf.sprintf"Missing_anchor on %S for %S"(to_stringt)send(* let (^/) x y = x ^ "/" ^ y *)let(>>|)xf=matchxwith|Okx->Ok(fx)|Error_ase->elet(>>=)xf=matchxwith|Okx->fx|Error_ase->eletrecfrom_identifier:stop_before:bool->Identifier.t->(t,Error.t)result=fun~stop_before->letopenErrorinfunction|`Root(abstr,unit_name)->begintryOkabstr.packagewithexn->Error(Uncaught_exn(Printexc.to_stringexn))end>>|funpkg_name->letpage=[pkg_name]inletkind="module"in(* FIXME: for the moment we ignore [stop_before] for compilation units. At
some point we want to change that. *)(*
if stop_before then
{ page; anchor = unit_name; kind }
else
*){page=UnitName.to_stringunit_name::page;anchor="";kind}|`Page(abstr,page_name)->begintryOkabstr.packagewithexn->Error(Uncaught_exn(Printexc.to_stringexn))end>>|funpkg_name->letpage=[PageName.to_stringpage_name^".html";pkg_name]inletkind="page"in{page;anchor="";kind}|`Module(parent,mod_name)->from_identifier_no_anchor(parent:>Identifier.t)("module "^ModuleName.to_stringmod_name)>>|funparent->letkind="module"inifstop_beforethen{page=parent;anchor=Printf.sprintf"%s-%s"kind(ModuleName.to_stringmod_name);kind}else{page=(ModuleName.to_stringmod_name)::parent;anchor="";kind}|`Argument(functor_id,arg_num,arg_name)->from_identifier_no_anchor(functor_id:>Identifier.t)("arg "^ArgumentName.to_stringarg_name)>>|funparent->letkind="argument"inletsuffix=Printf.sprintf"%s-%d-%s"kindarg_num(ArgumentName.to_stringarg_name)inifstop_beforethen{page=parent;anchor=suffix;kind}else{page=suffix::parent;anchor="";kind}|`ModuleType(parent,modt_name)->from_identifier_no_anchor(parent:>Identifier.t)("module type "^ModuleTypeName.to_stringmodt_name)>>|funparent->letkind="module-type"inletsuffix=Printf.sprintf"%s-%s"kind(ModuleTypeName.to_stringmodt_name)inifstop_beforethen{page=parent;anchor=suffix;kind}else{page=suffix::parent;anchor="";kind}|`Type(parent,type_name)->from_identifier_no_anchor(parent:>Identifier.t)("type "^(TypeName.to_stringtype_name))>>|funpage->letkind="type"in{page;anchor=Printf.sprintf"%s-%s"kind(TypeName.to_stringtype_name);kind}|`CoreTypety_name->Error(Not_linkable("core_type:"^(TypeName.to_stringty_name)))|`Constructor(parent,name)->from_identifier~stop_before:false(parent:>Identifier.t)>>=beginfunction(* FIXME: update doc-ock. *)(* | { anchor = ""; _ } as t -> Error (Missing_anchor (t, name)) *)|{page;anchor;_}->letkind="constructor"inOk{page;anchor=anchor^"."^(ConstructorName.to_stringname);kind}end|`Field(parent,name)->from_identifier~stop_before:false(parent:>Identifier.t)>>=beginfunction(* FIXME: update doc-ock. *)(* | { anchor = ""; _ } as t -> Error (Missing_anchor (t, name)) *)|{page;anchor;_}->letkind="field"inOk{page;anchor=anchor^"."^(FieldName.to_stringname);kind}end|`Extension(parent,name)->from_identifier_no_anchor(parent:>Identifier.t)("extension "^(ExtensionName.to_stringname))>>|funparent->letkind="extension"in{page=parent;anchor=Printf.sprintf"%s-%s"kind(ExtensionName.to_stringname);kind}|`Exception(parent,name)->from_identifier_no_anchor(parent:>Identifier.t)("exception "^(ExceptionName.to_stringname))>>|funparent->letkind="exception"in{page=parent;anchor=Printf.sprintf"%s-%s"kind(ExceptionName.to_stringname);kind}|`CoreExceptionname->Error(Not_linkable("core_exception:"^(ExceptionName.to_stringname)))|`Value(parent,name)->from_identifier_no_anchor(parent:>Identifier.t)("val "^(ValueName.to_stringname))>>|funparent->letkind="val"in{page=parent;anchor=Printf.sprintf"%s-%s"kind(ValueName.to_stringname);kind}|`Class(parent,name)->from_identifier_no_anchor(parent:>Identifier.t)("class "^(ClassName.to_stringname))>>|funparent->letkind="class"inletsuffix=Printf.sprintf"%s-%s"kind(ClassName.to_stringname)inifstop_beforethen{page=parent;anchor=suffix;kind}else{page=suffix::parent;anchor="";kind}|`ClassType(parent,name)->from_identifier_no_anchor(parent:>Identifier.t)("class type "^(ClassTypeName.to_stringname))>>|funparent->letkind="class-type"inletsuffix=Printf.sprintf"%s-%s"kind(ClassTypeName.to_stringname)inifstop_beforethen{page=parent;anchor=suffix;kind}else{page=suffix::parent;anchor="";kind}|`Method(parent,name)->letstr_name=MethodName.to_stringnameinfrom_identifier_no_anchor(parent:>Identifier.t)("method "^str_name)>>|funpage->letkind="method"in{page;anchor=Printf.sprintf"%s-%s"kindstr_name;kind}|`InstanceVariable(parent,name)->letstr_name=InstanceVariableName.to_stringnameinfrom_identifier_no_anchor(parent:>Identifier.t)("val "^str_name)>>|funpage->letkind="val"in{page;anchor=Printf.sprintf"%s-%s"kindstr_name;kind}|`Label(parent,anchor')->letanchor=LabelName.to_stringanchor'infrom_identifier~stop_before:false(parent:>Identifier.t)>>=function|{page;anchor="";kind}->(* Really ad-hoc and shitty, but it works. *)ifkind="page"thenOk{page;anchor;kind}elseOk{page;anchor;kind=""}|otherwise->Error(Unexpected_anchor(otherwise,"label "^anchor))andfrom_identifier_no_anchor:Identifier.t->string->(stringlist,Error.t)result=funidchild->from_identifier~stop_before:falseid>>=function|{page;anchor="";_}->Okpage|otherwise->Error(Unexpected_anchor(otherwise,child))letanchor_of_id_exnid=matchfrom_identifier~stop_before:trueidwith|Errore->failwith(Error.to_stringe)|Ok{anchor;_}->anchorletkind_of_id_exnid=matchfrom_identifier~stop_before:trueidwith|Errore->failwith(Error.to_stringe)|Ok{kind;_}->kindletrender_path:Odoc_model.Paths.Path.t->string=letopenOdoc_model.Paths.Pathinletrecrender_resolved:Odoc_model.Paths.Path.Resolved.t->string=letopenResolvedinfunction|`Identifierid->Identifier.nameid|`Subst(_,p)->render_resolved(p:>t)|`SubstAlias(_,p)->render_resolved(p:>t)|`Hiddenp->render_resolved(p:>t)|`Module(p,s)->render_resolved(p:>t)^"."^(ModuleName.to_strings)|`Canonical(_,`Resolvedp)->render_resolved(p:>t)|`Canonical(p,_)->render_resolved(p:>t)|`Apply(rp,p)->render_resolved(rp:>t)^"("^render_path(p:>Odoc_model.Paths.Path.t)^")"|`ModuleType(p,s)->render_resolved(p:>t)^"."^(ModuleTypeName.to_strings)|`Type(p,s)->render_resolved(p:>t)^"."^(TypeName.to_strings)|`Class(p,s)->render_resolved(p:>t)^"."^(ClassName.to_strings)|`ClassType(p,s)->render_resolved(p:>t)^"."^(ClassTypeName.to_strings)andrender_path:Odoc_model.Paths.Path.t->string=function|`Rootroot->root|`Forwardroot->root|`Dot(prefix,suffix)->render_path(prefix:>t)^"."^suffix|`Apply(p1,p2)->render_path(p1:>t)^"("^render_path(p2:>t)^")"|`Resolvedrp->render_resolvedrpinrender_pathmoduleAnchor=structtypet={kind:string;name:string;}modulePolymorphic_variant_decl=structletname_of_type_constrte=matchtewith|Odoc_model.Lang.TypeExpr.Constr(path,_)->render_path(path:>Odoc_model.Paths.Path.t)|_->invalid_arg"DocOckHtml.Url.Polymorphic_variant_decl.name_of_type_constr"letfrom_element~type_identelt=matchfrom_identifier~stop_before:truetype_identwith|Errore->failwith(Error.to_stringe)|Ok{anchor;_}->matcheltwith|Odoc_model.Lang.TypeExpr.Polymorphic_variant.Typete->{kind="type";name=Printf.sprintf"%s.%s"anchor(name_of_type_constrte)}|Constructor{name;_}->{kind="constructor";name=Printf.sprintf"%s.%s"anchorname}endmoduleModule_listing=structmoduleReference=Odoc_model.Paths.Reference(* TODO: better error message. *)letfail()=failwith"Only modules allowed inside {!modules: ...}"letrecfrom_reference:Reference.t->t=function|`Root(name,_)->{kind="xref-unresolved";name=Odoc_model.Names.UnitName.to_stringname}|`Dot(parent,suffix)->let{name;_}=from_reference(parent:>Reference.t)in{kind="xref-unresolved";name=Printf.sprintf"%s.%s"namesuffix}|`Module(parent,suffix)->let{name;_}=from_reference(parent:>Reference.t)in{kind="xref-unresolved";name=Printf.sprintf"%s.%s"name(Odoc_model.Names.ModuleName.to_stringsuffix)}|`ModuleType(parent,suffix)->let{name;_}=from_reference(parent:>Reference.t)in{kind="xref-unresolved";name=Printf.sprintf"%s.%s"name(Odoc_model.Names.ModuleTypeName.to_stringsuffix)}|`Resolvedr->from_resolvedr|_->fail()andfrom_resolved:Reference.Resolved.t->t=function|`Identifierid->letname=Identifier.nameidinletkind=matchfrom_identifier~stop_before:falseidwith|Ok{kind;_}->kind|Error_->fail()in{name;kind}|`Module(parent,s)->let{name;_}=from_resolved(parent:>Reference.Resolved.t)in{kind="module";name=Printf.sprintf"%s.%s"name(Odoc_model.Names.ModuleName.to_strings)}|`ModuleType(parent,s)->let{name;_}=from_resolved(parent:>Reference.Resolved.t)in{kind="module-type";name=Printf.sprintf"%s.%s"name(Odoc_model.Names.ModuleTypeName.to_strings)}|_->fail()endend