@@ -89,55 +89,42 @@ def do_subst_in_file(targetfile, sourcefile, dict):
8989 print "Can't write target file %s" % targetfile
9090 raise
9191
92- def run_doxygen (doxygen_path , config_file , working_dir ):
92+ def run_doxygen (doxygen_path , config_file , working_dir , is_silent ):
9393 config_file = os .path .abspath ( config_file )
9494 doxygen_path = doxygen_path
9595 old_cwd = os .getcwd ()
9696 try :
9797 os .chdir ( working_dir )
9898 cmd = [doxygen_path , config_file ]
99- print ' ' .join ( cmd )
99+ print 'Running:' , ' ' .join ( cmd )
100100 try :
101101 import subprocess
102102 except :
103103 if os .system ( ' ' .join ( cmd ) ) != 0 :
104104 print 'Documentation generation failed'
105105 return False
106106 else :
107- try :
108- subprocess .check_call ( cmd )
109- except subprocess .CalledProcessError :
107+ if is_silent :
108+ process = subprocess .Popen ( cmd , stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
109+ else :
110+ process = subprocess .Popen ( cmd )
111+ stdout , _ = process .communicate ()
112+ if process .returncode :
113+ print 'Documentation generation failed:'
114+ print stdout
110115 return False
111116 return True
112117 finally :
113118 os .chdir ( old_cwd )
114119
115- def main ():
116- usage = """%prog
117- Generates doxygen documentation in build/doxygen.
118- Optionaly makes a tarball of the documentation to dist/.
119-
120- Must be started in the project top directory.
121- """
122- from optparse import OptionParser
123- parser = OptionParser (usage = usage )
124- parser .allow_interspersed_args = False
125- parser .add_option ('--with-dot' , dest = "with_dot" , action = 'store_true' , default = False ,
126- help = """Enable usage of DOT to generate collaboration diagram""" )
127- parser .add_option ('--dot' , dest = "dot_path" , action = 'store' , default = find_program ('dot' ),
128- help = """Path to GraphViz dot tool. Must be full qualified path. [Default: %default]""" )
129- parser .add_option ('--doxygen' , dest = "doxygen_path" , action = 'store' , default = find_program ('doxygen' ),
130- help = """Path to Doxygen tool. [Default: %default]""" )
131- parser .add_option ('--with-html-help' , dest = "with_html_help" , action = 'store_true' , default = False ,
132- help = """Enable generation of Microsoft HTML HELP""" )
133- parser .add_option ('--no-uml-look' , dest = "with_uml_look" , action = 'store_false' , default = True ,
134- help = """Generates DOT graph without UML look [Default: False]""" )
135- parser .add_option ('--open' , dest = "open" , action = 'store_true' , default = False ,
136- help = """Open the HTML index in the web browser after generation""" )
137- parser .add_option ('--tarball' , dest = "make_tarball" , action = 'store_true' , default = False ,
138- help = """Generates a tarball of the documentation in dist/ directory""" )
139- parser .enable_interspersed_args ()
140- options , args = parser .parse_args ()
120+ def build_doc ( options , make_release = False ):
121+ if make_release :
122+ options .make_tarball = True
123+ options .with_dot = True
124+ options .with_html_help = True
125+ options .with_uml_look = True
126+ options .open = False
127+ options .silent = True
141128
142129 version = open ('version' ,'rt' ).read ().strip ()
143130 output_dir = '../build/doxygen' # relative to doc/doxyfile location.
@@ -167,10 +154,9 @@ def yesno( bool ):
167154 os .makedirs ( full_output_dir )
168155
169156 do_subst_in_file ( 'doc/doxyfile' , 'doc/doxyfile.in' , subst_keys )
170- ok = run_doxygen ( options .doxygen_path , 'doc/doxyfile' , 'doc' )
171- print open (os .path .join ('doc' , warning_log_path ), 'rb' ).read ()
172- if not ok :
173- print 'Doxygen generation failed'
157+ ok = run_doxygen ( options .doxygen_path , 'doc/doxyfile' , 'doc' , is_silent = options .silent )
158+ if not options .silent :
159+ print open (os .path .join ('doc' , warning_log_path ), 'rb' ).read ()
174160 index_path = os .path .abspath (os .path .join (subst_keys ['%HTML_OUTPUT%' ], 'index.html' ))
175161 print 'Generated documentation can be found in:'
176162 print index_path
@@ -187,5 +173,35 @@ def yesno( bool ):
187173 tarball_basedir = os .path .join ( full_output_dir , html_output_dirname )
188174 make_tarball ( tarball_path , tarball_sources , tarball_basedir , html_output_dirname )
189175
176+ def main ():
177+ usage = """%prog
178+ Generates doxygen documentation in build/doxygen.
179+ Optionaly makes a tarball of the documentation to dist/.
180+
181+ Must be started in the project top directory.
182+ """
183+ from optparse import OptionParser
184+ parser = OptionParser (usage = usage )
185+ parser .allow_interspersed_args = False
186+ parser .add_option ('--with-dot' , dest = "with_dot" , action = 'store_true' , default = False ,
187+ help = """Enable usage of DOT to generate collaboration diagram""" )
188+ parser .add_option ('--dot' , dest = "dot_path" , action = 'store' , default = find_program ('dot' ),
189+ help = """Path to GraphViz dot tool. Must be full qualified path. [Default: %default]""" )
190+ parser .add_option ('--doxygen' , dest = "doxygen_path" , action = 'store' , default = find_program ('doxygen' ),
191+ help = """Path to Doxygen tool. [Default: %default]""" )
192+ parser .add_option ('--with-html-help' , dest = "with_html_help" , action = 'store_true' , default = False ,
193+ help = """Enable generation of Microsoft HTML HELP""" )
194+ parser .add_option ('--no-uml-look' , dest = "with_uml_look" , action = 'store_false' , default = True ,
195+ help = """Generates DOT graph without UML look [Default: False]""" )
196+ parser .add_option ('--open' , dest = "open" , action = 'store_true' , default = False ,
197+ help = """Open the HTML index in the web browser after generation""" )
198+ parser .add_option ('--tarball' , dest = "make_tarball" , action = 'store_true' , default = False ,
199+ help = """Generates a tarball of the documentation in dist/ directory""" )
200+ parser .add_option ('-s' , '--silent' , dest = "silent" , action = 'store_true' , default = False ,
201+ help = """Hides doxygen output""" )
202+ parser .enable_interspersed_args ()
203+ options , args = parser .parse_args ()
204+ build_doc ( options )
205+
190206if __name__ == '__main__' :
191207 main ()
0 commit comments