Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: chrome/common/extensions/PRESUBMIT.py

Issue 10885049: Extensions Docs Server: KILL BUILD.PY (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 4
5 import os.path # for initializing constants 5 import os.path # for initializing constants
6 6
7 # Directories that we run presubmit checks on. 7 # Directories that we run presubmit checks on.
8 PRESUBMIT_PATH = os.path.normpath('chrome/common/extensions/PRESUBMIT.py') 8 PRESUBMIT_PATH = os.path.normpath('chrome/common/extensions/PRESUBMIT.py')
9 API_DIR = os.path.normpath('chrome/common/extensions/api') 9 API_DIR = os.path.normpath('chrome/common/extensions/api')
10 DOC_DIR = os.path.normpath('chrome/common/extensions/docs') 10 DOC_DIR = os.path.normpath('chrome/common/extensions/docs')
(...skipping 14 matching lines...) Expand all
25 'This change modifies the extension docs but the generated docs have ' 25 'This change modifies the extension docs but the generated docs have '
26 'not been updated properly. See %s for more info.' % README) 26 'not been updated properly. See %s for more info.' % README)
27 BUILD_SCRIPT = os.path.join(BUILD_DIR, 'build.py') 27 BUILD_SCRIPT = os.path.join(BUILD_DIR, 'build.py')
28 REBUILD_INSTRUCTIONS = ( 28 REBUILD_INSTRUCTIONS = (
29 'First build DumpRenderTree, then update the docs by running:\n %s' 29 'First build DumpRenderTree, then update the docs by running:\n %s'
30 ' --page-name=<apiName>' % 30 ' --page-name=<apiName>' %
31 BUILD_SCRIPT) 31 BUILD_SCRIPT)
32 32
33 33
34 def CheckChangeOnUpload(input_api, output_api): 34 def CheckChangeOnUpload(input_api, output_api):
35 return (CheckPresubmitChanges(input_api, output_api) + 35 return CheckPresubmitChanges(input_api, output_api)
36 CheckDocChanges(input_api, output_api))
37 36
38 def CheckChangeOnCommit(input_api, output_api): 37 def CheckChangeOnCommit(input_api, output_api):
39 return (CheckPresubmitChanges(input_api, output_api) + 38 return CheckPresubmitChanges(input_api, output_api)
40 CheckDocChanges(input_api, output_api, strict=False))
41 39
42 def CheckPresubmitChanges(input_api, output_api): 40 def CheckPresubmitChanges(input_api, output_api):
43 for PRESUBMIT_PATH in input_api.LocalPaths(): 41 for PRESUBMIT_PATH in input_api.LocalPaths():
44 return input_api.canned_checks.RunUnitTests(input_api, output_api, 42 return input_api.canned_checks.RunUnitTests(input_api, output_api,
45 ['./PRESUBMIT_test.py']) 43 ['./PRESUBMIT_test.py'])
46 return [] 44 return []
47 45
48 def CheckDocChanges(input_api, output_api, strict=True):
49 warnings = []
50
51 for af in input_api.AffectedFiles():
52 path = af.LocalPath()
53 if IsSkippedFile(path, input_api):
54 continue
55
56 elif (IsApiFile(path, input_api) or
57 IsBuildFile(path, input_api) or
58 IsTemplateFile(path, input_api) or
59 IsJsFile(path, input_api) or
60 IsCssFile(path, input_api)):
61 # These files do not always cause changes to the generated docs
62 # so we can ignore them if not running strict checks.
63 if strict and not DocsGenerated(input_api):
64 warnings.append('Docs out of sync with %s changes.' % path)
65
66 elif IsStaticDoc(path, input_api):
67 if not StaticDocBuilt(af, input_api):
68 warnings.append('Changes to %s not reflected in generated doc.' % path)
69
70 elif IsSampleFile(path, input_api):
71 if not SampleZipped(af, input_api):
72 warnings.append('Changes to sample %s have not been re-zipped.' % path)
73
74 elif IsGeneratedDoc(path, input_api):
75 if not NonGeneratedFilesEdited(input_api):
76 warnings.append('Changes to generated doc %s not reflected in '
77 'non-generated files.' % path)
78
79 if warnings:
80 warnings.sort()
81 warnings = [' - %s\n' % w for w in warnings]
82 # Prompt user if they want to continue.
83 return [output_api.PresubmitPromptWarning(REBUILD_WARNING + '\n' +
84 ''.join(warnings) +
85 REBUILD_INSTRUCTIONS)]
86 return []
87
88 def IsSkippedFile(path, input_api): 46 def IsSkippedFile(path, input_api):
89 return input_api.os_path.basename(path) in EXCEPTIONS 47 return input_api.os_path.basename(path) in EXCEPTIONS
90 48
91 def IsApiFile(path, input_api): 49 def IsApiFile(path, input_api):
92 return (input_api.os_path.dirname(path) == API_DIR and 50 return (input_api.os_path.dirname(path) == API_DIR and
93 (path.endswith('.json') or path.endswith('.idl'))) 51 (path.endswith('.json') or path.endswith('.idl')))
94 52
95 def IsBuildFile(path, input_api): 53 def IsBuildFile(path, input_api):
96 return input_api.os_path.dirname(path) == BUILD_DIR 54 return input_api.os_path.dirname(path) == BUILD_DIR
97 55
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 """ 92 """
135 return any(IsApiFile(path, input_api) or 93 return any(IsApiFile(path, input_api) or
136 IsBuildFile(path, input_api) or 94 IsBuildFile(path, input_api) or
137 IsTemplateFile(path, input_api) or 95 IsTemplateFile(path, input_api) or
138 IsJsFile(path, input_api) or 96 IsJsFile(path, input_api) or
139 IsCssFile(path, input_api) or 97 IsCssFile(path, input_api) or
140 IsStaticDoc(path, input_api) or 98 IsStaticDoc(path, input_api) or
141 IsSampleFile(path, input_api) 99 IsSampleFile(path, input_api)
142 for path in input_api.LocalPaths()) 100 for path in input_api.LocalPaths())
143 101
144 def StaticDocBuilt(static_file, input_api): 102 def StaticDocBuilt(static_file, input_api):
not at google - send to devlin 2012/08/30 01:49:42 can delete this
cduvall 2012/08/30 02:09:08 Done.
145 """Return True if the generated doc that corresponds to the |static_file| 103 """Return True if the generated doc that corresponds to the |static_file|
146 is also in this change. Both files must also contain matching changes. 104 is also in this change. Both files must also contain matching changes.
147 """ 105 """
148 for subdir in [APPS_DIR, EXTENSIONS_DIR]: 106 for subdir in [APPS_DIR, EXTENSIONS_DIR]:
149 generated_file = _FindFileInAlternateDir(static_file, subdir, input_api) 107 generated_file = _FindFileInAlternateDir(static_file, subdir, input_api)
150 if _ChangesMatch(generated_file, static_file): 108 if _ChangesMatch(generated_file, static_file):
151 return True 109 return True
152 return False 110 return False
153 111
154 def _FindFileInAlternateDir(affected_file, alt_dir, input_api): 112 def _FindFileInAlternateDir(affected_file, alt_dir, input_api):
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 found = True 168 found = True
211 else: 169 else:
212 next_generated += 1 170 next_generated += 1
213 start_pos = 0 171 start_pos = 0
214 172
215 if not found: 173 if not found:
216 return False 174 return False
217 175
218 return True 176 return True
219 177
220 def SampleZipped(sample_file, input_api): 178 def SampleZipped(sample_file, input_api):
not at google - send to devlin 2012/08/30 01:49:42 can delete this actually basically everythign in
cduvall 2012/08/30 02:09:08 It is gone.
221 """Return True if the zipfile that should contain |sample_file| is in 179 """Return True if the zipfile that should contain |sample_file| is in
222 this change. 180 this change.
223 """ 181 """
224 sample_path = sample_file.LocalPath() 182 sample_path = sample_file.LocalPath()
225 for af in input_api.AffectedFiles(): 183 for af in input_api.AffectedFiles():
226 root, ext = input_api.os_path.splitext(af.LocalPath()) 184 root, ext = input_api.os_path.splitext(af.LocalPath())
227 if ext == '.zip' and sample_path.startswith(root): 185 if ext == '.zip' and sample_path.startswith(root):
228 return True 186 return True
229 return False 187 return False
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/PRESUBMIT_test.py » ('j') | chrome/common/extensions/docs/build/build.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698