diff --git a/v2/tools/doxygen.jam b/v2/tools/doxygen.jam index 52898d1a8..43736e99b 100644 --- a/v2/tools/doxygen.jam +++ b/v2/tools/doxygen.jam @@ -33,6 +33,10 @@ import project ; import xsltproc ; import make ; import os ; +import toolset : flags ; +import alias ; +import common ; +import modules ; # Use to specify extra configuration paramters. These get translated # into a doxyfile which configures the building of the docs. @@ -44,17 +48,29 @@ feature.feature prefix : : free ; # Specify the "boost.doxygen.reftitle" XSLT option. feature.feature reftitle : : free ; +# Which processor to use for various translations from Doxygen. +feature.feature doxygen.processor : xsltproc doxproc : propagated implicit ; + +# To generate, or not, index sections. +feature.feature doxygen.doxproc.index : no yes : propagated incidental ; + +# The ID for the resulting BoostBook reference section. +feature.feature doxygen.doxproc.id : : free ; + +# The title for the resulting BoostBook reference section. +feature.feature doxygen.doxproc.title : : free ; + # Doxygen configuration input file. type.register DOXYFILE : doxyfile ; # Doxygen XML multi-file output. -type.register DOXYGEN_XML_MULTIFILE : : XML ; +type.register DOXYGEN_XML_MULTIFILE : xml-dir : XML ; # Doxygen XML coallesed output. type.register DOXYGEN_XML : doxygen : XML ; # Doxygen HTML multifile directory. -type.register DOXYGEN_HTML_MULTIFILE : dir : HTML ; +type.register DOXYGEN_HTML_MULTIFILE : html-dir : HTML ; # Redirection HTML file to HTML multifile directory. type.register DOXYGEN_HTML : : HTML ; @@ -125,13 +141,24 @@ rule init ( name ? ) .doxygen = $(name) ; } .doxygen ?= doxygen ; + + .doxproc = [ modules.binding $(__name__) ] ; + .doxproc = $(.doxproc:D)/doxproc.py ; - generators.register-composing doxygen.headers-to-doxyfile : H HPP CPP : DOXYFILE ; - generators.register-standard doxygen.run : DOXYFILE : DOXYGEN_XML_MULTIFILE ; - generators.register-standard doxygen.xml-to-boostbook : DOXYGEN_XML : BOOSTBOOK ; - generators.register-standard doxygen.collect : DOXYGEN_XML_MULTIFILE : DOXYGEN_XML ; - generators.register-standard doxygen.run : DOXYFILE : DOXYGEN_HTML_MULTIFILE ; - generators.register-standard doxygen.html-redirect : DOXYGEN_HTML_MULTIFILE : DOXYGEN_HTML ; + generators.register-composing doxygen.headers-to-doxyfile + : H HPP CPP : DOXYFILE ; + generators.register-standard doxygen.run + : DOXYFILE : DOXYGEN_XML_MULTIFILE ; + generators.register-standard doxygen.xml-dir-to-boostbook + : DOXYGEN_XML_MULTIFILE : BOOSTBOOK : doxproc ; + generators.register-standard doxygen.xml-to-boostbook + : DOXYGEN_XML : BOOSTBOOK : xsltproc ; + generators.register-standard doxygen.collect + : DOXYGEN_XML_MULTIFILE : DOXYGEN_XML ; + generators.register-standard doxygen.run + : DOXYFILE : DOXYGEN_HTML_MULTIFILE ; + generators.register-standard doxygen.html-redirect + : DOXYGEN_HTML_MULTIFILE : DOXYGEN_HTML ; IMPORT $(__name__) : doxygen : : doxygen ; } @@ -150,7 +177,13 @@ rule name ( ) # action must deal with this behavior. actions doxygen-action { - "$(NAME:E=doxygen)" $(>) && echo "Stamped" > "$(<)" + $(RM) "$(*.XML)" & "$(NAME:E=doxygen)" $(>) && echo "Stamped" > "$(<)" +} + +# Runs the Python doxproc XML processor. +actions doxproc +{ + python "$(DOXPROC)" "--xmldir=$(>)" "--output=$(<)" "$(OPTIONS)" "--id=$(ID)" "--title=$(TITLE)" } # Generates a doxygen configuration file (doxyfile) given a set of C++ @@ -159,12 +192,24 @@ actions doxygen-action rule headers-to-doxyfile ( target : sources * : properties * ) { local text "# Generated by Boost.Build version 2" ; + + local output-dir ; # Translate into command line flags. for local param in [ feature.get-values : $(properties) ] { local namevalue = [ regex.match ([^=]*)=(.*) : $(param) ] ; text += "$(namevalue[1]) = $(namevalue[2])" ; + if $(namevalue[1]) = OUTPUT_DIRECTORY + { + output-dir = "$(namevalue[2])" ; + } + } + + if ! $(output-dir) + { + output-dir = [ on $(target) return $(LOCATE) ] ; + text += "OUTPUT_DIRECTORY = $(output-dir)" ; } local headers = "" ; @@ -188,6 +233,15 @@ rule run ( target : source : properties * ) { doxygen-action $(target) : $(source) ; NAME on $(target) = $(.doxygen) ; + RM on $(target) = [ modules.peek common : RM ] ; + *.XML on $(target) = + [ path.native + [ path.join + [ path.make [ on $(target) return $(LOCATE) ] ] + $(target:B:S=) + *.xml ] + ] + ; } # The rules below require Boost.Book stylesheets, so we need @@ -218,9 +272,12 @@ rule collect ( target : source : properties * ) local collect-xsl-dir = [ path.native [ path.join [ boostbook.xsl-dir ] doxygen collect ] ] ; - local collect-path = [ path.join [ path.pwd ] xml ] ; - local real-source = [ path.native xml/index.xml ] ; - NOTFILE $(real-source) ; + local source-path + = [ path.make [ on $(source) return $(LOCATE) ] ] ; + local collect-path + = [ path.join [ path.pwd ] $(source-path) $(source:B) ] ; + local real-source + = [ path.native [ path.join [ path.native $(collect-path) ] index.xml ] ] ; xsltproc.xslt $(target) : $(real-source) $(collect-xsl-dir:S=.xsl) : doxygen.xml.path=$(collect-path) ; @@ -248,6 +305,19 @@ rule xml-to-boostbook ( target : source : properties * ) xsltproc.xslt $(target) : $(source) $(d2b-xsl) : $(xslt-properties) ; } +flags doxygen.xml-dir-to-boostbook OPTIONS yes : --enable-index ; +flags doxygen.xml-dir-to-boostbook ID ; +flags doxygen.xml-dir-to-boostbook TITLE ; + +rule xml-dir-to-boostbook ( target : source : properties * ) +{ + DOXPROC on $(target) = $(.doxproc) ; + + LOCATE on $(source:S=) = [ on $(source) return $(LOCATE) ] ; + + doxygen.doxproc $(target) : $(source:S=) ; +} + # Generate the HTML redirect to HTML dir index.html file. rule html-redirect ( target : source : properties * ) { @@ -273,7 +343,7 @@ rule html-redirect ( target : source : properties * ) } # User-level rule to generate BoostBook XML from a set of headers via Doxygen. -rule doxygen ( target : sources * : requirements * : default-build * ) +rule doxygen ( target : sources * : requirements * : default-build * : usage-requirements * ) { local project = [ project.current ] ; @@ -325,24 +395,65 @@ rule doxygen ( target : sources * : requirements * : default-build * ) else { # Build a BoostBook XML file from the sources. - local doxyfile = [ - new typed-target $(target) : $(project) : BOOSTBOOK - : [ targets.main-target-sources $(sources) : $(target) ] + local location-xml = [ feature.get-values : $(requirements) ] ; + requirements = [ property.change $(requirements) : ] ; + local target-xml = $(target:B=$(target:B)-xml) ; + + ## The doxygen configuration file. + targets.main-target-alternative + [ new typed-target $(target-xml:S=.tag) : $(project) : DOXYFILE + : [ targets.main-target-sources $(sources) : $(target-xml:S=.tag) ] : [ targets.main-target-requirements $(requirements) GENERATE_HTML=NO GENERATE_XML=YES + XML_OUTPUT=$(target-xml) : $(project) ] : [ targets.main-target-default-build $(default-build) : $(project) ] ] ; - targets.main-target-alternative $(doxyfile) ; + $(project).mark-target-as-explicit $(target-xml:S=.tag) ; + + ## The Doxygen XML directory of the processed source files. + targets.main-target-alternative + [ new typed-target $(target-xml:S=.dir) : $(project) : DOXYGEN_XML_MULTIFILE + : $(target-xml:S=.tag) + : [ targets.main-target-requirements $(requirements) + : $(project) ] + : [ targets.main-target-default-build $(default-build) : $(project) ] + ] ; + $(project).mark-target-as-explicit $(target-xml:S=.dir) ; + + ## The resulting BoostBook file is generated by the processor tool. The + ## tool can be either the xsltproc plus accompanying XSL scripts. Or it + ## can be the python doxproc.py script. + targets.main-target-alternative + [ new typed-target $(target-xml) : $(project) : BOOSTBOOK + : $(target-xml:S=.dir) + : [ targets.main-target-requirements $(requirements) + : $(project) ] + : [ targets.main-target-default-build $(default-build) : $(project) ] + ] ; + $(project).mark-target-as-explicit $(target-xml) ; targets.main-target-alternative [ new install-target-class $(target:S=.xml) : $(project) - : [ $(doxyfile).name ] + : $(target-xml) : [ targets.main-target-requirements $(requirements) - . + $(location-xml:E=.) + $(target:S=.xml) : $(project) ] : [ targets.main-target-default-build $(default-build) : $(project) ] ] ; + $(project).mark-target-as-explicit $(target:S=.xml) ; + + targets.main-target-alternative + [ new alias-target-class $(target) : $(project) + : + : [ targets.main-target-requirements $(requirements) + : $(project) ] + : [ targets.main-target-default-build $(default-build) : $(project) ] + : [ targets.main-target-usage-requirements $(usage-requirements) + $(target:S=.xml) + : $(project) ] + ] ; } }