Bug 145918

Summary: Python code generator does not wrap lines properly
Product: [Applications] umbrello Reporter: Ben Hearsum <bhearsum>
Component: generalAssignee: Umbrello Development Group <umbrello-devel>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Ben Hearsum 2007-05-24 22:23:28 UTC
Version:           svn (using KDE KDE 3.5.6)
Installed from:    Ubuntu Packages
OS:                Linux

When generating code in Python no line wrapping is done. I have many comments that are over 300 characters long which exist on a single line. Generation with C++ yields better (but not perfect) line breaking.

Sample output in Python:
        """
        Adds the CSS declaration 'declaration' to the selector specified by 'selector'. If the key specified in 'selector' already exists in 'self.rules' the given declaration is added to it. If 'selector' does not exist it will be added. If the specified property in the declaration already exists, it's value will be overridden to ensure that no duplicates exist. No checks are done to see if the keys/values are applicable to the selector.

        @param string selector : The CSS selector. Examples include "body", "table#myID".
        @param string declaration : A single declaration, colon seperated declaration block. Examples include "list-style-type: none", "color: red".
        @return  :
        @author
        """

Sample output in C++:
    /**
     * Adds the CSS declaration 'declaration' to the selector specified by 'selector'.
     * If the key specified in 'selector' already exists in 'self.rules' the given
     * declaration is added to it. If 'selector' does not exist it will be added. If
     * the specified property in the declaration already exists, it's value will be
     * overridden to ensure that no duplicates exist. No checks are done to see if the
     * keys/values are applicable to the selector.
     * @param  selector The CSS selector. Examples include "body", "table#myID".
     * @param  declaration A single declaration, colon seperated declaration block.
     * Examples include "list-style-type: none", "color: red".
     */
Comment 1 Oliver Kellogg 2007-05-25 07:43:34 UTC
SVN commit 668117 by okellogg:

Use CodeGenerator::formatDoc() for formatting the string returned by UMLObject::getDoc()
BUG:145918


 M  +1 -0      ChangeLog  
 M  +8 -8      umbrello/codegenerators/pythonwriter.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #668116:668117
@@ -3,6 +3,7 @@
 * Bugs/wishes from http://bugs.kde.org:
 * Unstable saves and loads, class names become dirty (145709)
 * Crash on deleting class in list view (145762)
+* Python code generator does not wrap lines properly (145918)
 
 Version 1.5.7
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/pythonwriter.cpp #668116:668117
@@ -134,12 +134,12 @@
 
     h<<(superclasses.count() > 0 ? ")":"")<<":"<<m_endl<<m_endl;
 
-    if(forceDoc() || !c->getDoc().isEmpty()) {
-        h<<m_indentation<<"\"\"\""<<m_endl;
-        h<<m_indentation<<c->getDoc()<<m_endl;
-        h<<m_indentation<<":version:"<<m_endl;
-        h<<m_indentation<<":author:"<<m_endl;
-        h<<m_indentation<<"\"\"\""<<m_endl<<m_endl;
+    if (forceDoc() || !c->getDoc().isEmpty()) {
+        h << m_indentation << "\"\"\"" << m_endl;
+        h << formatDoc(c->getDoc(), m_indentation + ' ') << m_endl;
+        h << m_indentation << ":version:" << m_endl;
+        h << m_indentation << ":author:" << m_endl;
+        h << m_indentation << "\"\"\"" << m_endl << m_endl;
         m_bNeedPass = false;
     }
 
@@ -247,8 +247,8 @@
 
         if( writeDoc )  //write method documentation
         {
-            h<<m_indentation<<m_indentation<<"\"\"\""<<m_endl;
-            h<<m_indentation<<m_indentation<<op->getDoc()<<m_endl<<m_endl;
+            h << m_indentation << m_indentation << "\"\"\"" << m_endl;
+            h << formatDoc(op->getDoc(), m_indentation + m_indentation + ' ') << m_endl;
 
             for (at = atl.first(); at; at = atl.next())  //write parameter documentation
             {
Comment 2 Ben Hearsum 2007-05-25 07:53:57 UTC
I really appreciate the quick fix. Thanks Oliver.