Index: dev-tools/scripts/checkJavaDocs.py =================================================================== --- dev-tools/scripts/checkJavaDocs.py (revision 1377897) +++ dev-tools/scripts/checkJavaDocs.py (working copy) @@ -20,7 +20,79 @@ reHREF = re.compile('(.*?)', re.IGNORECASE) reMarkup = re.compile('<.*?>') +reDivBlock = re.compile('
(.*?)
', re.IGNORECASE) +reCaption = re.compile('(.*?)', re.IGNORECASE) +reTDLast = re.compile('(.*?)$', re.IGNORECASE) +reColOne = re.compile('(.*?)', re.IGNORECASE) +def cleanHTML(s): + s = reMarkup.sub('', s) + s = s.replace(' ', ' ') + s = s.replace('<', '<') + s = s.replace('>', '>') + s = s.replace('&', '&') + return s.strip() + +def checkClass(fullPath): + f = open(fullPath, encoding='UTF-8') + anyMissing = False + + printed = False + inThing = False + lastCaption = None + lastItem = None + + desc = None + + for line in f.readlines(): + m = reCaption.search(line) + if m is not None: + lastCaption = m.group(1) + #print(' caption %s' % lastCaption) + m = reTDLast.search(line) + if m is not None: + lastItem = cleanHTML(m.group(1)) + #print(' item %s' % lastItem) + else: + m = reColOne.search(line) + if m is not None: + lastItem = cleanHTML(m.group(1)) + #print(' item %s' % lastItem) + + lineLower = line.strip().lower() + + if lineLower.find('') != -1: + desc = [] + if desc is not None: + desc.append(line) + if line.find('') != -1: + desc = ''.join(desc) + desc = desc.replace('
', '') + desc = desc.replace('
', '') + desc = desc.strip() + #print(' desc %s' % desc) + hasDesc = len(desc) > 0 + desc = None + f.close() + return anyMissing + def checkSummary(fullPath): printed = False f = open(fullPath, encoding='UTF-8') @@ -32,7 +104,16 @@ lineLower = line.strip().lower() if desc is not None: # TODO: also detect missing description in overview-summary - if lineLower.startswith('package ') or lineLower.startswith('

see: '): @@ -84,8 +165,8 @@ True if there are problems. """ - if level != 'class' and level != 'package': - print('unsupported level: %s, must be "class" or "package"' % level) + if level != 'class' and level != 'package' and level != 'method': + print('unsupported level: %s, must be "class" or "package" or "method"' % level) sys.exit(1) #for dirPath, dirNames, fileNames in os.walk('%s/lucene/build/docs/api' % root): @@ -100,7 +181,7 @@ anyMissing = False for dirPath, dirNames, fileNames in os.walk(root): - + if dirPath.find('/all/') != -1: # These are dups (this is a bit risk, eg, root IS this /all/ directory..) continue @@ -108,6 +189,12 @@ if 'package-summary.html' in fileNames: if level != 'package' and checkSummary('%s/package-summary.html' % dirPath): anyMissing = True + if level == 'method': + for fileName in fileNames: + fullPath = '%s/%s' % (dirPath, fileName) + if not fileName.startswith('package-') and fileName.endswith('.html') and os.path.isfile(fullPath): + if checkClass(fullPath): + anyMissing = True if 'overview-summary.html' in fileNames: if checkSummary('%s/overview-summary.html' % dirPath): anyMissing = True @@ -116,7 +203,7 @@ if __name__ == '__main__': if len(sys.argv) < 2 or len(sys.argv) > 3: - print('usage: %s [class|package]' % sys.argv[0]) + print('usage: %s [class|package|method]' % sys.argv[0]) sys.exit(1) if len(sys.argv) == 2: level = 'class'