Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file OCamlbuildDocPlugin.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328(******************************************************************************)(* OASIS: architecture for building OCaml libraries and applications *)(* *)(* Copyright (C) 2011-2016, Sylvain Le Gall *)(* Copyright (C) 2008-2011, OCamlCore SARL *)(* *)(* This library is free software; you can redistribute it and/or modify it *)(* under the terms of the GNU Lesser General Public License as published by *)(* the Free Software Foundation; either version 2.1 of the License, or (at *)(* your option) any later version, with the OCaml static compilation *)(* exception. *)(* *)(* This library 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 file COPYING for more *)(* details. *)(* *)(* You should have received a copy of the GNU Lesser General Public License *)(* along with this library; if not, write to the Free Software Foundation, *)(* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *)(******************************************************************************)(* Create documentation using ocamlbuild .odocl files
@author Sylvain Le Gall
*)openOASISTypesopenOASISGettextopenOCamlbuildCommontyperun_t={extra_args:stringlist;run_path:unix_filename;}letdoc_build~ctxtrun_(cs,_)argv=letindex_html=OASISUnixPath.make[run.run_path;cs.cs_name^".docdir";"index.html";]inlettgt_dir=OASISHostPath.make[build_dirargv;OASISHostPath.of_unixrun.run_path;cs.cs_name^".docdir";]inrun_ocamlbuild~ctxt(index_html::run.extra_args)argv;List.iter(funglb->BaseBuilt.register~ctxtBaseBuilt.BDoccs.cs_name[OASISFileUtil.glob~ctxt(Filename.concattgt_dirglb)])["*.html";"*.css"]letdoc_clean~ctxt__(cs,_)argv=run_clean~ctxtargv;BaseBuilt.unregister~ctxtBaseBuilt.BDoccs.cs_name(* END EXPORT *)openOASISFileTemplateopenOASISValuesopenOASISUtilsopenOASISPluginopenOASISSchemaopenOCamlbuildIdletplugin=`Doc,name,Someversiontypet={path:unix_dirname;modules:stringlist;libraries:findlib_fulllist;intro:unix_filenameoption;flags:stringlist;common:ocamlbuild_common;}letpivot_data=data_new_propertypluginletpivot_sub_data=data_new_propertypluginletself_id,all_id=Doc.createpluginletnew_fieldnm?defaultvlhlpsync=new_fieldOASISDocument.schemaall_idnm?defaultvl(fun()->s_hlp)pivot_datasyncletpath=new_field"Path"directory(ns_"Top level directory for building ocamldoc documentation")(fun_t->t.path)letmodules=new_field"Modules"~default:[]modules(ns_"List of OCaml modules used to generate ocamldoc documentation")(fun_t->t.modules)letlibraries=new_field"Libraries"~default:[](comma_separatedfindlib_full)(ns_"Findlib names of internal libraries used to generate the ocamldoc \
documentation")(fun_t->t.libraries)(* TODO: the following 2 options require to edit _tags after OCamlbuildDoc
*)(*
let intro =
new_field
~default:None
"Intro"
(opt file)
(ns_ "OCamldoc formatted file used to generate index.html of the ocamldoc \
documentation")
(fun _ t -> t.intro)
let flags =
new_field
~default:[]
"Flags"
space_separated
(ns_ "OCamldoc flags")
(fun _ t -> t.flags)
*)(* TODO: use -t for title *)letgenerator=letgenerator_common=(* Register fields. *)ocamlbuild_common_generatorpivot_sub_dataOASISDocument.schemaall_idinfundatapkg->letpath=pathdatainletmodules_from_libraries=(* Convert findlib name to internal library and compute
* the module they shipped.
*)letlib_of_findlib=let_,_,library_name_of_findlib_name=OASISFindlib.findlib_mappingpkginletlib_of_name=List.fold_left(funmp->function|Library({cs_name=name;_},bs,lib)->MapString.addname(bs,lib)mp|_->mp)MapString.emptypkg.sectionsinfunfndlb_nm->letnm=library_name_of_findlib_namefndlb_nminMapString.findnmlib_of_namein(* Fetch modules from internal libraries *)List.flatten(List.map(funfndlb_nm->letbs,lib=lib_of_findlibfndlb_nmin(* Rebase modules in the doc path *)List.map(funmodul->OASISUnixPath.make_relativepath(OASISUnixPath.concatbs.bs_pathmodul))lib.lib_modules)(librariesdata))inletmodules_from_doc=(* Fetch modules defined directly *)modulesdatainletmodules=modules_from_libraries@modules_from_docin{path=path;modules=modules;libraries=librariesdata;intro=None;flags=[];common=generator_commondata;}letdoitctxtpkg(cs,doc)=lett=generatorcs.cs_datapkginletctxt=(* Create .odocl file *)add_file(template_make(OASISHostPath.add_extension(Filename.concatt.pathcs.cs_name)"odocl")comment_ocamlbuild[]t.modules[])ctxtinletctxt=(* Checks consistency of options *)(* TODO: merge with qstrt_completion *)List.fold_left(functxtf->fctxt)ctxt[set_error(not(List.mem(ExternalTool"ocamldoc")doc.doc_build_tools))(Printf.sprintf(f_"ocamldoc in field BuildTools of document %s is mandatory.")cs.cs_name);set_error(not(List.mem(ExternalTool"ocamlbuild")doc.doc_build_tools))(Printf.sprintf(f_"ocamlbuild in field BuildTools of document %s is mandatory.")cs.cs_name);set_error(t.modules=[])(Printf.sprintf(f_"No module defined for document %s.")cs.cs_name);]inletextra_args,ctxt=extra_args_ocamlbuild_commonctxtpkgt.commoninletrun={run_path=t.path;extra_args=extra_args}inletodn_of_run_t(v:run_t)=OASISDataNotation.REC("OCamlbuildDocPlugin",[("extra_args",((funx->OASISDataNotation.of_listOASISDataNotation.of_stringx)v.extra_args));("run_path",(odn_of_unix_filenamev.run_path))])inctxt,{chng_moduls=[OCamlbuildData.ocamlbuildsys_ml];chng_main=OASISDataNotation.func_with_arg_ctxtdoc_build"OCamlbuildDocPlugin.doc_build"runodn_of_run_t;chng_clean=Some(OASISDataNotation.func_with_arg_ctxtdoc_clean"OCamlbuildDocPlugin.doc_clean"runodn_of_run_t);chng_distclean=None;}letqstrt_completionpkg=List.fold_left(funpkgtool->fix_build_toolstoolpkg)pkg[ExternalTool"ocamlbuild";ExternalTool"ocamldoc"]letinit()=OCamlbuildId.init();Doc.register_actself_iddoit;register_quickstart_completionall_idqstrt_completion