Remove obsolete entries from .gitignore.
[chromium-blink-merge.git] / components / cronet / tools / generate_javadoc.py
blob2326c724b72555ffd778a3b7f7c1dfa2fb2f3920
1 #!/usr/bin/env python
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
5 # found in the LICENSE file.
7 import fnmatch
8 import optparse
9 import os
10 import sys
12 REPOSITORY_ROOT = os.path.abspath(os.path.join(
13 os.path.dirname(__file__), '..', '..', '..'))
15 sys.path.append(os.path.join(REPOSITORY_ROOT, 'build/android/gyp/util'))
16 sys.path.append(os.path.join(REPOSITORY_ROOT, 'net/tools/net_docs'))
17 import build_utils
18 import net_docs
19 from markdown.postprocessors import Postprocessor
20 from markdown.extensions import Extension
23 class CronetPostprocessor(Postprocessor):
24 def run(self, text):
25 return text.replace('@Override', '@Override')
28 class CronetExtension(Extension):
29 def extendMarkdown(self, md, md_globals):
30 md.postprocessors.add('CronetPostprocessor',
31 CronetPostprocessor(md), '_end')
34 def GenerateJavadoc(options):
35 output_dir = os.path.abspath(os.path.join(options.output_dir, 'javadoc'))
36 working_dir = os.path.join(options.input_dir, 'android/java')
37 overview_file = os.path.abspath(options.overview_file)
39 build_utils.DeleteDirectory(output_dir)
40 build_utils.MakeDirectory(output_dir)
41 javadoc_cmd = ['ant', '-Dsource.dir=src', '-Ddoc.dir=' + output_dir,
42 '-Doverview=' + overview_file, 'doc']
43 build_utils.CheckOutput(javadoc_cmd, cwd=working_dir)
46 def main():
47 parser = optparse.OptionParser()
48 parser.add_option('--output-dir', help='Directory to put javadoc')
49 parser.add_option('--input-dir', help='Root of cronet source')
50 parser.add_option('--overview-file', help='Path of the overview page')
51 parser.add_option('--readme-file', help='Path of the README.md')
53 options, _ = parser.parse_args()
55 net_docs.ProcessDocs([options.readme_file], options.input_dir,
56 options.output_dir, extensions=[CronetExtension()])
58 GenerateJavadoc(options)
60 if __name__ == '__main__':
61 sys.exit(main())