]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Significantly improve handling of comment lines.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 8 Sep 2005 23:59:48 +0000 (23:59 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 8 Sep 2005 23:59:48 +0000 (23:59 +0000)
git-svn-id: https://svn.dealii.org/trunk@11377 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/source/parameter_handler.cc
deal.II/doc/news/changes.html

index c4a1084b98ccc2e4908c0e1738322e63074237d0..96659114db323645ea27caaf9f0f44783dd7b70b 100644 (file)
@@ -14,6 +14,7 @@
 #include <base/parameter_handler.h>
 #include <base/logstream.h>
 #include <base/memory_consumption.h>
+#include <base/utilities.h>
 #include <fstream>
 #include <iostream>
 #include <iomanip>
@@ -32,6 +33,7 @@
 #endif
 
 
+
 //TODO[WB]: various functions here could be simplified by using namespace Utilities
 
 namespace Patterns
@@ -903,6 +905,35 @@ ParameterHandler::print_parameters_section (std::ostream      &out,
                  :
                  pd->entries[ptr->first].value);
 
+                                             // if there is documentation,
+                                             // then add an empty line (unless
+                                             // this is the first entry in a
+                                             // subsection), print the
+                                             // documentation, and then the
+                                             // actual entry; break the
+                                             // documentation into readable
+                                             // chunks such that the whole
+                                             // thing is at most 78 characters
+                                             // wide
+            if (pd->entries[ptr->first].has_documentation())
+              {
+                if (ptr != pd->entries.begin())
+                  out << std::endl;
+                
+                const std::vector<std::string> doc_lines
+                  = Utilities::
+                  break_text_into_lines (pd->entries[ptr->first].documentation,
+                                         78 - indent_level*2 - 2);
+                
+                for (unsigned int i=0; i<doc_lines.size(); ++i)
+                  out << std::setw(indent_level*2) << ""
+                      << "# "
+                      << doc_lines[i]
+                      << std::endl;
+              }
+            
+            
+            
                                              // print name and value
                                              // of this entry
             out << std::setw(indent_level*2) << ""
@@ -911,34 +942,14 @@ ParameterHandler::print_parameters_section (std::ostream      &out,
                 << std::setw(longest_name-ptr->first.length()+1) << " "
                 << "= " << value;
 
-                                             // if we are going to write some
-                                             // text after this, then add a
-                                             // comment marker and align it
-                                             // properly
-            if ((pd->entries[ptr->first].has_documentation())
-                ||
-                (value != pd->entries[ptr->first].value))
-              out << std::setw(longest_value-value.length()+1) << " "
-                  << "# ";
-
-                                             // if there is
-                                             // documentation, then
-                                             // print that, too. the
-                                             // documentation is
-                                             // always looked up in
-                                             // the Defaults tree
-            if (pd->entries[ptr->first].documentation.length() != 0)
-              out << pd->entries[ptr->first].documentation;
-            
                                              // finally print the
                                              // default value, but
                                              // only if it differs
                                              // from the actual value
             if (value != pd->entries[ptr->first].value)
               {
-                if (pd->entries[ptr->first].documentation.length() != 0)
-                  out << ", ";
-                
+                out << std::setw(longest_value-value.length()+1) << " "
+                    << "# ";
                 out << "default: " << pd->entries[ptr->first].value;
               }
             
index ab3f43389a14e14b1bb9d1baec0cc09ca2252cbe..47af0531bf0163b53eeffbdbf64f163fd366f2bc 100644 (file)
@@ -264,6 +264,15 @@ inconvenience this causes.
 <h3>base</h3>
 
 <ol>
+  <li> <p>
+       Extended: The <code>ParameterHandler</code> class now does a much better
+       job generating output in the <code>print_parameters()</code> function if
+       parameters have documentation strings attached to them. See the step-19
+       example program output for this.
+       <br>
+       (WB, 2005/09/12)
+       </p>
+
   <li> <p>
        New: There is now a namespace <code>Utilities</code> that contains
        functions that are not particularly specific to finite element codes,

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.