[gtk-doc] mkhtml2: tolerate wonky glossterms
- From: Stefan Sauer <stefkost src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-doc] mkhtml2: tolerate wonky glossterms
- Date: Tue, 8 May 2018 18:27:30 +0000 (UTC)
commit eb861c2cb293ebd38a77eead0c1973c245496463
Author: Stefan Sauer <ensonic users sf net>
Date: Tue May 8 20:01:33 2018 +0200
mkhtml2: tolerate wonky glossterms
Gtk3 has glossentries without glossterms and so on.
gtkdoc/mkhtml2.py | 20 +++++++++++++++-----
1 files 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]