Skip to content

Commit 2004cab

Browse files
committed
Fixed mandatory kwonly args
1 parent 0b7e9c7 commit 2004cab

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/robot/libdocpkg/consoleviewer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def _show_inits(self, lib):
7474
def _show_keyword(self, kw, show_name=True):
7575
if show_name:
7676
self._header(kw.name, underline='-')
77-
self._data([('Arguments', '[%s]' % ', '.join(kw.args))])
77+
self._data([('Arguments', '[%s]' % ', '.join([str(arg) for arg in kw.args]))])
7878
self._doc(kw.doc)
7979

8080
def _header(self, name, underline):

src/robot/libdocpkg/robotbuilder.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,21 @@ def _get_args(argspec):
155155
optional=True))
156156
for arg_name in argspec.kwonlyargs:
157157
value_type = None
158-
default_value = argspec.defaults[arg_name]
158+
default_value = None
159+
optional = False
160+
if argspec.defaults and arg_name in argspec.defaults:
161+
default_value = argspec.defaults[arg_name]
162+
optional = True
159163
if argspec.types and arg_name in argspec.types:
160164
value_type = argspec.types[arg_name]
161165
arguments.append(ArgumentDoc(name=arg_name,
162166
value_type=value_type,
163167
default_value=default_value,
164168
argument_type='kwonlyargs',
165-
optional=True))
169+
optional=optional))
166170
if argspec.kwargs:
167171
arguments.append(ArgumentDoc(name=argspec.kwargs,
168172
argument_type='kwargs',
169173
optional=True))
174+
170175
return arguments

src/robot/libdocpkg/writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def LibdocWriter(format=None):
2828
return LibdocXmlWriter()
2929
if format == 'XML:HTML':
3030
return LibdocXmlWriter(force_html_doc=True)
31-
if format == 'JSON':
31+
if format == 'JSON': # ToDo: add JSON to Errors and writers etc
3232
return LibdocJsonWriter()
3333
raise DataError("Format must be either 'HTML', 'XML', 'JSON' or 'XML:HTML', "
3434
"got '%s'." % format)

0 commit comments

Comments
 (0)