2 new revisions:
Revision: 2f2a34d5d618
Branch: default
Author: Jussi Malinen <jussi.ao.mali...@gmail.com>
Date: Mon Dec 2 11:06:04 2013 UTC
Log: Fix libdoc for kwargs handling. Also fix handling of varargs if
they a...
http://code.google.com/p/robotframework/source/detail?r=2f2a34d5d618
Revision: 6083e2589b2d
Branch: default
Author: Jussi Malinen <jussi.ao.mali...@gmail.com>
Date: Mon Dec 2 11:06:17 2013 UTC
Log: Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=6083e2589b2d
==============================================================================
Revision: 2f2a34d5d618
Branch: default
Author: Jussi Malinen <jussi.ao.mali...@gmail.com>
Date: Mon Dec 2 11:06:04 2013 UTC
Log: Fix libdoc for kwargs handling. Also fix handling of varargs if
they are lists and fi a bug which made all lists to have * in front.
Update issue 1583
Now libdoc handles also kwargs on java.
http://code.google.com/p/robotframework/source/detail?r=2f2a34d5d618
Modified:
/atest/robot/libdoc/java_library.txt
/atest/testdata/libdoc/Example.java
/src/robot/libdocpkg/javabuilder.py
=======================================
--- /atest/robot/libdoc/java_library.txt Thu Oct 11 12:02:11 2012 UTC
+++ /atest/robot/libdoc/java_library.txt Mon Dec 2 11:06:04 2013 UTC
@@ -39,13 +39,13 @@
Keyword Names
Keyword Name Should Be 0 Keyword
- Keyword Name Should Be 1 My Keyword
+ Keyword Name Should Be 4 My Keyword
Keyword Arguments
Keyword Arguments Should Be 0 arg
- Keyword Arguments Should Be 1
- Keyword Arguments Should Be -2 *varargs
- Keyword Arguments Should Be -1 normal *varargs
+ Keyword Arguments Should Be 4
+ Keyword Arguments Should Be -4 *varargs
+ Keyword Arguments Should Be -3 normal *varargs
Keyword Documentation
Keyword Doc Should Start With 0
@@ -54,9 +54,24 @@
... | Your Keyword | xxx |\n
... | Your Keyword | yyy |\n\n
... See `My Keyword` for no more information.
- Keyword Doc Should Start With 1
+ Keyword Doc Should Start With 4
... Does nothing & <doc> has "stuff" to 'escape'!!
... \nand ignored indentation
Non ASCII
- Keyword Doc Should Be 2 Hyvää yötä.\n\nСпасибо!
+ Keyword Doc Should Be 5 Hyvää yötä.\n\nСпасибо!
+
+Lists as varargs
+ Keyword Arguments Should Be -1 *varargsList
+
+Kwargs
+ Keyword Arguments Should Be 1 normal *varargs **kwargs
+
+Only last map is kwargs
+ Keyword Arguments Should Be 2 normal **kwargs
+
+Only last list is varargs
+ Keyword Arguments Should Be -2 normalArray *varargs
+
+Last argument overrides
+ Keyword Arguments Should Be 3 normalArray normalMap normal
=======================================
--- /atest/testdata/libdoc/Example.java Thu Oct 11 12:02:11 2012 UTC
+++ /atest/testdata/libdoc/Example.java Mon Dec 2 11:06:04 2013 UTC
@@ -1,3 +1,5 @@
+import java.util.*;
+
/**
* Library for `libdoc.py` testing purposes.
*
@@ -62,6 +64,36 @@
*/
public void varargs2(int normal, int... varargs) {
}
+
+ /**
+ * Creating varargs using `List`.
+ */
+ public void varargsList(List<String> varargsList) {
+ }
+
+ /**
+ * Only last array or list is kwargs.
+ */
+ public void varargsLast(String[] normalArray, String[] varargs) {
+ }
+
+ /**
+ * Only last arguments overrides.
+ */
+ public void lastArgument(String[] normalArray, Map<String, Object>
normalMap, String normal) {
+ }
+
+ /**
+ * Creating kwargs.
+ */
+ public void kwargs(int normal, String[] varargs, Map<String, Object>
kwargs) {
+ }
+
+ /**
+ * Only last map is kwargs.
+ */
+ public void kwargsLast(Map<String, Object> normal, Map<String, Object>
kwargs) {
+ }
/**
* Hyv\u00e4\u00e4 y\u00f6t\u00e4.
=======================================
--- /src/robot/libdocpkg/javabuilder.py Thu Jun 6 14:00:44 2013 UTC
+++ /src/robot/libdocpkg/javabuilder.py Mon Dec 2 11:06:04 2013 UTC
@@ -29,7 +29,7 @@
named_args=False,
doc_format=self._get_doc_format(doc))
libdoc.keywords = self._keywords(doc)
- libdoc.inits = self._intializers(doc)
+ libdoc.inits = self._initializers(doc)
return libdoc
def _get_doc(self, doc):
@@ -61,18 +61,38 @@
def _keyword_doc(self, method):
return KeywordDoc(
name=utils.printable_name(method.name(), code_style=True),
- args=list(self._yield_keyword_arguments(method)),
+ args=self._get_keyword_arguments(method),
doc=self._get_doc(method)
)
- def _yield_keyword_arguments(self, method):
- for param in method.parameters():
- name = param.name()
- if param.type().dimension() == '[]':
- name = '*' + name
- yield name
+ def _get_keyword_arguments(self, method):
+ reverse_params = list(reversed(method.parameters()))
+ if not reverse_params:
+ return []
+ result = []
+ index = 0
+ param = reverse_params[index]
+ if self._is_kwargs(param):
+ result.append('**'+param.name())
+ index+=1
+ if len(reverse_params) == index:
+ return result
+ param = reverse_params[index]
+ if self._is_varargs(param):
+ result.append('*'+param.name())
+ index+=1
+ while (len(reverse_params)>index):
+ result.append(reverse_params[index].name())
+ index +=1
+ return list(reversed(result))
+
+ def _is_kwargs(self, param):
+ return str(param.type()).startswith('java.util.Map')
+
+ def _is_varargs(self, param):
+ return str(param.type()).startswith('java.util.List') or
param.type().dimension() == '[]'
- def _intializers(self, doc):
+ def _initializers(self, doc):
inits = [self._keyword_doc(init) for init in doc.constructors()]
if len(inits) == 1 and not inits[0].args:
return []
==============================================================================
Revision: 6083e2589b2d
Branch: default
Author: Jussi Malinen <jussi.ao.mali...@gmail.com>
Date: Mon Dec 2 11:06:17 2013 UTC
Log: Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=6083e2589b2d
--
---
You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.