lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sar...@apache.org
Subject lucene-solr:branch_5_5: 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.
Date Wed, 01 Jun 2016 18:32:09 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_5_5 8cf52135d -> c2947a7e6


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/c2947a7e
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/c2947a7e
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/c2947a7e

Branch: refs/heads/branch_5_5
Commit: c2947a7e6051432c5ec23d843392bc76b74beff3
Parents: 8cf5213
Author: Steve Rowe <sarowe@apache.org>
Authored: Wed Jun 1 13:39:07 2016 -0400
Committer: Steve Rowe <sarowe@apache.org>
Committed: Wed Jun 1 14:31:59 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/c2947a7e/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)


Mime
View raw message