You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sa...@apache.org on 2016/06/01 18:31:41 UTC
lucene-solr:branch_5x: LUCENE-7308: checkJavaDocs.py (called from
documentation-lint): checkClassDetails(): reimplement detail item chunking to
align with actual item boundaries, and to test the final item.
Repository: lucene-solr
Updated Branches:
refs/heads/branch_5x 0c27bf76b -> d5f6ccf86
LUCENE-7308: checkJavaDocs.py (called from documentation-lint): checkClassDetails(): reimplement detail item chunking to align with actual item boundaries, and to test the final item.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/d5f6ccf8
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/d5f6ccf8
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/d5f6ccf8
Branch: refs/heads/branch_5x
Commit: d5f6ccf86508617bf0a81afa0b8a2cef7da76bcb
Parents: 0c27bf7
Author: Steve Rowe <sa...@apache.org>
Authored: Wed Jun 1 13:39:07 2016 -0400
Committer: Steve Rowe <sa...@apache.org>
Committed: Wed Jun 1 14:31:22 2016 -0400
----------------------------------------------------------------------
dev-tools/scripts/checkJavaDocs.py | 74 ++++++++++++++++-----------------
1 file changed, 36 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d5f6ccf8/dev-tools/scripts/checkJavaDocs.py
----------------------------------------------------------------------
diff --git a/dev-tools/scripts/checkJavaDocs.py b/dev-tools/scripts/checkJavaDocs.py
index 9af1bb1..ae2b440 100644
--- a/dev-tools/scripts/checkJavaDocs.py
+++ b/dev-tools/scripts/checkJavaDocs.py
@@ -78,7 +78,11 @@ def cleanHTML(s):
reH3 = re.compile('^<h3>(.*?)</h3>', re.IGNORECASE | re.MULTILINE)
reH4 = re.compile('^<h4>(.*?)</h4>', re.IGNORECASE | re.MULTILINE)
-
+reDetailsDiv = re.compile('<div class="details">')
+reEndOfClassData = re.compile('<!--.*END OF CLASS DATA.*-->')
+reBlockList = re.compile('<ul class="blockList(?:Last)?">')
+reCloseUl = re.compile('</ul>')
+
def checkClassDetails(fullPath):
"""
Checks for invalid HTML in the full javadocs under each field/method.
@@ -86,60 +90,54 @@ def checkClassDetails(fullPath):
# TODO: only works with java7 generated javadocs now!
with open(fullPath, encoding='UTF-8') as f:
- desc = None
+ desc = []
cat = None
item = None
errors = []
+ inDetailsDiv = False
+ blockListDepth = 0
for line in f.readlines():
+ # Skip content up until <div class="details">
+ if not inDetailsDiv:
+ if reDetailsDiv.match(line) is not None:
+ inDetailsDiv = True
+ continue
- m = reH3.search(line)
- if m is not None:
- if desc is not None:
- desc = ''.join(desc)
- if True or cat == 'Constructor Detail':
- idx = desc.find('</div>')
- if idx == -1:
- # Ctor missing javadocs ... checkClassSummaries catches it
- desc = None
- continue
- desc = desc[:idx+6]
- else:
- # Have to fake <ul> context because we pulled a fragment out "across" two <ul>s:
- desc = '<ul>%s</ul>' % ''.join(desc)
- #print(' VERIFY %s: %s: %s' % (cat, item, desc))
+ # Stop looking at content at closing details </div>, which is just before <!-- === END OF CLASS DATA === -->
+ if reEndOfClassData.match(line) is not None:
+ if len(desc) != 0:
try:
- verifyHTML(desc)
+ verifyHTML(''.join(desc))
except RuntimeError as re:
#print(' FAILED: %s' % re)
errors.append((cat, item, str(re)))
- desc = None
- cat = m.group(1)
- continue
+ break
- m = reH4.search(line)
- if m is not None:
- if desc is not None:
- # Have to fake <ul> context because we pulled a fragment out "across" two <ul>s:
- if cat == 'Element Detail':
- desc = ''.join(desc)
- idx = desc.find('</dl>')
- if idx != -1:
- desc = desc[:idx+5]
- else:
- desc = '<ul>%s</ul>' % ''.join(desc)
- #print(' VERIFY %s: %s: %s' % (cat, item, desc))
+ # <ul class="blockList(Last)"> is the boundary between items
+ if reBlockList.match(line) is not None:
+ blockListDepth += 1
+ if len(desc) != 0:
try:
- verifyHTML(desc)
+ verifyHTML(''.join(desc))
except RuntimeError as re:
#print(' FAILED: %s' % re)
errors.append((cat, item, str(re)))
- item = m.group(1)
- desc = []
- continue
+ del desc[:]
- if desc is not None:
+ if blockListDepth == 3:
desc.append(line)
+ if reCloseUl.match(line) is not None:
+ blockListDepth -= 1
+ else:
+ m = reH3.search(line)
+ if m is not None:
+ cat = m.group(1)
+ else:
+ m = reH4.search(line)
+ if m is not None:
+ item = m.group(1)
+
if len(errors) != 0:
print()
print(fullPath)