Commits

james woodyatt committed 0c901e3

Add the 'documents' target for generating HTML with ocamldoc.

Comments (0)

Files changed (6)

     PKG.REQUIRES=oni.cf
     install: $(PKG.install-target)
     remove: $(PKG.remove-target)
+    documents: $(PKG.documents-target)
     
     clean:
         rm -rf $(AUXROOT)
 public.ROOT= $(dir .)
 
 ### Emphemeral targets
-.PHONY: clean test install remove
+.PHONY: clean test documents install remove
 
 ### Include OMakefile from top directory
 .SUBDIRS: .
         ARCHIVES=$(unit.package-archives)
         REQUIRES=unix
     PKG=$(PKG.add-subpackage $(sub))
+    PKG=$(component.package-search $(PKG))
     PKG.FILES+=$(unit.package-files $(component))
     export PKG
 
         REQUIRES=oni.nx
         ARCHIVES=$(unit.package-archives)
     PKG=$(PKG.add-subpackage $(sub))
+    PKG=$(M.iom.package-search $(PKG))
     PKG.FILES+=$(unit.package-files $(M.iom))
     export PKG
 
         REQUIRES=unix oni.cf
         ARCHIVES=$(unit.package-archives)
     PKG=$(PKG.add-subpackage $(sub))
+    PKG=$(M.nx.package-search $(PKG))
     PKG.FILES+=$(unit.package-files $(M.nx))
     export PKG
 

project/lang/OCaml.om

         ocamldep=$(SelectDriver ocamldep)
         ocamlc=$(SelectDriver ocamlc)
         ocamlopt=$(SelectDriver ocamlopt)
+        ocamldoc=$(SelectDriver ocamldoc)
 
 ### The Objective Caml native/byte-code compilers
 OCaml_compiler.=
         private.libs=$(name).cmxa
         return $(mklib-composer-rule $(name), $(libs), $(cmxfiles), $(dst))
 
+### The OCaml document generator
+OCAMLDOC.=
+    extends $(OCaml_compiler)
+    
+    ### Driver
+    DRIVER()=
+        return $(cmd-driver ocamldoc)
+    
+    ### The verbose flag
+    verbose-flag()=
+        return $(if $(VERBOSE), -v, $(EMPTY))
+    
+    ### Composer options
+    protected.composer-options(src, index)=
+        private.opts=-html -colorize-code -short-functors
+        private.opts+=$(verbose-flag) $(include-search)
+        return $(opts) -d $(dirname $(index)) $(src)
+    
+    ### Generate HTML documents
+    html-documents(srcfiles, dst)=
+        private.index=$(file $(dst)/index.html)
+        private.mlifiles=$(filter %.mli, $(srcfiles))
+        composer-rule($(mlifiles), $(index))
+        return $(index)
+
 ### Component for staging OCaml language compositions
 OCaml_component.=
     class OCaml_component
             cmxa(config)=
                 return $(file $(STAGE.DIR)/$(config)/$(name).cmxa)
         return $r
+    
+    ### Add component to document search path for package
+    package-search(p)=
+        p.DOCSEARCH+=$(this.STAGE.DIR)
+        return $p
 
 ### Class of objects that refer to an OCaml library in a component
 OCaml_library_referral.=
         this.STAGE=$(stage.push $(this.NAME).package)
         this.VERSION=$(src.VERSION)
         this.FILES[]=
+        this.DOCSEARCH[]=
         return $(this)
     
     ### Install target
         $(target):
             -ocamlfind remove $(this.NAME)
         return $(target)
+    
+    ### Documents target
+    documents-target()=
+        private.target=$(addprefix documents-, $(this.NAME))
+        private.dstage=$(this.STAGE.push docs)
+        OCAMLDOC.DEPEND+=$(dstage.DIR)
+        OCAMLDOC.SEARCH+=$(this.DOCSEARCH)
+        return $(OCAMLDOC.html-documents $(this.FILES), $(dstage.DIR))
 
 # End $File$