mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
Meta: Disallow links to single-page HTML spec
This commit is contained in:
@@ -19,6 +19,8 @@ parser.add_argument("--overwrite-inplace", action=argparse.BooleanOptionalAction
|
||||
parser.add_argument('filenames', nargs='*')
|
||||
args = parser.parse_args()
|
||||
|
||||
SINGLE_PAGE_HTML_SPEC_LINK = re.compile('//.*https://html\\.spec\\.whatwg\\.org/#')
|
||||
|
||||
|
||||
def find_files_here_or_argv():
|
||||
if args.filenames:
|
||||
@@ -32,11 +34,15 @@ def find_files_here_or_argv():
|
||||
def run():
|
||||
"""Lint WebIDL files checked into git for four leading spaces on each line."""
|
||||
files_without_four_leading_spaces = set()
|
||||
"""Also lint for them not containing any links to the single-page HTML spec."""
|
||||
files_with_single_page_html_spec_link = set()
|
||||
did_fail = False
|
||||
for filename in find_files_here_or_argv():
|
||||
lines = []
|
||||
with open(filename, "r") as f:
|
||||
for line_number, line in enumerate(f, start=1):
|
||||
if SINGLE_PAGE_HTML_SPEC_LINK.search(line):
|
||||
files_with_single_page_html_spec_link.add(filename)
|
||||
if lines_to_skip.match(line):
|
||||
lines.append(line)
|
||||
continue
|
||||
@@ -60,6 +66,11 @@ def run():
|
||||
if not args.overwrite_inplace:
|
||||
print(
|
||||
f"\nTo fix the WebIDL files in place, run: ./Meta/{script_name} --overwrite-inplace")
|
||||
|
||||
if files_with_single_page_html_spec_link:
|
||||
print("\nWebIDL files that have links to the single-page HTML spec:",
|
||||
" ".join(files_with_single_page_html_spec_link))
|
||||
|
||||
if did_fail:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
@@ -54,6 +54,9 @@ LOCAL_INCLUDE_SUFFIX_EXCLUDES = [
|
||||
'.moc',
|
||||
]
|
||||
|
||||
# We check for and disallow any comments linking to the single-page HTML spec because it takes a long time to load.
|
||||
SINGLE_PAGE_HTML_SPEC_LINK = re.compile('//.*https://html\\.spec\\.whatwg\\.org/#')
|
||||
|
||||
|
||||
def should_check_file(filename):
|
||||
if not filename.endswith('.cpp') and not filename.endswith('.h'):
|
||||
@@ -93,6 +96,7 @@ def run():
|
||||
errors_include_weird_format = []
|
||||
errors_include_missing_local = []
|
||||
errors_include_bad_complex = []
|
||||
errors_single_page_html_spec = []
|
||||
|
||||
for filename in find_files_here_or_argv():
|
||||
with open(filename, "r") as f:
|
||||
@@ -140,6 +144,8 @@ def run():
|
||||
print(f"In {filename}: Cannot find {referenced_file}")
|
||||
if filename not in errors_include_missing_local:
|
||||
errors_include_missing_local.append(filename)
|
||||
if SINGLE_PAGE_HTML_SPEC_LINK.search(file_content):
|
||||
errors_single_page_html_spec.append(filename)
|
||||
|
||||
have_errors = False
|
||||
if errors_license:
|
||||
@@ -175,6 +181,12 @@ def run():
|
||||
" ".join(errors_include_bad_complex),
|
||||
)
|
||||
have_errors = True
|
||||
if errors_single_page_html_spec:
|
||||
print(
|
||||
"Files with links to the single-page HTML spec:",
|
||||
" ".join(errors_single_page_html_spec)
|
||||
)
|
||||
have_errors = True
|
||||
|
||||
if have_errors:
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user