[gobject-introspection: 22/30] docwriter: Handle invalid nodes better
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection: 22/30] docwriter: Handle invalid nodes better
- Date: Tue, 14 Aug 2018 07:05:51 +0000 (UTC)
commit fc39530d66d921331ced5a0b6607e9106c8d1647
Author: Philip Chimento <philip chimento gmail com>
Date: Tue Feb 9 22:24:15 2016 -0800
docwriter: Handle invalid nodes better
Cogl-2.0.gir has the following entry:
<bitfield name="BufferMapHint"
version="1.4"
stability="Unstable"
c:type="CoglBufferMapHint">
<doc xml:whitespace="preserve">...</doc>
<member name="" value="1"
c:identifier="COGL_BUFFER_MAP_HINT_DISCARD">
<doc xml:whitespace="preserve">...</doc>
</member>
<member name="_range"
value="2"
c:identifier="COGL_BUFFER_MAP_HINT_DISCARD_RANGE">
<doc xml:whitespace="preserve">...</doc>
</member>
</bitfield>
The prefix is not picked up correctly and so we get a member without a
name, which crashes the docwriter in to_underscore(). Change that
function to handle this case by giving it a dummy "anonymous member"
name.
giscanner/docwriter.py | 10 ++++++++++
1 file changed, 10 insertions(+)
---
diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py
index e5a025ba..754787e3 100644
--- a/giscanner/docwriter.py
+++ b/giscanner/docwriter.py
@@ -28,6 +28,7 @@ from __future__ import unicode_literals
import os
import re
+import sys
import tempfile
from xml.sax import saxutils
@@ -1131,6 +1132,15 @@ class DevDocsFormatterGjs(DocFormatterGjs):
link += "#" + anchor
return "[{}]({}){}".format(display_name, link, 's' if pluralize else '')
+ def to_underscores(self, node):
+ try:
+ return super(DevDocsFormatterGjs, self).to_underscores(node)
+ except Exception as e:
+ if e.message == 'invalid node':
+ print('warning: invalid node in', node.parent.name,
+ file=sys.stderr)
+ return node.parent.name + '_invalid_node'
+
def make_anchor(self, node):
style_class = get_node_kind(node)
return "{}-{}".format(style_class, self.to_underscores(node))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]