From 2ba8647b8033dd7a5bb92f5413ea2339cda16aad Mon Sep 17 00:00:00 2001
From: Victor Poughon <victor.poughon@cnes.fr>
Date: Tue, 11 Dec 2018 13:59:14 +0100
Subject: [PATCH] DOC: fix string list display formatting

---
 .../Cookbook/Scripts/otbGenerateWrappersRstDoc.py    | 10 ++++++++--
 .../ApplicationEngine/src/otbWrapperApplication.cxx  | 12 +++++++++---
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py b/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py
index d93f545550..2a1ac0c582 100755
--- a/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py
+++ b/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py
@@ -228,10 +228,16 @@ def rst_parameter_value(app, key):
         raise ValueError("Cannot show parameter value for type ", type)
 
 def rst_parameter_flags(app, key):
+    """
+    Display the mandatory and default value flags of a parameter
+    The display logic tries to follow the logic in WrapperCommandLineLauncher::DisplayParameterHelp
+    The default value is formatted using GetParameterAsString to use the same formatting as the cli interface
+    """
+
     if app.IsMandatory(key) and not app.HasValue(key):
         return "*Mandatory* "
-    elif app.HasValue(key) and app.GetParameterType(key) != ParameterType_Group:
-        return "*Default value: {}* ".format(app.GetParameterAsString(key)) # get value as string to use the same formatting as the c++ api
+    elif app.HasValue(key) and app.GetParameterType(key) != ParameterType_Group and app.GetParameterAsString(key) != "":
+        return "*Default value: {}* ".format(app.GetParameterAsString(key))
     else:
         return ""
 
diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx
index c755a4407f..dbeac1e3aa 100644
--- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx
+++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx
@@ -1995,9 +1995,15 @@ std::string Application::GetParameterAsString(std::string paramKey)
     {
       std::ostringstream oss;
       oss << std::setprecision(10);
-      const std::vector<std::string> strList = this->GetParameterStringList( paramKey );
-      for (unsigned int i=0; i<strList.size(); i++)
-        oss << strList[i] << std::endl;
+      const std::vector<std::string> strList = this->GetParameterStringList(paramKey);
+      for (size_t i = 0; i < strList.size(); i++)
+      {
+        if (i != 0)
+        {
+          oss << " ";
+        }
+        oss << strList[i];
+      }
       ret = oss.str();
     }
   else
-- 
GitLab