Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file doc_attr.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136openResult(*
* Copyright (c) 2014 Leo White <lpw25@cl.cam.ac.uk>
*
* 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.
*)modulePaths=Odoc_model.Pathsletempty_body=[]letempty:Odoc_model.Comment.docs=empty_bodyletload_payload:Parsetree.payload->(string*Location.t)option=function|PStr[{pstr_desc=Pstr_eval({pexp_desc=#ifOCAML_MAJOR=4&&OCAML_MINOR=02Pexp_constant(Const_string(text,_))#elifOCAML_MAJOR=4&&OCAML_MINOR<11Pexp_constant(Pconst_string(text,_))#elsePexp_constant(Pconst_string(text,_,_))#endif;pexp_loc=loc;_},_);_}]->Some(text,loc)|_->Noneletattachedparentattrs=letocaml_deprecated=refNoneinletrecloopfirstnb_deprecatedacc:_->(Odoc_model.Comment.docs,Odoc_model.Error.t)result=function#ifOCAML_MAJOR=4&&OCAML_MINOR>=08|{Parsetree.attr_name={Location.txt=("doc"|"ocaml.doc");loc=_loc};attr_payload;_}::rest->begin#else|({Location.txt=("doc"|"ocaml.doc");loc=_loc},attr_payload)::rest->begin#endifmatchload_payloadattr_payloadwith|Some(str,loc)->beginletstart_pos=loc.Location.loc_startinletstart_pos={start_poswithpos_cnum=start_pos.pos_cnum+3}inletparsed=Odoc_parser.parse_comment~sections_allowed:`All~containing_definition:parent~location:start_pos~text:str|>Odoc_model.Error.shed_warningsinloopfalse0(acc@parsed)restend|None->(* TODO *)assertfalseend|_::rest->loopfirstnb_deprecatedaccrest|[]->beginmatchnb_deprecated,!ocaml_deprecatedwith|0,Some_tag->Okacc|_,_->Okaccendinlooptrue0empty_bodyattrs|>Odoc_model.Error.to_exceptionletread_stringparentlocstr:Odoc_model.Comment.docs_or_stop=letstart_pos=loc.Location.loc_startinletdoc:Odoc_model.Comment.docs=Odoc_parser.parse_comment~sections_allowed:`All~containing_definition:parent~location:start_pos~text:str|>Odoc_model.Error.shed_warningsin`Docsdocletpage=read_stringletstandaloneparent:Parsetree.attribute->Odoc_model.Comment.docs_or_stopoption=function#ifOCAML_MAJOR=4&&OCAML_MINOR>=08|{attr_name={Location.txt=("text"|"ocaml.text");loc=_loc};attr_payload;_}->begin#else|({Location.txt=("text"|"ocaml.text");loc=_loc},attr_payload)->begin#endifmatchload_payloadattr_payloadwith|Some("/*",_loc)->Some`Stop|Some(str,loc)->letloc'={locwithloc_start={loc.loc_startwithpos_cnum=loc.loc_start.pos_cnum+3}}inSome(read_stringparentloc'str)|None->(* TODO *)assertfalse(* let doc : Odoc_model.Comment.t =
Error (invalid_attribute_error parent loc) in
Some (Documentation doc) *)end|_->Noneletstandalone_multipleparentattrs=letcoms=List.fold_left(funaccattr->matchstandaloneparentattrwith|None->acc|Somecom->com::acc)[]attrsinList.revcoms