Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Tweak documentation coverage test
Ignore some obvious members which don't require docs:
- constructors with no arguments
- = and == operators

Also show list of undocumented members for each class
  • Loading branch information
nyalldawson committed Aug 21, 2015
1 parent 9d984b1 commit ee139b9
Showing 1 changed file with 39 additions and 4 deletions.
43 changes: 39 additions & 4 deletions tests/src/python/test_qgsdoccoverage.py
Expand Up @@ -42,6 +42,16 @@ def elemIsDocumentableClass(elem):
#public or protected classes should be documented
return elem.get('prot') in ('public','protected')

def memberSignature(elem):
a = elem.find('argsstring')
try:
if a is not None:
return elem.find('name').text + a.text
else:
return elem.find('name').text
except:
return None

def elemIsDocumentableMember(elem):
if elem.get('kind') == 'variable':
return False
Expand All @@ -60,8 +70,27 @@ def elemIsDocumentableMember(elem):

#ignore destructor
name = elem.find('name')
if name is not None and name.text and name.text.startswith('~'):
return False
try:
if name.text and name.text.startswith('~'):
return False
except:
pass

#ignore constructors with no arguments
definition = elem.find('definition')
argsstring = elem.find('argsstring')
try:
if definition.text == '{}::{}'.format(name.text,name.text) and argsstring.text == '()':
return False
except:
pass

#ignore certain obvious operators
try:
if name.text in ('operator=','operator=='):
return False
except:
pass

return True

Expand All @@ -76,12 +105,15 @@ def memberIsDocumented(m):
def parseClassElem(e):
documentable_members = 0
documented_members = 0
undocumented_members = []
for m in e.getiterator('memberdef'):
if elemIsDocumentableMember(m):
documentable_members += 1
if memberIsDocumented(m):
documented_members += 1
return documentable_members, documented_members
else:
undocumented_members.append(memberSignature(m))
return documentable_members, documented_members, undocumented_members

def parseFile(f):
documentable_members = 0
Expand All @@ -90,11 +122,14 @@ def parseFile(f):
for event, elem in ET.iterparse(f):
if event == 'end' and elem.tag == 'compounddef':
if elemIsDocumentableClass(elem):
members, documented = parseClassElem(elem)
members, documented, undocumented = parseClassElem(elem)
documentable_members += members
documented_members += documented
if documented < members:
print "Class {}, {}/{} members documented".format(elem.find('compoundname').text,documented,members)
for u in undocumented:
print ' Missing: {}'.format(u)
print "\n"
elem.clear()
except ET.ParseError as e:
#sometimes Doxygen generates malformed xml (eg for < and > operators)
Expand Down

0 comments on commit ee139b9

Please sign in to comment.