Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file indexOut.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334(**************************************************************************)(* *)(* Copyright 2013 OCamlPro *)(* *)(* All rights reserved. This file is distributed under the terms of *)(* the Lesser GNU Public License version 3.0. *)(* *)(* This software is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* Lesser GNU General Public License for more details. *)(* *)(**************************************************************************)openIndexTypesletoption_iteroptf=matchoptwith|Somex->fx|None->()letrecstring_index_fromsichars=ifi>=String.lengthsthenraiseNot_foundelseifString.containscharss.[i]thenielsestring_index_froms(i+1)charsmoduleIndexFormat=structletlist?(paren=false)?(left=fun_->())?(right=fun_->())prsepfmtlst=letrecaux=function|[]->()|[x]->prfmtx|x::r->prfmtx;sepfmt();auxrinmatchlstwith|[]->()|[x]->leftfmt;prfmtx;rightfmt|_::_::_->ifparenthenFormat.pp_print_charfmt'(';leftfmt;auxlst;rightfmt;ifparenthenFormat.pp_print_charfmt')'letlines?(escaped=false)fmtstr=letlen=String.lengthstrinletesc=ifescapedthenString.escapedelsefuns->sinletrecauxi=ifi>=lenthen()elseletj=tryString.index_fromstri'\n'withNot_found->leninFormat.pp_print_stringfmt(esc(String.trim(String.substri(j-i))));ifj<len-1then(Format.pp_force_newlinefmt();aux(j+1))inaux0typecoloriser={f:'a.kind->('a,Format.formatter,unit)format->Format.formatter->'a}letcolor=letfkindfstrfmt=letcolorcode=matchkindwith|OpenType|Type->"\027[36m"|Value->"\027[1m"|Exception->"\027[33m"|Field_|Variant_->"\027[34m"|Method_->"\027[1m"|Module|ModuleType->"\027[31m"|Class|ClassType->"\027[35m"|Keyword->"\027[32m"inFormat.pp_print_asfmt0colorcode;Format.kfprintf(funfmt->Format.pp_print_asfmt0"\027[m")fmtfstrin{f}letno_color=letf_fstrfmt=Format.fprintffmtfstrin{f}letname?(colorise=no_color)fmtid=colorise.fid.kind"%s"fmtid.nameletpath?(short=false)?(colorise=no_color)fmtid=List.iter(Format.fprintffmt"%a."(colorise.fModule"%s"))(ifshortthenid.pathelseid.orig_path);name~colorisefmtidletkind?(colorise=no_color)fmtid=matchid.kindwith|OpenType->Format.pp_print_stringfmt"opentype"|Type->Format.pp_print_stringfmt"type"|Value->Format.pp_print_stringfmt"val"|Exception->Format.pp_print_stringfmt"exception"|Fieldparentty->Format.fprintffmt"field(%a)"(colorise.fparentty.kind"%s")parentty.name|Variantparentty->Format.fprintffmt"constr(%a)"(colorise.fparentty.kind"%s")parentty.name|Methodparentclass->Format.fprintffmt"method(%a)"(colorise.fparentclass.kind"%s")parentclass.name|Module->Format.pp_print_stringfmt"module"|ModuleType->Format.pp_print_stringfmt"modtype"|Class->Format.pp_print_stringfmt"class"|ClassType->Format.pp_print_stringfmt"classtype"|Keyword->Format.pp_print_stringfmt"keyword"letrectydeclfmt=letopenOutcometreeinfunction|Otyp_abstract->Format.fprintffmt"<abstract>"|Otyp_manifest(ty,_)->tydeclfmtty|Otyp_recordfields->letprint_fieldfmt(name,mut,arg)=Format.fprintffmt"@[<2>%s%s :@ @[%a@]@];"(ifmutthen"mutable "else"")name!Oprint.out_typearginFormat.fprintffmt"@[<hv 2>{%a}@]"(list~left:(funfmt->Format.pp_print_spacefmt())~right:(funfmt->Format.pp_print_breakfmt1(-2))print_fieldFormat.pp_print_space)fields|Otyp_sum[]->Format.pp_print_charfmt'-'|Otyp_sumconstrs->letprint_variantfmt(name,tyl,ret_type_opt)=matchret_type_optwith|None->iftyl=[]thenFormat.pp_print_stringfmtnameelseFormat.fprintffmt"@[<2>%s of@ @[%a@]@]"name(list!Oprint.out_type(funfmt()->Format.fprintffmt" *@ "))tyl|Someret_type->iftyl=[]thenFormat.fprintffmt"@[<2>%s :@ @[%a@]@]"name!Oprint.out_typeret_typeelseFormat.fprintffmt"@[<2>%s :@ @[%a -> @[%a@]@]@]"name(list!Oprint.out_type(funfmt()->Format.fprintffmt" *@ "))tyl!Oprint.out_typeret_typeinlistprint_variant~left:(funfmt->Format.pp_print_if_newlinefmt();Format.fprintffmt"| ")(funfmt()->Format.fprintffmt"@ | ")fmtconstrs|ty->!Oprint.out_typefmttyletout_tyfmtty=letopenOutcometreeinmatchtywith|Osig_class(_,_,_,ctyp,_)|Osig_class_type(_,_,_,ctyp,_)->!Oprint.out_class_typefmtctyp|Osig_typext({oext_args=[]},_)->Format.pp_print_charfmt'-'|Osig_typext({oext_args},_)->list~paren:true!Oprint.out_type(funfmt()->Format.pp_print_charfmt',';Format.pp_print_spacefmt())fmtoext_args|Osig_modtype(_,mtyp)|Osig_module(_,mtyp,_)->!Oprint.out_module_typefmtmtyp#ifOCAML_VERSION>="4.03"|Osig_type({otype_type},_)->tydeclfmtotype_type|Osig_value{oval_type}->!Oprint.out_typefmtoval_type|Osig_ellipsis->Format.fprintffmt"..."#elifOCAML_VERSION>="4.02"|Osig_type({otype_type},_)->tydeclfmtotype_type|Osig_value(_,ty,_)->!Oprint.out_typefmtty#else|Osig_type((_,_,ty,_,_),_)->tydeclfmtty|Osig_value(_,ty,_)->!Oprint.out_typefmtty#endifletty?(colorise=no_color)fmtid=option_iterid.ty(colorise.fType"@[<hv>%a@]"fmtout_ty)letparent_ty?colorise?shortfmtid=option_iter(IndexMisc.parent_typeid)(funid->Format.fprintffmt"@[<hv>%a =@ %a@]"(path?colorise?short)id(ty?colorise)id)letdoc?escaped?colorise:(_=no_color)fmtid=option_iter(Lazy.forceid.doc)(Format.fprintffmt"@[<h>%a@]"(lines?escaped))letloc?root?(intf=false)?colorise:(_=no_color)fmtid=letloc=ifintfthenLazy.forceid.loc_sigelseLazy.forceid.loc_implinifloc=Location.nonethenFormat.fprintffmt"@[<h><no location information>@]"elseletpos=loc.Location.loc_startinletfname=matchrootwith|SomerwhenFilename.is_relativepos.Lexing.pos_fname->Filename.concatrpos.Lexing.pos_fname|_->pos.Lexing.pos_fnameinFormat.fprintffmt"@[<h>%s:%d:%d@]"fnamepos.Lexing.pos_lnum(pos.Lexing.pos_cnum-pos.Lexing.pos_bol)letfile?colorise:(_=no_color)fmtid=Format.fprintffmt"@[<h>%s@]"(matchid.filewithCmtf|Cmif|Cmtif->f)letinfo?(colorise=no_color)fmtid=letbreakifnfmt=function|None->()|Some_->Format.pp_print_breakfmt1ninFormat.fprintffmt"@[<v 2>@[<hov 2>%a@ %a%a%a@]%a%a@]@."(path?short:None~colorise)id(kind~colorise)id(breakif0)id.ty(ty~colorise)id(breakif2)(Lazy.forceid.doc)(doc?escaped:None~colorise)idlethandle_format_char?rootchr?colorisefmtid=matchchrwith|'n'->name?colorisefmtid|'q'->path~short:true?colorisefmtid|'p'->path?colorisefmtid|'k'->kind?colorisefmtid|'t'->ty?colorisefmtid|'d'->doc?colorisefmtid|'D'->doc~escaped:true?colorisefmtid|'l'->loc?root?colorisefmtid|'s'->loc?root~intf:true?colorisefmtid|'f'->file?colorisefmtid|'i'->info?colorisefmtid|'e'->parent_ty?colorisefmtid|'%'->Format.fprintffmt"%%"|c->Format.fprintffmt"%%%c"cletformat?root?(separate=false)format?colorisefmtid=letlen=String.lengthformatinletrecauxaddsubffmtflushi=letj=trystring_index_fromformati"%\\"withNot_found->leninifj>ithenaddsubi(j-i);ifj>=len-1thenaddsubj(len-j)elseletfmt=ffmt()inbeginmatchformat.[j],format.[j+1]with|'%',c->handle_format_char?rootc?colorisefmtid|'\\','n'->Format.pp_print_newlinefmt()|'\\','t'->Format.pp_print_charfmt'\t'|'\\','r'->Format.pp_print_charfmt'\r'|'\\',c->Format.pp_print_charfmtc|_->assertfalseend;flushfmt;auxaddsubffmtflush(j+2)inifnotseparatethenletaddsubilen=Format.pp_print_stringfmt(String.subformatilen)inletffmt()=fmtinletflush_=()inauxaddsubffmtflush0elseletb=Buffer.create200inletaddsub=Buffer.add_substringbformatinletffmt()=Format.formatter_of_bufferbinletflushfmt=Format.pp_print_flushfmt()inauxaddsubffmtflush0;Format.pp_print_stringfmt(Buffer.contentsb)endmodulePrint=structletdisable_split_lines()=Format.pp_set_marginFormat.str_formatter1_000_000letmake(f:?colorise:IndexFormat.coloriser->'a)?(color=false)id=letcolorise=ifcolorthenIndexFormat.colorelseIndexFormat.no_colorinf~coloriseFormat.str_formatterid;Format.flush_str_formatter()letname=makeIndexFormat.nameletpath?short=make(IndexFormat.path?short)letkind=makeIndexFormat.kindletty=makeIndexFormat.tyletdoc?escaped=make(IndexFormat.doc?escaped)letloc?root?intf=make(IndexFormat.loc?root?intf)letfile=makeIndexFormat.fileletinfo=makeIndexFormat.infoletformat?root?separateformat=make(IndexFormat.format?root?separateformat)endmoduleFormat=IndexFormat