You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/02/06 13:48:06 UTC

svn commit: r1657791 - /lucene/dev/branches/branch_5x/dev-tools/scripts/checkJavaDocs.py

Author: mikemccand
Date: Fri Feb  6 12:48:06 2015
New Revision: 1657791

URL: http://svn.apache.org/r1657791
Log:
fix missing javadocs checker to work with Java 1.8 generated javadocs too

Modified:
    lucene/dev/branches/branch_5x/dev-tools/scripts/checkJavaDocs.py

Modified: lucene/dev/branches/branch_5x/dev-tools/scripts/checkJavaDocs.py
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/dev-tools/scripts/checkJavaDocs.py?rev=1657791&r1=1657790&r2=1657791&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/dev-tools/scripts/checkJavaDocs.py (original)
+++ lucene/dev/branches/branch_5x/dev-tools/scripts/checkJavaDocs.py Fri Feb  6 12:48:06 2015
@@ -22,9 +22,11 @@ reHREF = re.compile('<a.*?>(.*?)</a>', r
 reMarkup = re.compile('<.*?>')
 reDivBlock = re.compile('<div class="block">(.*?)</div>', re.IGNORECASE)
 reCaption = re.compile('<caption><span>(.*?)</span>', re.IGNORECASE)
+reJ8Caption = re.compile('<h3>(.*?) Summary</h3>')
 reTDLastNested = re.compile('^<td class="colLast"><code><strong><a href="[^>]*\.([^>]*?)\.html" title="class in[^>]*">', re.IGNORECASE)
 reTDLast = re.compile('^<td class="colLast"><code><strong><a href="[^>]*#([^>]*?)">', re.IGNORECASE)
 reColOne = re.compile('^<td class="colOne"><code><strong><a href="[^>]*#([^>]*?)">', re.IGNORECASE)
+reMemberNameLink = re.compile('^<td class="colLast"><code><span class="memberNameLink"><a href="[^>]*#([^>]*?)">', re.IGNORECASE)
 
 # the Method detail section at the end
 reMethodDetail = re.compile('^<h3>Method Detail</h3>$', re.IGNORECASE)
@@ -146,6 +148,7 @@ def checkClassDetails(fullPath):
     return False
 
 def checkClassSummaries(fullPath):
+  #print("check %s" % fullPath)
 
   # TODO: only works with java7 generated javadocs now!
   f = open(fullPath, encoding='UTF-8')
@@ -167,6 +170,7 @@ def checkClassSummaries(fullPath):
     lineCount += 1
     if m is not None:
       foundMethodDetail = True
+      #print('  got method detail')
       continue
 
     # prune methods that are just @Overrides of other interface/classes,
@@ -177,8 +181,9 @@ def checkClassSummaries(fullPath):
       if m is not None:
         lastMethodAnchor = m.group(1)
         continue
-      m = reMethodOverridden.search(line)
-      if m is not None and ('Methods', lastMethodAnchor) in missing:
+      isOverrides = '>Overrides:<' in line or '>Specified by:<' in line
+      #print('check for removing @overridden method: %s; %s; %s' % (lastMethodAnchor, isOverrides, missing))
+      if isOverrides and ('Methods', lastMethodAnchor) in missing:
         #print('removing @overridden method: %s' % lastMethodAnchor)
         missing.remove(('Methods', lastMethodAnchor))
 
@@ -186,36 +191,40 @@ def checkClassSummaries(fullPath):
     if m is not None:
       lastCaption = m.group(1)
       #print('    caption %s' % lastCaption)
-    m = reTDLastNested.search(line)
-    if m is not None:
-      # nested classes
-      lastItem = m.group(1)
-      #print('      item %s' % lastItem)
     else:
-      m = reTDLast.search(line)
+      m = reJ8Caption.search(line)
+      if m is not None:
+        lastCaption = m.group(1)
+        if not lastCaption.endswith('s'):
+          lastCaption += 's'
+        #print('    caption %s' % lastCaption)
+
+    # Try to find the item in question (method/member name):
+    for matcher in (reTDLastNested, # nested classes
+                    reTDLast, # methods etc.
+                    reColOne, # ctors etc.
+                    reMemberNameLink): # java 8
+      m = matcher.search(line)
       if m is not None:
-        # methods etc
         lastItem = m.group(1)
-      else:
-        # ctors etc
-        m = reColOne.search(line)
-        if m is not None:
-          lastItem = m.group(1)
-          #print('      item %s' % lastItem)
+        #print('  found item %s; inThing=%s' % (lastItem, inThing))
+        break
 
     lineLower = line.strip().lower()
 
-    if lineLower.find('<tr class="') != -1:
+    if lineLower.find('<tr class="') != -1 or lineLower.find('<tr id="') != -1:
       inThing = True
       hasDesc = False
       continue
 
     if inThing:
       if lineLower.find('</tr>') != -1:
+        #print('  end item %s; hasDesc %s' % (lastItem, hasDesc))
         if not hasDesc:
           if lastItem is None:
             raise RuntimeError('failed to locate javadoc item in %s, line %d? last line: %s' % (fullPath, lineCount, line.rstrip()))
           missing.append((lastCaption, unEscapeURL(lastItem)))
+          #print('    add missing; now %d: %s' % (len(missing), str(missing)))
         inThing = False
         continue
       else:
@@ -236,6 +245,7 @@ def checkClassSummaries(fullPath):
             desc = desc.replace('</div>', '')
             desc = desc.strip()
             hasDesc = len(desc) > 0
+            #print('   thing %s: %s' % (lastItem, desc))
 
             desc = None
   f.close()