mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 17:44:56 +09:00
Meta: Disallow links to single-page HTML spec
This commit is contained in:
parent
86c5bde83f
commit
9b8120d8e8
Notes:
github-actions[bot]
2025-02-05 23:05:51 +00:00
Author: https://github.com/Psychpsyo
Commit: 9b8120d8e8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3454
Reviewed-by: https://github.com/tcl3 ✅
46 changed files with 88 additions and 65 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue