From eb861c2cb293ebd38a77eead0c1973c245496463 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Tue, 8 May 2018 20:01:33 +0200 Subject: [PATCH] mkhtml2: tolerate wonky glossterms Gtk3 has glossentries without glossterms and so on. --- gtkdoc/mkhtml2.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/gtkdoc/mkhtml2.py b/gtkdoc/mkhtml2.py index 16aa93c..ac10e7a 100644 --- a/gtkdoc/mkhtml2.py +++ b/gtkdoc/mkhtml2.py @@ -310,11 +310,21 @@ def build_glossary(files): continue for term in GLOSSENTRY_XPATH(node.xml): # TODO: there can be all kind of things in a glossary. This only supports - # what we commonly use - key = etree.tostring(term.find('glossterm'), method="text", encoding=str).strip() - value = etree.tostring(term.find('glossdef'), method="text", encoding=str).strip() - glossary[key] = value - # logging.debug('glosentry: %s:%s', key, value) + # what we commonly use, glossterm is mandatory + key_node = term.find('glossterm') + val_node = term.find('glossdef') + if key_node is not None and val_node is not None: + key = etree.tostring(key_node, method="text", encoding=str).strip() + val = etree.tostring(val_node, method="text", encoding=str).strip() + glossary[key] = val + # logging.debug('glosentry: %s:%s', key, val) + else: + debug = [] + if key_node is None: + debug.append('missing key') + if val_node is None: + debug.append('missing val') + logging.warning('Unexpected glossentry %s:', term.attrib['id'], ','.join(debug)) # conversion helpers -- 2.11.4.GIT