Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve checkJavadocLinks.py to detect "invalid reference" #14287

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions gradle/documentation/check-broken-links/checkJavadocLinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ def __init__(self, baseURL):
self.printed = False

def handle_starttag(self, tag, attrs):
# look for explicit broken link
if tag == 'details':
for attName, attValue in attrs:
if attName == 'class' and attValue == 'invalid-tag':
raise RuntimeError('javadoc generated an invalid-tag')

# NOTE: I don't think 'a' should be in here. But try debugging
# NumericRangeQuery.html. (Could be javadocs bug, it's a generic type...)
if tag not in ('link', 'meta', 'frame', 'br', 'wbr', 'hr', 'p', 'li', 'img', 'col', 'a', 'dt', 'dd', 'input'):
Expand Down Expand Up @@ -108,7 +114,7 @@ def parse(baseURL, html):
try:
parser.feed(html)
parser.close()
except:
except Exception:
# TODO: Python's html.parser is now always lenient, which is no good for us: we want correct HTML in our javadocs
parser.printFile()
print(' WARNING: failed to parse %s:' % baseURL)
Expand Down Expand Up @@ -140,7 +146,7 @@ def checkAll(dirName):
else:
iter = os.walk(dirName)

for root, dirs, files in iter:
for root, _, files in iter:
for f in files:
main, ext = os.path.splitext(f)
ext = ext.lower()
Expand All @@ -162,7 +168,7 @@ def checkAll(dirName):
# ... then verify:
print()
print('Verify...')
for fullPath, (links, anchors) in allFiles.items():
for fullPath, (links, _) in allFiles.items():
#print fullPath
printed = False
for link in links:
Expand Down