[gobject-introspection/wip/docs: 2/7] doctool: Don't use zip(range(L))



commit ee06ef4f91485daad330e714324157604b9f8eae
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sat Feb 2 11:07:42 2013 -0500

    doctool: Don't use zip(range(L))
    
    Instead, remove it entirely (since we don't need the index) or instead
    use enumerate().

 giscanner/doctemplates/C/function.tmpl      |    6 +++---
 giscanner/doctemplates/Gjs/class.tmpl       |    2 +-
 giscanner/doctemplates/Gjs/enum.tmpl        |    2 +-
 giscanner/doctemplates/Gjs/function.tmpl    |    2 +-
 giscanner/doctemplates/Gjs/vfunc.tmpl       |    2 +-
 giscanner/doctemplates/Python/class.tmpl    |    2 +-
 giscanner/doctemplates/Python/enum.tmpl     |    2 +-
 giscanner/doctemplates/Python/function.tmpl |    4 ++--
 giscanner/doctemplates/Python/signal.tmpl   |    4 ++--
 giscanner/doctemplates/Python/vfunc.tmpl    |    4 ++--
 10 files changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/giscanner/doctemplates/C/function.tmpl b/giscanner/doctemplates/C/function.tmpl
index 9403698..e76eda3 100644
--- a/giscanner/doctemplates/C/function.tmpl
+++ b/giscanner/doctemplates/C/function.tmpl
@@ -25,10 +25,10 @@
 <%block name="synopsis">
 <synopsis><code mime="text/x-csrc">
 ${node.retval.type.ctype} ${formatter.format_function_name(node)} (\
-% if len(node.all_parameters) == 0:
+% if not node.all_parameters:
 void\
 % else:
-% for arg, ix in zip(node.all_parameters, range(len(node.all_parameters))):
+% for ix, arg in enumerate(node.all_parameters):
 % if ix != 0:
 ${' ' * (len(formatter.format_type(node.retval.type)) + len(formatter.format_function_name(node)) + 3)}\
 % endif
@@ -48,7 +48,7 @@ ${formatter.format_type(arg.type) | x} ${arg.argname}\
 <%block name="details">
 % if node.all_parameters or node.retval:
 <dl>
-% for arg, ix in zip(node.parameters, range(len(node.parameters))):
+% for arg in node.parameters:
 <dt><p>${arg.argname} :</p></dt>
 <dd>${formatter.format(node, arg.doc)}</dd>
 % endfor
diff --git a/giscanner/doctemplates/Gjs/class.tmpl b/giscanner/doctemplates/Gjs/class.tmpl
index 3991ff3..435b31a 100644
--- a/giscanner/doctemplates/Gjs/class.tmpl
+++ b/giscanner/doctemplates/Gjs/class.tmpl
@@ -4,7 +4,7 @@
 from gi.repository import ${namespace.name}
 
 ${formatter.to_underscores(node.name).lower()} = ${namespace.name}.${node.name}(\
-% for property_, ix in zip(node.properties, range(len(node.properties))):
+% for ix, property_ in enumerate(node.properties):
 % if property_.construct or property_.construct_only or property_.writable:
 <link xref='${namespace.name}.${node.name}-${property_.name}'>${property_.name.replace('-', '_')}</link>=value\
 % if ix != len(node.properties) - 1:
diff --git a/giscanner/doctemplates/Gjs/enum.tmpl b/giscanner/doctemplates/Gjs/enum.tmpl
index 840f79f..2624c42 100644
--- a/giscanner/doctemplates/Gjs/enum.tmpl
+++ b/giscanner/doctemplates/Gjs/enum.tmpl
@@ -2,7 +2,7 @@
 <%block name="details">
 % if node.members:
 <dl>
-% for member, ix in zip(node.members, range(len(node.members))):
+% for member in node.members:
 <dt><p>${node.name}.${member.name.upper()} :</p></dt>
 <dd>${formatter.format(node, member.doc)}</dd>
 % endfor
diff --git a/giscanner/doctemplates/Gjs/function.tmpl b/giscanner/doctemplates/Gjs/function.tmpl
index d0fa096..2039405 100644
--- a/giscanner/doctemplates/Gjs/function.tmpl
+++ b/giscanner/doctemplates/Gjs/function.tmpl
@@ -35,7 +35,7 @@ ${', '.join('%s:%s' % (arg.argname, formatter.format_type(arg.type)) for arg in
 <%block name="details">
 % if node.parameters or node.retval:
 <dl>
-% for arg, ix in zip(node.parameters, range(len(node.parameters))):
+% for arg in node.parameters:
 <dt><p>${arg.argname} :</p></dt>
 <dd>${formatter.format(node, arg.doc)}</dd>
 % endfor
diff --git a/giscanner/doctemplates/Gjs/vfunc.tmpl b/giscanner/doctemplates/Gjs/vfunc.tmpl
index bba3f38..2e5d8c9 100644
--- a/giscanner/doctemplates/Gjs/vfunc.tmpl
+++ b/giscanner/doctemplates/Gjs/vfunc.tmpl
@@ -10,7 +10,7 @@ ${', '.join('%s:%s' % (arg.argname, formatter.format_type(arg.type)) for arg in
 <%block name="details">
 % if node.parameters or node.retval:
 <dl>
-% for arg, ix in zip(node.parameters, range(len(node.parameters))):
+% for arg in node.parameters:
 <dt><p>${arg.argname} :</p></dt>
 <dd>${formatter.format(node, arg.doc)}</dd>
 % endfor
diff --git a/giscanner/doctemplates/Python/class.tmpl b/giscanner/doctemplates/Python/class.tmpl
index 3991ff3..435b31a 100644
--- a/giscanner/doctemplates/Python/class.tmpl
+++ b/giscanner/doctemplates/Python/class.tmpl
@@ -4,7 +4,7 @@
 from gi.repository import ${namespace.name}
 
 ${formatter.to_underscores(node.name).lower()} = ${namespace.name}.${node.name}(\
-% for property_, ix in zip(node.properties, range(len(node.properties))):
+% for ix, property_ in enumerate(node.properties):
 % if property_.construct or property_.construct_only or property_.writable:
 <link xref='${namespace.name}.${node.name}-${property_.name}'>${property_.name.replace('-', '_')}</link>=value\
 % if ix != len(node.properties) - 1:
diff --git a/giscanner/doctemplates/Python/enum.tmpl b/giscanner/doctemplates/Python/enum.tmpl
index 840f79f..2624c42 100644
--- a/giscanner/doctemplates/Python/enum.tmpl
+++ b/giscanner/doctemplates/Python/enum.tmpl
@@ -2,7 +2,7 @@
 <%block name="details">
 % if node.members:
 <dl>
-% for member, ix in zip(node.members, range(len(node.members))):
+% for member in node.members:
 <dt><p>${node.name}.${member.name.upper()} :</p></dt>
 <dd>${formatter.format(node, member.doc)}</dd>
 % endfor
diff --git a/giscanner/doctemplates/Python/function.tmpl b/giscanner/doctemplates/Python/function.tmpl
index fa705bd..23fde04 100644
--- a/giscanner/doctemplates/Python/function.tmpl
+++ b/giscanner/doctemplates/Python/function.tmpl
@@ -24,7 +24,7 @@
 </%block>
 <%block name="synopsis">
 <synopsis><code mime="text/x-python">
-% if len(node.all_parameters) != 0:
+% if node.all_parameters:
 @accepts(\
 ${', '.join((formatter.format_type(arg.type) for arg in node.all_parameters))}\
 )
@@ -40,7 +40,7 @@ ${', '.join((formatter.format_parameter_name(node, arg) for arg in node.all_para
 <%block name="details">
 % if node.all_parameters or node.retval:
 <dl>
-% for arg, ix in zip(node.all_parameters, range(len(node.all_parameters))):
+% for ix, arg in enumerate(node.all_parameters):
 <dt><p>${formatter.format_parameter_name(node, arg)} :</p></dt>
 <dd>${formatter.format(node, arg.doc)}</dd>
 % endfor
diff --git a/giscanner/doctemplates/Python/signal.tmpl b/giscanner/doctemplates/Python/signal.tmpl
index 9b27746..abb3a3a 100644
--- a/giscanner/doctemplates/Python/signal.tmpl
+++ b/giscanner/doctemplates/Python/signal.tmpl
@@ -6,7 +6,7 @@
 <%block name="synopsis">
 <synopsis><code mime="text/x-python">
 def callback(${formatter.to_underscores(node.parent.name).lower()}, \
-% for arg, ix in zip(node.parameters, range(len(node.parameters))):
+% for arg in node.parameters:
 ${arg.argname}, \
 % endfor
 user_param1, ...)
@@ -16,7 +16,7 @@ user_param1, ...)
 <dl>
 <dt><p>${formatter.to_underscores(node.parent.name).lower()} :</p></dt>
 <dd><p>instance of ${namespace.name}.${node.parent.name} that is emitting the signal</p></dd>
-% for arg, ix in zip(node.parameters, range(len(node.parameters))):
+% for arg in node.parameters:
 <dt><p>${arg.argname} :</p></dt>
 <dd>${formatter.format(node, arg.doc)}</dd>
 % endfor
diff --git a/giscanner/doctemplates/Python/vfunc.tmpl b/giscanner/doctemplates/Python/vfunc.tmpl
index 65f856a..6f7e692 100644
--- a/giscanner/doctemplates/Python/vfunc.tmpl
+++ b/giscanner/doctemplates/Python/vfunc.tmpl
@@ -1,7 +1,7 @@
 <%inherit file="/base.tmpl"/>
 <%block name="synopsis">
 <synopsis><code mime="text/x-python">
-% if len(node.parameters) != 0:
+% if node.parameters:
 @accepts(\
 ${', '.join((formatter.format_type(arg.type) for arg in node.parameters))}\
 )
@@ -16,7 +16,7 @@ ${', '.join((arg.argname for arg in node.parameters))}\
 <%block name="details">
 % if node.parameters or node.retval:
 <dl>
-% for arg, ix in zip(node.parameters, range(len(node.parameters))):
+% for arg in node.parameters:
 <dt><p>${arg.argname} :</p></dt>
 <dd>${formatter.format(node, arg.doc)}</dd>
 % endfor


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]