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

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

Issue 10993029: Extensions Docs Server: Fix headings with no IDs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more descriptive ids Created 8 years, 2 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
« no previous file with comments | « no previous file | chrome/common/extensions/docs/templates/articles/app_architecture.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 """Presubmit script for changes affecting extensions. 5 """Presubmit script for changes affecting extensions.
6 6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into gcl. 8 for more details about the presubmit API built into gcl.
9 """ 9 """
10 import fnmatch 10 import fnmatch
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 if (fnmatch.fnmatch(name, '%s*' % PUBLIC_TEMPLATES_PATH) or 66 if (fnmatch.fnmatch(name, '%s*' % PUBLIC_TEMPLATES_PATH) or
67 fnmatch.fnmatch(name, '%s*' % INTROS_PATH) or 67 fnmatch.fnmatch(name, '%s*' % INTROS_PATH) or
68 fnmatch.fnmatch(name, '%s*' % ARTICLES_PATH)): 68 fnmatch.fnmatch(name, '%s*' % ARTICLES_PATH)):
69 args.extend(_FindMatchingTemplates(name.split(os.sep)[-1], 69 args.extend(_FindMatchingTemplates(name.split(os.sep)[-1],
70 _ListFilesInPublic())) 70 _ListFilesInPublic()))
71 if fnmatch.fnmatch(name, '%s*' % API_PATH): 71 if fnmatch.fnmatch(name, '%s*' % API_PATH):
72 args.extend(_FindMatchingTemplates(_SanitizeAPIName(name, API_PATH), 72 args.extend(_FindMatchingTemplates(_SanitizeAPIName(name, API_PATH),
73 _ListFilesInPublic())) 73 _ListFilesInPublic()))
74 return args 74 return args
75 75
76 def _CheckHeadingIDs(input_api):
77 ids_re = re.compile('<h[23].*id=.*?>')
78 headings_re = re.compile('<h[23].*?>')
79 bad_files = []
80 for name in input_api.AbsoluteLocalPaths():
81 if (fnmatch.fnmatch(name, '*%s*' % INTROS_PATH) or
82 fnmatch.fnmatch(name, '*%s*' % ARTICLES_PATH)):
83 contents = input_api.ReadFile(name)
84 if (len(re.findall(headings_re, contents)) !=
85 len(re.findall(ids_re, contents))):
86 bad_files.append(name)
87 return bad_files
88
76 def _CheckChange(input_api, output_api): 89 def _CheckChange(input_api, output_api):
77 results = [] 90 results = [
91 output_api.PresubmitError('File %s needs an id for each heading.' % name)
92 for name in _CheckHeadingIDs(input_api)]
78 try: 93 try:
79 integration_test = [] 94 integration_test = []
80 # From depot_tools/presubmit_canned_checks.py:529 95 # From depot_tools/presubmit_canned_checks.py:529
81 if input_api.platform == 'win32': 96 if input_api.platform == 'win32':
82 integration_test = [input_api.python_executable] 97 integration_test = [input_api.python_executable]
83 integration_test.append( 98 integration_test.append(
84 os.path.join('docs', 'server2', 'integration_test.py')) 99 os.path.join('docs', 'server2', 'integration_test.py'))
85 integration_test.extend(_CreateIntegrationTestArgs(input_api.LocalPaths())) 100 integration_test.extend(_CreateIntegrationTestArgs(input_api.LocalPaths()))
86 input_api.subprocess.check_call(integration_test, 101 input_api.subprocess.check_call(integration_test,
87 cwd=input_api.PresubmitLocalPath()) 102 cwd=input_api.PresubmitLocalPath())
88 except input_api.subprocess.CalledProcessError: 103 except input_api.subprocess.CalledProcessError:
89 results.append(output_api.PresubmitError('IntegrationTest failed!')) 104 results.append(output_api.PresubmitError('IntegrationTest failed!'))
90 return results 105 return results
91 106
92 def CheckChangeOnUpload(input_api, output_api): 107 def CheckChangeOnUpload(input_api, output_api):
93 return _CheckChange(input_api, output_api) 108 return _CheckChange(input_api, output_api)
94 109
95 def CheckChangeOnCommit(input_api, output_api): 110 def CheckChangeOnCommit(input_api, output_api):
96 return _CheckChange(input_api, output_api) 111 return _CheckChange(input_api, output_api)
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/docs/templates/articles/app_architecture.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698