| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 import logging | 4 import logging |
| 5 import optparse | 5 import optparse |
| 6 import os | 6 import os |
| 7 import pkgutil | 7 import pkgutil |
| 8 import pydoc | 8 import pydoc |
| 9 import re | 9 import re |
| 10 import sys | 10 import sys |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 modules = [] | 90 modules = [] |
| 91 for dirname, _, filenames in os.walk(docs_dir): | 91 for dirname, _, filenames in os.walk(docs_dir): |
| 92 for filename in filenames: | 92 for filename in filenames: |
| 93 path = os.path.join(dirname, filename) | 93 path = os.path.join(dirname, filename) |
| 94 modules.append(AlreadyDocumentedModule(path)) | 94 modules.append(AlreadyDocumentedModule(path)) |
| 95 return modules | 95 return modules |
| 96 | 96 |
| 97 | 97 |
| 98 def IsUpdateDocsNeeded(): | 98 def IsUpdateDocsNeeded(): |
| 99 already_documented_modules = GetAlreadyDocumentedModules() | 99 already_documented_modules = GetAlreadyDocumentedModules() |
| 100 already_documented_modules_by_name = dict( | 100 already_documented_modules_by_name = dict(\ |
| 101 (module.name, module) for module in already_documented_modules) | 101 (module.name, module) for module in already_documented_modules) |
| 102 current_modules = GetAllModulesToDocument(telemetry) | 102 current_modules = GetAllModulesToDocument(telemetry) |
| 103 | 103 |
| 104 # Quick check: if the names of modules has changed, we definitely need | 104 # Quick check: if the names of modules has changed, we definitely need |
| 105 # an update. | 105 # an update. |
| 106 already_documented_module_names = set( | 106 already_documented_module_names = set(\ |
| 107 m.name for m in already_documented_modules) | 107 m.name for m in already_documented_modules) |
| 108 | 108 |
| 109 current_module_names = set([m.__name__ for m in current_modules]) | 109 current_module_names = set([m.__name__ for m in current_modules]) |
| 110 | 110 |
| 111 if current_module_names != already_documented_module_names: | 111 if current_module_names != already_documented_module_names: |
| 112 return True | 112 return True |
| 113 | 113 |
| 114 # Generate the new docs and compare aganist the old. If changed, then a | 114 # Generate the new docs and compare aganist the old. If changed, then a |
| 115 # an update is needed. | 115 # an update is needed. |
| 116 for current_module in current_modules: | 116 for current_module in current_modules:\ |
| 117 already_documented_module = already_documented_modules_by_name[ | 117 already_documented_module = already_documented_modules_by_name[\ |
| 118 current_module.__name__] | 118 current_module.__name__] |
| 119 current_html = GenerateHTMLForModule(current_module) | 119 current_html = GenerateHTMLForModule(current_module) |
| 120 if current_html != already_documented_module.contents: | 120 if current_html != already_documented_module.contents: |
| 121 return True | 121 return True |
| 122 | 122 |
| 123 return False | 123 return False |
| 124 | 124 |
| 125 def Main(args): | 125 def Main(args): |
| 126 parser = optparse.OptionParser() | 126 parser = optparse.OptionParser() |
| 127 parser.add_option( | 127 parser.add_option( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 139 | 139 |
| 140 RemoveAllDocs() | 140 RemoveAllDocs() |
| 141 | 141 |
| 142 old_cwd = os.getcwd() | 142 old_cwd = os.getcwd() |
| 143 try: | 143 try: |
| 144 os.chdir(telemetry_dir) | 144 os.chdir(telemetry_dir) |
| 145 for module in GetAllModulesToDocument(telemetry): | 145 for module in GetAllModulesToDocument(telemetry): |
| 146 WriteHTMLForModule(module) | 146 WriteHTMLForModule(module) |
| 147 finally: | 147 finally: |
| 148 os.chdir(old_cwd) | 148 os.chdir(old_cwd) |
| OLD | NEW |