1#!/usr/bin/env python 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 os 7import sys 8 9_DEVIL_PATH = os.path.abspath(os.path.join( 10 os.path.dirname(__file__), '..')) 11_DEVIL_URL = ( 12 'https://github.com/catapult-project/catapult/blob/master/devil/') 13 14sys.path.append(_DEVIL_PATH) 15from devil.utils import cmd_helper 16 17_FILES_TO_DOC = { 18 'devil/android/sdk/adb_wrapper.py': 'docs/adb_wrapper.md', 19 'devil/android/device_utils.py': 'docs/device_utils.md', 20 'devil/utils/markdown.py': 'docs/markdown.md', 21} 22 23_MARKDOWN_SCRIPT = os.path.join(_DEVIL_PATH, 'devil', 'utils', 'markdown.py') 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, 34 '--module-link', module_link]) 35 if status: 36 logging.error('Failed to update doc for %s' % module_path) 37 failed = True 38 else: 39 with open(doc_path, 'w') as doc_file: 40 doc_file.write(stdout) 41 42 return 1 if failed else 0 43 44if __name__ == '__main__': 45 sys.exit(main()) 46