| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 # Traverses apidoc and dartdoc and lists all possible input files that are | 6 # Traverses apidoc and dartdoc and lists all possible input files that are |
| 7 # used when building API documentation. Used by gyp to determine when apidocs | 7 # used when building API documentation. Used by gyp to determine when apidocs |
| 8 # need to be regenerated (see `apidoc.gyp`). | 8 # need to be regenerated (see `apidoc.gyp`). |
| 9 | 9 |
| 10 # TODO(rnystrom): Port this to dart. It can be run before dart has been built | 10 # TODO(rnystrom): Port this to dart. It can be run before dart has been built |
| 11 # (which is when this script is invoked by gyp) by using the prebuild dart in | 11 # (which is when this script is invoked by gyp) by using the prebuild dart in |
| 12 # tools/testing/bin. | 12 # tools/testing/bin. |
| 13 | 13 |
| 14 import os | 14 import os |
| 15 import sys | 15 import sys |
| 16 | 16 |
| 17 def handle_walk(root, directories, files, start): |
| 18 for filename in files: |
| 19 if filename.endswith(( |
| 20 '.css', '.dart', '.ico', '.js', '.json', '.png', '.sh', '.txt')): |
| 21 print os.path.relpath(os.path.join(root, filename), start=start) |
| 22 |
| 23 |
| 17 def main(argv): | 24 def main(argv): |
| 18 if len(argv) == 1: | 25 if len(argv) == 1: |
| 19 dir = os.curdir | 26 dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), |
| 27 os.pardir, os.pardir, os.pardir) |
| 20 else: | 28 else: |
| 21 dir = argv[1] | 29 dir = argv[1] |
| 22 for root, directories, files in os.walk(dir): | 30 start = os.path.join(dir, 'utils', 'apidoc') |
| 23 if root == os.curdir: | 31 for root, directories, files in os.walk(os.path.join(dir, 'utils', 'apidoc')): |
| 24 directories[0:] = [ | 32 handle_walk(root, directories, files, start) |
| 25 os.path.join('utils', 'apidoc'), | 33 for root, directories, files in os.walk(os.path.join(dir, 'lib', 'dartdoc')): |
| 26 os.path.join('lib', 'dartdoc') | 34 handle_walk(root, directories, files, start) |
| 27 ] | |
| 28 | |
| 29 for filename in files: | |
| 30 if filename.endswith(( | |
| 31 '.css', '.dart', '.ico', '.js', '.json', '.png', '.sh', '.txt')): | |
| 32 print os.path.relpath(os.path.join(root, filename)) | |
| 33 | 35 |
| 34 if __name__ == '__main__': | 36 if __name__ == '__main__': |
| 35 sys.exit(main(sys.argv)) | 37 sys.exit(main(sys.argv)) |
| OLD | NEW |