rubycodedocumentation.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "rubycodedocumentation.h"
00022
00023
00024 #include <qregexp.h>
00025 #include <kdebug.h>
00026
00027
00028 #include "rubyclassifiercodedocument.h"
00029 #include "rubycodegenerationpolicy.h"
00030 #include "../uml.h"
00031
00032
00033
00034
00035 RubyCodeDocumentation::RubyCodeDocumentation ( RubyClassifierCodeDocument * doc, const QString & text )
00036 : CodeComment ((CodeDocument*) doc, text)
00037 {
00038
00039 }
00040
00041 RubyCodeDocumentation::~RubyCodeDocumentation ( ) { }
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00057 void RubyCodeDocumentation::saveToXMI ( QDomDocument & doc, QDomElement & root ) {
00058 QDomElement blockElement = doc.createElement( "rubycodedocumentation" );
00059 setAttributesOnNode(doc, blockElement);
00060
00061 root.appendChild( blockElement );
00062 }
00063
00067 QString RubyCodeDocumentation::toString ( )
00068 {
00069
00070 QString output = "";
00071
00072
00073 if(getWriteOutText())
00074 {
00075 bool useHashOutput = true;
00076
00077
00078 CodeGenerationPolicy *p = UMLApp::app()->getCommonPolicy();
00079 if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine)
00080 useHashOutput = false;
00081
00082 QString indent = getIndentationString();
00083 QString endLine = getNewLineEndingChars();
00084 QString body = getText();
00085 if( useHashOutput)
00086 {
00087 if(!body.isEmpty())
00088 output.append(formatMultiLineText (body, indent +"# ", endLine));
00089 } else {
00090 output.append("=begin rdoc"+endLine);
00091 output.append(formatMultiLineText (body, indent +' ', endLine));
00092 output.append("=end"+endLine);
00093 }
00094 }
00095
00096 return output;
00097 }
00098
00099 QString RubyCodeDocumentation::getNewEditorLine ( int amount )
00100 {
00101 CodeGenerationPolicy *p = UMLApp::app()->getCommonPolicy();
00102 if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine)
00103 return getIndentationString(amount) + ' ';
00104 else
00105 return getIndentationString(amount) + "# ";
00106 }
00107
00108 int RubyCodeDocumentation::firstEditableLine() {
00109 CodeGenerationPolicy *p = UMLApp::app()->getCommonPolicy();
00110 if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine)
00111 return 1;
00112 return 0;
00113 }
00114
00115 int RubyCodeDocumentation::lastEditableLine() {
00116 CodeGenerationPolicy *p = UMLApp::app()->getCommonPolicy();
00117 if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine)
00118 {
00119 return -1;
00120 }
00121 return 0;
00122 }
00123
00127 QString RubyCodeDocumentation::unformatText ( const QString & text , const QString & indent)
00128 {
00129
00130 QString mytext = TextBlock::unformatText(text, indent);
00131 CodeGenerationPolicy *p = UMLApp::app()->getCommonPolicy();
00132
00133 mytext.remove(QRegExp('^'+indent));
00134 if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine)
00135 {
00136 mytext.remove(QRegExp("^=begin\\s*(rdoc)?\\s*\n?"));
00137 mytext.remove(QRegExp("^=end\\s*\n?$"));
00138 } else
00139 mytext.remove(QRegExp("^#\\s*"));
00140
00141 return mytext;
00142 }
00143
00144
00145 #include "rubycodedocumentation.moc"
This file is part of the documentation for umbrello Version 3.1.0.