[cpl-plugin-uves] 01/01: Put parameter section only if there are parameters

Ole Streicher olebole-guest at moszumanska.debian.org
Thu Dec 12 11:18:10 UTC 2013


This is an automated email from the git hooks/post-receive script.

olebole-guest pushed a commit to branch debian-template
in repository cpl-plugin-uves.

commit ed613f1363f87f8fd85a52a5b540e02b7fa4c803
Author: Ole Streicher <debian at liska.ath.cx>
Date:   Mon Dec 9 11:27:29 2013 +0100

    Put parameter section only if there are parameters
---
 debian/create_sphinx.py | 66 +++++++++++++++++++++++++++----------------------
 1 file changed, 36 insertions(+), 30 deletions(-)

diff --git a/debian/create_sphinx.py b/debian/create_sphinx.py
index be553f9..5c90c3f 100644
--- a/debian/create_sphinx.py
+++ b/debian/create_sphinx.py
@@ -33,30 +33,7 @@ Constructor
    import cpl
    {recipe} = cpl.Recipe("{recipe}")
 
-Parameters
-----------
-
-{pars}
-
-The following code snippet shows the default settings for the available 
-parameters.
-
-::
-
-   import cpl
-   {recipe} = cpl.Recipe("{recipe}")
-
-{pars_example1}
-
-You may also set or overwrite some or all parameters by the recipe 
-parameter `param`, as shown in the following example:
-
-::
-
-   import cpl
-   {recipe} = cpl.Recipe("{recipe}")
-   [...]
-   res = {recipe}( ..., param = {{{pars_example2}}})
+{parameters}
 
 .. seealso:: `cpl.Recipe <http://packages.python.org/python-cpl/recipe.html>`_
    for more information about the recipe object.
@@ -124,6 +101,32 @@ Support Department <usd-help at eso.org>`_, describing:
  * whether the problem is repeatable.
 '''
 
+rst_partemplate = '''Parameters
+----------
+
+{pars}
+
+The following code snippet shows the default settings for the available 
+parameters.
+
+::
+
+   import cpl
+   {recipe} = cpl.Recipe("{recipe}")
+
+{pars_example1}
+
+You may also set or overwrite some or all parameters by the recipe 
+parameter `param`, as shown in the following example:
+
+::
+
+   import cpl
+   {recipe} = cpl.Recipe("{recipe}")
+   [...]
+   res = {recipe}( ..., param = {{{pars_example2}}})
+'''
+
 conf_template = '''project = u'{PIPELINE} pipeline'
 version = '{version}'
 release = '{version}'
@@ -184,7 +187,7 @@ def get_description(s):
             o += [ s ]
     return "\n".join(o)
 
-def rstpage(recipe, template):
+def rstpage(recipe, template, partemplate):
     return template.format(
         recipe = recipe.__name__,
         version = recipe.__version__,
@@ -194,16 +197,19 @@ def rstpage(recipe, template):
         author = recipe.__author__,
         license = recipe.__copyright__,
         pipeline = pipeline,
-        pars = par(recipe, par_template),
-        pars_example1 = par(recipe, '   {recipe}.param.{par} = {default}\n'),
-        pars_example2 = par(recipe, '"{par}":{default}', ', ', 2)
+        parameters = partemplate.format(
+            recipe = recipe.__name__,
+            pars = par(recipe, par_template),
+            pars_example1 = par(recipe,
+                                '   {recipe}.param.{par} = {default}\n'),
+            pars_example2 = par(recipe, '"{par}":{default}', ', ', 2)
+        ) if len(recipe.param) > 0 else ''
     )
 
-
 for recipe in recipes_oca + recipes_x:
     f = open(os.path.join("sphinx",
                           fname_template.format(recipe = recipe.__name__)), "w")
-    f.write(rstpage(recipe, rst_template))
+    f.write(rstpage(recipe, rst_template, rst_partemplate))
     f.close()
 
 if len(recipes_oca) > 0 and len(recipes_x) > 0:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/cpl-plugin-uves.git



More information about the debian-science-commits mailing list