Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file doc_attr.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170(*
* 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.
*)openOdoc_modelmodulePaths=Odoc_model.Pathsletempty_body=[]letempty:Odoc_model.Comment.docs=empty_bodyletload_payload:Parsetree.payload->string*Location.t=function|PStr[{pstr_desc=Pstr_eval({pexp_desc=#ifOCAML_VERSION<(4,3,0)Pexp_constant(Const_string(text,_))#elifOCAML_VERSION<(4,11,0)Pexp_constant(Pconst_string(text,_))#elsePexp_constant(Pconst_string(text,_,_))#endif;pexp_loc=loc;_},_);_}]->(text,loc)|_->assertfalseletparse_attribute:Parsetree.attribute->(string*Location.t)option=function#ifOCAML_VERSION>=(4,8,0)|{attr_name={Location.txt=("text"|"ocaml.text");loc=_loc};attr_payload;_}->begin#else|({Location.txt=("text"|"ocaml.text");loc=_loc},attr_payload)->begin#endifSome(load_payloadattr_payload)end|_->Noneletpad_locloc={loc.Location.loc_startwithpos_cnum=loc.loc_start.pos_cnum+3}letast_to_comment~internal_tagsparentast_docs=Odoc_model.Semantics.ast_to_comment~internal_tags~sections_allowed:`All~parent_of_sections:parentast_docs|>Error.raise_warningsletattachedinternal_tagsparentattrs=letrecloopacc=function#ifOCAML_VERSION>=(4,8,0)|{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#endifletstr,loc=load_payloadattr_payloadinletast_docs=Odoc_parser.parse_comment~location:(pad_locloc)~text:str|>Error.raise_parser_warningsinloop(List.rev_appendast_docsacc)restend|_::rest->loopaccrest|[]->List.revaccinletast_docs=loop[]attrsinast_to_comment~internal_tagsparentast_docsletattached_no_tagparentattrs=letx,()=attachedSemantics.Expect_noneparentattrsinxletread_stringinternal_tagsparentlocationstr=Odoc_model.Semantics.parse_comment~internal_tags~sections_allowed:`All~containing_definition:parent~location~text:str|>Odoc_model.Error.raise_warningsletread_string_commentinternal_tagsparentlocstr=read_stringinternal_tagsparent(pad_locloc)strletpageparentlocstr=letdoc,()=read_stringOdoc_model.Semantics.Expect_noneparentloc.Location.loc_startstrin`Docsdocletstandaloneparent(attr:Parsetree.attribute):Odoc_model.Comment.docs_or_stopoption=matchparse_attributeattrwith|Some("/*",_loc)->Some`Stop|Some(str,loc)->letdoc,()=read_string_commentSemantics.Expect_noneparentlocstrinSome(`Docsdoc)|_->Noneletstandalone_multipleparentattrs=letcoms=List.fold_left(funaccattr->matchstandaloneparentattrwith|None->acc|Somecom->com::acc)[]attrsinList.revcomsletsplit_docsdocs=letrecinnerfirstx=matchxwith|{Location_.value=`Heading_;_}::_->List.revfirst,x|x::y->inner(x::first)y|[]->List.revfirst,[]ininner[]docsletextract_top_commentinternal_tags~classifyparentitems=letrecextract~classify=function|hd::tlasitems->(matchclassifyhdwith|Some(`Attributeattr)->(matchparse_attributeattrwith|Some(text,loc)->letast_docs=Odoc_parser.parse_comment~location:(pad_locloc)~text|>Error.raise_parser_warningsin(tl,ast_docs)|None->letitems,ast_docs=extract~classifytlin(hd::items,ast_docs))|Some`Open->letitems,ast_docs=extract~classifytlin(hd::items,ast_docs)|None->(items,[]))|[]->([],[])inletitems,ast_docs=extract~classifyitemsinletdocs,tags=ast_to_comment~internal_tags(parent:Paths.Identifier.Signature.t:>Paths.Identifier.LabelParent.t)ast_docsin(items,split_docsdocs,tags)letextract_top_comment_classitems=matchitemswith|Lang.ClassSignature.Comment(`Docsdoc)::tl->(tl,split_docsdoc)|_->items,(empty,empty)