From: Johan Dahlin Date: Mon, 28 Apr 2008 00:15:16 +0000 (+0000) Subject: Wrap attributes for lines which are wider than 79 characters X-Git-Tag: GOBJECT_INTROSPECTION_0_5_0~304 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ffdd14a60438db558819ab12134e7ea7d8472566;p=platform%2Fupstream%2Fgobject-introspection.git Wrap attributes for lines which are wider than 79 characters 2008-04-27 Johan Dahlin * giscanner/xmlwriter.py: Wrap attributes for lines which are wider than 79 characters svn path=/trunk/; revision=235 --- diff --git a/ChangeLog b/ChangeLog index 9ba9ac0..c53ec13 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2008-04-27 Johan Dahlin + * giscanner/xmlwriter.py: + Wrap attributes for lines which are wider than 79 characters + * giscanner/scannerlexer.l: Allow parenthesis in annotations diff --git a/giscanner/xmlwriter.py b/giscanner/xmlwriter.py index ccb75c6..c80c90d 100644 --- a/giscanner/xmlwriter.py +++ b/giscanner/xmlwriter.py @@ -40,8 +40,25 @@ class XMLWriter(object): return attr_value + def _collect_attributes_wrapped(self, tag_name, attributes): + assert attributes + attr_value = '' + indent_len = 0 + for attr, value in attributes: + if indent_len: + attr_value += '\n%s' % (' ' * indent_len) + assert value is not None, attr + attr_value += ' %s=%s' % (attr, quoteattr(value)) + if not indent_len: + indent_len = (self._indent + + len(tag_name) + 1) + + return attr_value + def _open_tag(self, tag_name, attributes=None): attrs = self._collect_attributes(attributes) + if (len(attrs) + len(tag_name) + 2) > 79: + attrs = self._collect_attributes_wrapped(tag_name, attributes) self.write_line('<%s%s>' % (tag_name, attrs)) def _close_tag(self, tag_name):