added "whitelist" capability to the documentation check script
This commit is contained in:
@@ -16,17 +16,60 @@ opencv_hdr_list = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
opencv_module_list = [
|
opencv_module_list = [
|
||||||
#"core",
|
"core",
|
||||||
#"imgproc",
|
"imgproc",
|
||||||
#"calib3d",
|
"calib3d",
|
||||||
#"features2d",
|
"features2d",
|
||||||
#"video",
|
"video",
|
||||||
#"objdetect",
|
"objdetect",
|
||||||
#"highgui",
|
"highgui",
|
||||||
"ml"
|
"ml"
|
||||||
]
|
]
|
||||||
|
|
||||||
class RSTParser(object):
|
class RSTParser(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.read_whitelist()
|
||||||
|
|
||||||
|
# reads the file containing functions and classes that do not need to be documented
|
||||||
|
def read_whitelist(self):
|
||||||
|
self.whitelist = {}
|
||||||
|
try:
|
||||||
|
wf = open("check_docs_whitelist.txt", "rt")
|
||||||
|
except IOError:
|
||||||
|
return
|
||||||
|
self.parser = hp.CppHeaderParser()
|
||||||
|
|
||||||
|
for l in wf.readlines():
|
||||||
|
cpos = l.find("#")
|
||||||
|
if cpos >= 0:
|
||||||
|
l = l[:cpos]
|
||||||
|
l = l.strip()
|
||||||
|
if not l:
|
||||||
|
continue
|
||||||
|
rst_decl = None
|
||||||
|
if "(" in l:
|
||||||
|
rst_decl = self.parser.parse_func_decl_no_wrap(l)
|
||||||
|
fname = rst_decl[0]
|
||||||
|
else:
|
||||||
|
fname = l.replace("::", ".")
|
||||||
|
complist = fname.split(".")
|
||||||
|
prefix = ""
|
||||||
|
alreadyListed = False
|
||||||
|
wl = []
|
||||||
|
for c in complist:
|
||||||
|
prefix = (prefix + "." + c).lstrip(".")
|
||||||
|
wl = self.whitelist.get(prefix, [])
|
||||||
|
if wl == "*":
|
||||||
|
break
|
||||||
|
if wl == "*":
|
||||||
|
continue
|
||||||
|
if not rst_decl:
|
||||||
|
self.whitelist[fname] = "*"
|
||||||
|
else:
|
||||||
|
wl.append(rst_decl)
|
||||||
|
self.whitelist[fname] = wl
|
||||||
|
wf.close()
|
||||||
|
|
||||||
def process_rst(self, docname):
|
def process_rst(self, docname):
|
||||||
df = open(docname, "rt")
|
df = open(docname, "rt")
|
||||||
@@ -71,6 +114,9 @@ class RSTParser(object):
|
|||||||
print "Documented function %s in %s:%d does not have a match" % (fdecl, docname, lineno)
|
print "Documented function %s in %s:%d does not have a match" % (fdecl, docname, lineno)
|
||||||
df.close()
|
df.close()
|
||||||
|
|
||||||
|
def decl2str(self, decl):
|
||||||
|
return "%s %s(%s)" % (decl[1], decl[0], ", ".join([a[0] + " " + a[1] for a in decl[3]]))
|
||||||
|
|
||||||
def check_module_docs(self, name):
|
def check_module_docs(self, name):
|
||||||
self.parser = hp.CppHeaderParser()
|
self.parser = hp.CppHeaderParser()
|
||||||
decls = []
|
decls = []
|
||||||
@@ -80,8 +126,6 @@ class RSTParser(object):
|
|||||||
if hname.startswith("../modules/" + name):
|
if hname.startswith("../modules/" + name):
|
||||||
decls += self.parser.parse(hname, wmode=False)
|
decls += self.parser.parse(hname, wmode=False)
|
||||||
|
|
||||||
#parser.print_decls(decls)
|
|
||||||
|
|
||||||
for d in decls:
|
for d in decls:
|
||||||
fname = d[0]
|
fname = d[0]
|
||||||
if not fname.startswith("struct") and not fname.startswith("class") and not fname.startswith("const"):
|
if not fname.startswith("struct") and not fname.startswith("class") and not fname.startswith("const"):
|
||||||
@@ -99,12 +143,30 @@ class RSTParser(object):
|
|||||||
misscount = 0
|
misscount = 0
|
||||||
fkeys = sorted(self.fmap.keys())
|
fkeys = sorted(self.fmap.keys())
|
||||||
for f in fkeys:
|
for f in fkeys:
|
||||||
|
# skip undocumented destructors
|
||||||
|
if "~" in f:
|
||||||
|
continue
|
||||||
decls = self.fmap[f]
|
decls = self.fmap[f]
|
||||||
|
fcomps = f.split(".")
|
||||||
|
prefix = ""
|
||||||
|
wlist_decls = []
|
||||||
|
for c in fcomps:
|
||||||
|
prefix = (prefix + "." + c).lstrip(".")
|
||||||
|
wlist_decls = self.whitelist.get(prefix, [])
|
||||||
|
if wlist_decls == "*":
|
||||||
|
break
|
||||||
|
if wlist_decls == "*":
|
||||||
|
continue
|
||||||
|
wlist_decls = [self.decl2str(d) for d in wlist_decls]
|
||||||
|
|
||||||
for d in decls:
|
for d in decls:
|
||||||
misscount += 1
|
dstr = self.decl2str(d)
|
||||||
print "%s %s(%s)" % (d[1], d[0], ", ".join([a[0] + " " + a[1] for a in d[3]]))
|
if dstr not in wlist_decls:
|
||||||
|
misscount += 1
|
||||||
|
print "%s %s(%s)" % (d[1], d[0].replace(".", "::"), ", ".join([a[0] + " " + a[1] for a in d[3]]))
|
||||||
print "\n\n\nundocumented functions in %s: %d" % (name, misscount)
|
print "\n\n\nundocumented functions in %s: %d" % (name, misscount)
|
||||||
|
|
||||||
|
|
||||||
p = RSTParser()
|
p = RSTParser()
|
||||||
for m in opencv_module_list:
|
for m in opencv_module_list:
|
||||||
print "\n\n*************************** " + m + " *************************\n"
|
print "\n\n*************************** " + m + " *************************\n"
|
||||||
|
24
doc/check_docs_whitelist.txt
Normal file
24
doc/check_docs_whitelist.txt
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# this is a list of functions, classes and methods
|
||||||
|
# that are not supposed to be documented in the near future,
|
||||||
|
# to make the output of check_docs.py script more sensible.
|
||||||
|
#
|
||||||
|
# Syntax:
|
||||||
|
# every line starting with # is a comment
|
||||||
|
# there can be empty lines
|
||||||
|
# each line includes either a class name (including all the necessary namespaces),
|
||||||
|
# or a function/method name
|
||||||
|
# or a full declaration of a function/method
|
||||||
|
# if a class name is in the whitelist, all the methods are considered "white-listed" too
|
||||||
|
# if a method/function name is listed, then all the overload variants are "white-listed".
|
||||||
|
# that is, to white list a particular overloaded variant of a function/method you need to put
|
||||||
|
# full declaration into the file
|
||||||
|
#
|
||||||
|
|
||||||
|
cv::Mat::MSize
|
||||||
|
cv::Mat::MStep
|
||||||
|
cv::Algorithm
|
||||||
|
cv::_InputArray
|
||||||
|
cv::_OutputArray
|
||||||
|
|
||||||
|
CvLevMarq
|
||||||
|
|
Reference in New Issue
Block a user