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:30:58 UTC

lucene-solr:branch_6_0: 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_6_0 160abcaea -> 895aff622


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

Branch: refs/heads/branch_6_0
Commit: 895aff6226758da8a50cc8be1cadb5ee0601ad06
Parents: 160abca
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 13:43:02 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/895aff62/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)