| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2015 The Chromium Authors. All rights reserved. | 3 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 import fnmatch | 7 import fnmatch |
| 8 import optparse | 8 import optparse |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 class CronetExtension(Extension): | 28 class CronetExtension(Extension): |
| 29 def extendMarkdown(self, md, md_globals): | 29 def extendMarkdown(self, md, md_globals): |
| 30 md.postprocessors.add('CronetPostprocessor', | 30 md.postprocessors.add('CronetPostprocessor', |
| 31 CronetPostprocessor(md), '_end') | 31 CronetPostprocessor(md), '_end') |
| 32 | 32 |
| 33 | 33 |
| 34 def GenerateJavadoc(options): | 34 def GenerateJavadoc(options): |
| 35 output_dir = os.path.abspath(os.path.join(options.output_dir, 'javadoc')) | 35 output_dir = os.path.abspath(os.path.join(options.output_dir, 'javadoc')) |
| 36 working_dir = os.path.join(options.input_dir, 'android/api') | 36 working_dir = os.path.join(options.input_dir, 'android/api') |
| 37 overview_file = os.path.abspath(options.overview_file) | 37 overview_file = os.path.abspath(options.overview_file) |
| 38 lib_java_dir = os.path.abspath(options.lib_java_dir) |
| 38 | 39 |
| 39 build_utils.DeleteDirectory(output_dir) | 40 build_utils.DeleteDirectory(output_dir) |
| 40 build_utils.MakeDirectory(output_dir) | 41 build_utils.MakeDirectory(output_dir) |
| 41 javadoc_cmd = ['ant', '-Dsource.dir=src', '-Ddoc.dir=' + output_dir, | 42 javadoc_cmd = ['ant', '-Dsource.dir=src', '-Ddoc.dir=' + output_dir, |
| 42 '-Doverview=' + overview_file, 'doc'] | 43 '-Dlib.java.dir=' + lib_java_dir, '-Doverview=' + overview_file, |
| 44 'doc'] |
| 43 stdout = build_utils.CheckOutput(javadoc_cmd, cwd=working_dir) | 45 stdout = build_utils.CheckOutput(javadoc_cmd, cwd=working_dir) |
| 44 if " error: " in stdout or "warning" in stdout: | 46 if " error: " in stdout or "warning" in stdout: |
| 45 build_utils.DeleteDirectory(output_dir) | 47 build_utils.DeleteDirectory(output_dir) |
| 46 raise build_utils.CalledProcessError(working_dir, javadoc_cmd, stdout) | 48 raise build_utils.CalledProcessError(working_dir, javadoc_cmd, stdout) |
| 47 | 49 |
| 48 | 50 |
| 49 def main(): | 51 def main(): |
| 50 parser = optparse.OptionParser() | 52 parser = optparse.OptionParser() |
| 51 build_utils.AddDepfileOption(parser) | 53 build_utils.AddDepfileOption(parser) |
| 52 parser.add_option('--output-dir', help='Directory to put javadoc') | 54 parser.add_option('--output-dir', help='Directory to put javadoc') |
| 53 parser.add_option('--input-dir', help='Root of cronet source') | 55 parser.add_option('--input-dir', help='Root of cronet source') |
| 54 parser.add_option('--overview-file', help='Path of the overview page') | 56 parser.add_option('--overview-file', help='Path of the overview page') |
| 55 parser.add_option('--readme-file', help='Path of the README.md') | 57 parser.add_option('--readme-file', help='Path of the README.md') |
| 58 parser.add_option('--lib-java-dir', help='Directory containing java libs') |
| 56 | 59 |
| 57 options, _ = parser.parse_args() | 60 options, _ = parser.parse_args() |
| 58 | 61 |
| 59 net_docs.ProcessDocs([options.readme_file], options.input_dir, | 62 net_docs.ProcessDocs([options.readme_file], options.input_dir, |
| 60 options.output_dir, extensions=[CronetExtension()]) | 63 options.output_dir, extensions=[CronetExtension()]) |
| 61 | 64 |
| 62 GenerateJavadoc(options) | 65 GenerateJavadoc(options) |
| 63 | 66 |
| 64 if options.depfile: | 67 if options.depfile: |
| 65 input_paths = [] | 68 input_paths = [] |
| 66 for root, _, filenames in os.walk(options.input_dir): | 69 for root, _, filenames in os.walk(options.input_dir): |
| 67 input_paths.extend(os.path.join(root, f) for f in filenames) | 70 input_paths.extend(os.path.join(root, f) for f in filenames) |
| 68 build_utils.WriteDepfile(options.depfile, | 71 build_utils.WriteDepfile(options.depfile, |
| 69 input_paths + build_utils.GetPythonDependencies()) | 72 input_paths + build_utils.GetPythonDependencies()) |
| 70 | 73 |
| 71 if __name__ == '__main__': | 74 if __name__ == '__main__': |
| 72 sys.exit(main()) | 75 sys.exit(main()) |
| OLD | NEW |