Index: chrome/common/extensions/PRESUBMIT.py |
diff --git a/chrome/common/extensions/PRESUBMIT.py b/chrome/common/extensions/PRESUBMIT.py |
index 2a8f7bc2fa2f947752b97f63aa0dbfe5e9c13d09..e4a2f7e06448e37a51a894301f39e6d5273b0844 100644 |
--- a/chrome/common/extensions/PRESUBMIT.py |
+++ b/chrome/common/extensions/PRESUBMIT.py |
@@ -73,8 +73,23 @@ def _CreateIntegrationTestArgs(affected_files): |
_ListFilesInPublic())) |
return args |
+def _CheckHeadingIDs(input_api): |
+ ids_re = re.compile('<h[23].*id=.*?>') |
+ headings_re = re.compile('<h[23].*?>') |
+ bad_files = [] |
+ for name in input_api.AbsoluteLocalPaths(): |
+ if (fnmatch.fnmatch(name, '*%s*' % INTROS_PATH) or |
+ fnmatch.fnmatch(name, '*%s*' % ARTICLES_PATH)): |
+ contents = input_api.ReadFile(name) |
+ if (len(re.findall(headings_re, contents)) != |
+ len(re.findall(ids_re, contents))): |
+ bad_files.append(name) |
+ return bad_files |
+ |
def _CheckChange(input_api, output_api): |
- results = [] |
+ results = [ |
+ output_api.PresubmitError('File %s needs an id for each heading.' % name) |
+ for name in _CheckHeadingIDs(input_api)] |
try: |
integration_test = [] |
# From depot_tools/presubmit_canned_checks.py:529 |