gobject-introspection r235 - in trunk: . giscanner



Author: johan
Date: Mon Apr 28 00:15:16 2008
New Revision: 235
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=235&view=rev

Log:
2008-04-27  Johan Dahlin  <johan gnome org>

	* giscanner/xmlwriter.py:
	Wrap attributes for lines which are wider than 79 characters



Modified:
   trunk/ChangeLog
   trunk/giscanner/xmlwriter.py

Modified: trunk/giscanner/xmlwriter.py
==============================================================================
--- trunk/giscanner/xmlwriter.py	(original)
+++ trunk/giscanner/xmlwriter.py	Mon Apr 28 00:15:16 2008
@@ -40,8 +40,25 @@
 
         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):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]