| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 """Generate Doxygen documentation.""" | |
| 7 | |
| 8 import datetime | |
| 9 import os | |
| 10 import shutil | |
| 11 import sys | |
| 12 | |
| 13 from build_step import BuildStep | |
| 14 from utils import file_utils | |
| 15 from py.utils import shell_utils | |
| 16 | |
| 17 DOXYFILE_BASENAME = 'Doxyfile' # must match name of Doxyfile in skia root | |
| 18 DOXYGEN_BINARY = 'doxygen' | |
| 19 DOXYGEN_CONFIG_DIR = os.path.join(os.pardir, os.pardir, 'doxygen-config') | |
| 20 DOXYGEN_WORKING_DIR = os.path.join(os.pardir, os.pardir, 'doxygen') | |
| 21 | |
| 22 IFRAME_FOOTER_TEMPLATE = """ | |
| 23 <html><body><address style="text-align: right;"><small> | |
| 24 Generated at %s for skia | |
| 25 by <a href="http://www.doxygen.org/index.html">doxygen</a> | |
| 26 %s </small></address></body></html> | |
| 27 """ | |
| 28 | |
| 29 | |
| 30 class GenerateDoxygen(BuildStep): | |
| 31 def _Run(self): | |
| 32 # Create empty dir and add static_footer.txt | |
| 33 file_utils.create_clean_local_dir(DOXYGEN_WORKING_DIR) | |
| 34 static_footer_path = os.path.join(DOXYGEN_WORKING_DIR, 'static_footer.txt') | |
| 35 shutil.copyfile(os.path.join('tools', 'doxygen_footer.txt'), | |
| 36 static_footer_path) | |
| 37 | |
| 38 # Make copy of doxygen config file, overriding any necessary configs, | |
| 39 # and run doxygen. | |
| 40 file_utils.create_clean_local_dir(DOXYGEN_CONFIG_DIR) | |
| 41 modified_doxyfile = os.path.join(DOXYGEN_CONFIG_DIR, DOXYFILE_BASENAME) | |
| 42 with open(DOXYFILE_BASENAME, 'r') as reader: | |
| 43 with open(modified_doxyfile, 'w') as writer: | |
| 44 shutil.copyfileobj(reader, writer) | |
| 45 writer.write('OUTPUT_DIRECTORY = %s\n' % DOXYGEN_WORKING_DIR) | |
| 46 writer.write('HTML_FOOTER = %s\n' % static_footer_path) | |
| 47 shell_utils.run([DOXYGEN_BINARY, modified_doxyfile]) | |
| 48 | |
| 49 # Create iframe_footer.html | |
| 50 with open(os.path.join(DOXYGEN_WORKING_DIR, 'iframe_footer.html'), | |
| 51 'w') as fh: | |
| 52 fh.write(IFRAME_FOOTER_TEMPLATE % ( | |
| 53 datetime.datetime.now().isoformat(' '), | |
| 54 shell_utils.run([DOXYGEN_BINARY, '--version']))) | |
| 55 | |
| 56 | |
| 57 if '__main__' == __name__: | |
| 58 sys.exit(BuildStep.RunBuildStep(GenerateDoxygen)) | |
| OLD | NEW |