Skip to content

Continue parsing xml files even if one is malformed #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 38 additions & 34 deletions doxy-coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,42 +55,46 @@ def FATAL(*objs):
sys.exit((1,0)[ns.noerror])

def parse_file(fullpath):
tree = ET.parse(fullpath)


sourcefile = None
definitions = {}

for definition in tree.findall("./compounddef//memberdef"):
# Should it be documented
if (definition.get('kind') == 'function' and
definition.get('static') == 'yes'):
continue

# Is the definition documented?
documented = False
for k in ('briefdescription', 'detaileddescription', 'inbodydescription'):
if definition.findall("./%s/"%(k)):
documented = True
break

# Name
d_def = definition.find('./definition')
d_nam = definition.find('./name')

if not sourcefile:
l = definition.find('./location')
if l is not None:
sourcefile = l.get('file')

if d_def is not None:
name = d_def.text
elif d_nam is not None:
name = d_nam.text
else:
name = definition.get('id')

# Aggregate
definitions[name] = documented

try:
tree = ET.parse(fullpath)
except ET.ParseError as e:
print ("failed to parse ", fullpath, e)
else:
for definition in tree.findall("./compounddef//memberdef"):
# Should it be documented
if (definition.get('kind') == 'function' and
definition.get('static') == 'yes'):
continue

# Is the definition documented?
documented = False
for k in ('briefdescription', 'detaileddescription', 'inbodydescription'):
if definition.findall("./%s/"%(k)):
documented = True
break

# Name
d_def = definition.find('./definition')
d_nam = definition.find('./name')

if not sourcefile:
l = definition.find('./location')
if l is not None:
sourcefile = l.get('file')

if d_def is not None:
name = d_def.text
elif d_nam is not None:
name = d_nam.text
else:
name = definition.get('id')

# Aggregate
definitions[name] = documented

if not sourcefile:
sourcefile = fullpath
Expand Down