From: Wolfgang Bangerth Date: Thu, 27 Sep 2012 16:58:13 +0000 (+0000) Subject: Only output a list of parameters if there are any. Otherwise we X-Git-Tag: v8.0.0~2014 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db7089634f7ececd3d7bd3d1e1d63d107e0a80f4;p=dealii.git Only output a list of parameters if there are any. Otherwise we end up with an empty {itemize} list which latex does not like. git-svn-id: https://svn.dealii.org/trunk@26795 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 28ebe63f83..318bd56f1c 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -87,6 +87,14 @@ DoFHandler, in particular removal of specializations.

Specific improvements

    +
  1. Fixed: ParameterHandler::print_parameters, when using +ParameterHandler::OutputStyle::LaTeX would always print a list +of parameters in each section as a latex itemized environment. +However, if there are none, we end up with an empty list which +latex does not like. This is now fixed. +
    +(Wolfgang Bangerth, 2012/09/27) +
  2. New: Added BlockCompressedSimpleSparsityPattern::column_number().
    (Timo Heister, 2012/09/25) diff --git a/deal.II/source/base/parameter_handler.cc b/deal.II/source/base/parameter_handler.cc index 1b40987948..a166766a8c 100644 --- a/deal.II/source/base/parameter_handler.cc +++ b/deal.II/source/base/parameter_handler.cc @@ -1884,54 +1884,70 @@ ParameterHandler::print_parameters_section (std::ostream &out, case LaTeX: { - out << "\\begin{itemize}" - << std::endl; - - // print entries one by - // one. make sure they are - // sorted by using the - // appropriate iterators - for (boost::property_tree::ptree::const_assoc_iterator - p = current_section.ordered_begin(); - p != current_section.not_found(); ++p) - if (is_parameter_node (p->second) == true) - { - const std::string value = p->second.get("value"); - - // print name - out << "\\item {\\it Parameter name:} {\\tt " << demangle(p->first) << "}\n\n" - << std::endl; - - out << "\\index[prmindex]{" - << demangle(p->first) - << "}\n"; - out << "\\index[prmindexfull]{"; - for (unsigned int i=0; ifirst) - << "}\n"; - - // finally print value and default - out << "{\\it Value:} " << value << "\n\n" - << std::endl - << "{\\it Default:} " - << p->second.get("default_value") << "\n\n" - << std::endl; - - // if there is a - // documenting string, - // print it as well - if (!p->second.get("documentation").empty()) - out << "{\\it Description:} " - << p->second.get("documentation") << "\n\n" - << std::endl; - - // also output possible values - out << "{\\it Possible values:} " - << p->second.get ("pattern_description") - << std::endl; - } - out << "\\end{itemize}" << std::endl; + // if there are any parameters in + // this section then print them as an + // itemized list + bool parameters_exist_here = false; + for (boost::property_tree::ptree::const_assoc_iterator + p = current_section.ordered_begin(); + p != current_section.not_found(); ++p) + if (is_parameter_node (p->second) == true) + { + parameters_exist_here = true; + break; + } + + if (parameters_exist_here) + { + out << "\\begin{itemize}" + << std::endl; + + // print entries one by + // one. make sure they are + // sorted by using the + // appropriate iterators + for (boost::property_tree::ptree::const_assoc_iterator + p = current_section.ordered_begin(); + p != current_section.not_found(); ++p) + if (is_parameter_node (p->second) == true) + { + const std::string value = p->second.get("value"); + + // print name + out << "\\item {\\it Parameter name:} {\\tt " << demangle(p->first) << "}\n\n" + << std::endl; + + out << "\\index[prmindex]{" + << demangle(p->first) + << "}\n"; + out << "\\index[prmindexfull]{"; + for (unsigned int i=0; ifirst) + << "}\n"; + + // finally print value and default + out << "{\\it Value:} " << value << "\n\n" + << std::endl + << "{\\it Default:} " + << p->second.get("default_value") << "\n\n" + << std::endl; + + // if there is a + // documenting string, + // print it as well + if (!p->second.get("documentation").empty()) + out << "{\\it Description:} " + << p->second.get("documentation") << "\n\n" + << std::endl; + + // also output possible values + out << "{\\it Possible values:} " + << p->second.get ("pattern_description") + << std::endl; + } + out << "\\end{itemize}" << std::endl; + } break; } diff --git a/tests/bits/parameter_handler_4b.cc b/tests/bits/parameter_handler_4b.cc new file mode 100644 index 0000000000..917a7a291d --- /dev/null +++ b/tests/bits/parameter_handler_4b.cc @@ -0,0 +1,67 @@ +//---------------------------- parameter_handler_4b.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2003, 2004, 2005, 2012 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//---------------------------- parameter_handler_4b.cc --------------------------- + + +// test the output generated by +// ParameterHandler::print_parameters(LaTeX). make sure that empty sections do +// not lead to empty itemized environments in the latex output, which are not +// valid + +#include "../tests.h" +#include +#include +#include +#include + + +int main () +{ + try + { + std::ofstream logfile("parameter_handler_4b/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + ParameterHandler prm; + prm.enter_subsection ("Testing"); + prm.leave_subsection (); + prm.print_parameters (logfile, ParameterHandler::LaTeX); + } + catch (std::exception &exc) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; + + return 0; +} diff --git a/tests/bits/parameter_handler_4b/cmp/generic b/tests/bits/parameter_handler_4b/cmp/generic new file mode 100644 index 0000000000..c6af8c1988 --- /dev/null +++ b/tests/bits/parameter_handler_4b/cmp/generic @@ -0,0 +1,9 @@ + +\subsection{Global parameters} +\label{parameters:global} + + + +\subsection{Parameters in section \tt Testing} +\label{parameters:Testing} +