• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env vpython
2# Copyright 2017 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
6import logging
7import os
8import sys
9
10_DEVIL_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
11_DEVIL_URL = ('https://chromium.googlesource.com/catapult.git/+/HEAD/devil/')
12
13sys.path.append(_DEVIL_PATH)
14from devil.utils import cmd_helper
15
16_FILES_TO_DOC = {
17    'devil/android/sdk/adb_wrapper.py': 'docs/adb_wrapper.md',
18    'devil/android/device_utils.py': 'docs/device_utils.md',
19    'devil/utils/markdown.py': 'docs/markdown.md',
20}
21
22_MARKDOWN_SCRIPT = os.path.join(_DEVIL_PATH, 'devil', 'utils', 'markdown.py')
23
24
25def main():
26  failed = False
27  for k, v in _FILES_TO_DOC.iteritems():
28    module_path = os.path.join(_DEVIL_PATH, k)
29    module_link = _DEVIL_URL + k
30    doc_path = os.path.join(_DEVIL_PATH, v)
31
32    status, stdout = cmd_helper.GetCmdStatusAndOutput([
33        sys.executable, _MARKDOWN_SCRIPT, module_path, '--module-link',
34        module_link
35    ])
36    if status:
37      logging.error('Failed to update doc for %s' % module_path)
38      failed = True
39    else:
40      with open(doc_path, 'w') as doc_file:
41        doc_file.write(stdout)
42
43  return 1 if failed else 0
44
45
46if __name__ == '__main__':
47  sys.exit(main())
48