Skip to content

Commit

Permalink
Merge pull request #47 from tkoukkari/tko_kw_full_comments
Browse files Browse the repository at this point in the history
added support for command d(ocs)
  • Loading branch information
xyb authored Feb 5, 2020
2 parents 91285b2 + 1cb8c24 commit b516237
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 19 additions & 2 deletions DebugLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,15 @@ def build(self, lib):


@memoize
def get_lib_keywords(library):
def get_lib_keywords(library, long_format=False):
"""Get keywords of imported library"""
lib = ImportedLibraryDocBuilder().build(library)
keywords = []
for keyword in lib.keywords:
doc = keyword.doc.split('\n')[0]
if long_format:
doc = keyword.doc
else:
doc = keyword.doc.split('\n')[0]
keywords.append({'name': keyword.name,
'lib': library.name,
'doc': doc})
Expand Down Expand Up @@ -564,6 +567,20 @@ def complete_keywords(self, text, line, begin_idx, end_idx):

complete_k = complete_keywords

def do_docs(self, kw_name):
"""Get keyword documentation for individual keywords
d(ocs) [<keyword_name>]
"""

for lib in get_libs():
for keyword in get_lib_keywords(lib, long_format=True):

This comment has been minimized.

Copy link
@tkoukkari

tkoukkari Mar 10, 2020

Contributor

Actually, sorry, if named argument is used here I get:
"TypeError: wrapper() got an unexpected keyword argument 'long_format'"

Having just True there and it works. Unfortunately I don't understand enough how this wrapper works. Any insights? If not, I would propose changing this part back to True (from long_format=True)

if keyword['name'].lower() == kw_name.lower():
print(keyword['doc'])
return
print("could not find documentation for keyword {}".format(kw_name))

do_d = do_docs

class DebugLibrary(object):

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Or you can run it standalone as a ``RobotFramework`` shell::

Documented commands (type help <topic>):
========================================
EOF exit help k keywords l libs pdb s selenium
EOF d docs exit help k keywords l libs pdb s selenium

> log hello
> get time
Expand Down

0 comments on commit b516237

Please sign in to comment.