fix missing javadocs checker to work with Java 1.8 generated javadocs too

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1657805 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2015-02-06 13:37:07 +00:00
parent c5899ae960
commit 68b6d00cba
4 changed files with 32 additions and 19 deletions

View File

@ -22,9 +22,11 @@ reHREF = re.compile('<a.*?>(.*?)</a>', re.IGNORECASE)
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()

View File

@ -117,7 +117,8 @@ import org.apache.lucene.util.fst.Util.TopResults;
*
* @lucene.experimental
*/
public class AnalyzingSuggester extends Lookup {
// redundant 'implements Accountable' to workaround javadocs bugs
public class AnalyzingSuggester extends Lookup implements Accountable {
/**
* FST&lt;Weight,Surface&gt;:

View File

@ -110,7 +110,8 @@ import org.apache.lucene.util.fst.Util.TopResults;
*
* @lucene.experimental
*/
public class FreeTextSuggester extends Lookup {
// redundant 'implements Accountable' to workaround javadocs bugs
public class FreeTextSuggester extends Lookup implements Accountable {
/** Codec name used in the header for the saved model. */
public final static String CODEC_NAME = "freetextsuggest";

View File

@ -60,7 +60,8 @@ import org.apache.lucene.util.fst.Util.TopResults;
*
* @lucene.experimental
*/
public class WFSTCompletionLookup extends Lookup {
// redundant 'implements Accountable' to workaround javadocs bugs
public class WFSTCompletionLookup extends Lookup implements Accountable {
/**
* FST<Long>, weights are encoded as costs: (Integer.MAX_VALUE-weight)