Libdoc throws error message

595 views
Skip to first unread message

GerhardH

unread,
Feb 5, 2013, 8:52:30 AM2/5/13
to robotframe...@googlegroups.com
Hello all,

I am working with newest versions of RF:
   Python 2.7.3
   Jython 2.5.3
   RF 2.7.6

I implemented my own Java Library, called DOTTLibrary.jar, extending AnnotationLibrary; I made SwingLibrary available in the Robot lib directory, and my
keyword it is callable successfully.

I want to create the keyword description as HTML and XML file and called libdoc (as
the library is a Java library, I called libdoc via jython, from the directory where
the library is located), but libdoc throws an error:

C:\Robot\Testautomation\lib>jython -m robot.libdoc -f html DOTTLibrary.jar DOTTL
ibrary.html
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Robot\Jython\Lib\runpy.py", line 85, in run_module
loader = get_loader(mod_name)
File "C:\Robot\Jython\Lib\pkgutil.py", line 464, in get_loader
return find_loader(fullname)
File "C:\Robot\Jython\Lib\pkgutil.py", line 474, in find_loader
for importer in iter_importers(fullname):
File "C:\Robot\Jython\Lib\pkgutil.py", line 425, in iter_importers
__import__(pkg)
ImportError: No module named robot

Tools.jar from Java JDK, and also DOTTLibrary.jar, is available in the CLASSPATH.
So how is the correct call and the correct environment of libdoc.py?

Best regards Gerhard

Kevin O.

unread,
Feb 5, 2013, 11:28:32 AM2/5/13
to robotframe...@googlegroups.com
When you type jython -m robot.libdoc, you are telling Jython to look for the installed module robot, which is installed in Python not Jython (Jython has its own site-packages folder), thus the error.

If you get the standalone robot framework jar on the classpath along with your library, tools.jar, and the standalone JavaLib-Core, you should be able to do this:
java org.robotframework.RobotFramework libdoc <your class name> DOTTLibrary.html

Alternatively you can invoke libdoc similarly to how jybot works (there is no file in the Scripts folder for launching libdoc just run and rebot).
jython <path to Python install>\Lib\site-packages\robot\libdoc.py <your class name> DOTTLibrary.html

Note that you should pass in your class name (the one that extends AnnotationLibrary), not the file name of a .jar or .java file. You want libdoc to load the library as a dynamic api library and get the data from your @RobotKeyword and @ArgumentNames annotations and not the javadoc comments.

If you are using Maven I strongly suggest looking at the RF plugin for Maven because it makes this much easier.

Kevin

Kevin Ormbrek

unread,
Feb 5, 2013, 8:31:23 PM2/5/13
to GerhardH, robotframe...@googlegroups.com
The RF jar is a separate download that you do not need, but it provides Jython & RF in one file.
If you are using any version of JavaLib Core < 1.0.3 you get an NPE if you didn't overload getKeywordDocumentation to handle __intro__ as seen in https://github.com/robotframework/JavalibCore/issues/2. see https://github.com/robotframework/JavalibCore/issues/7


On Tue, Feb 5, 2013 at 11:25 AM, GerhardH <gerhar...@optimized-networks.net> wrote:
Hi Kevin,

I installed RF via the Win64 installer; I don´t find any standalone robot framework jar (I assume it would be under <python-install>\Lib\site-packages?

So I tried this (DOTTLibrary is also the name of the main class):
C:\Robot\Testautomation\lib>jython C:\Robot\Python\Lib\site-packages\robot\libdoc.py -f HTML DOTTLibrary DOTTLibrary.html
Calling dynamic method 'getKeywordDocumentation' failed: NullPointerException


Any other idea? I do not use Maven.

Thanks and best regards
Gerhard


Pekka Klärck

unread,
Feb 18, 2013, 5:00:37 PM2/18/13
to korm...@gmail.com, robotframe...@googlegroups.com
2013/2/5 Kevin O. <korm...@gmail.com>:
> When you type jython -m robot.libdoc, you are telling Jython to look for the
> installed module robot, which is installed in Python not Jython (Jython has
> its own site-packages folder), thus the error.

This is all correct. Notice, though, that Robot could be installed
under Jython using the source distribution.

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

Alejandro Serrano

unread,
Jun 13, 2013, 6:16:48 PM6/13/13
to robotframe...@googlegroups.com, korm...@gmail.com
Hello,

I am also working on my own Java Library extending AnnotationLibrary. When I try to generate the documentation through libdoc, it successfully creates the XML and HTML files.
However these files only contains the methods of my Library class instead of the real keywords.

Something like this:

MyOwnJavaLibrary

Library scope: global
Named arguments: not supported

Introduction
MyOwnJavaLibrary

@author Alejandro Serrano

Shortcuts

Get Keyword Arguments · Get Keyword Documentation · Get Keyword Names · Run Keyword

Keywords

Keyword Arguments Documentation
Get Keyword Arguments keywordName
Get Keyword Documentation keywordName
Get Keyword Names
Run Keyword keywordName, *args
Altogether 4 keywords.
Generated by libdoc on 2013-06-03 13:43:35.

I'm calling libdoc via jython:
     jython.bat -Dpython.path=C:\Python27\Lib\site-packages -m robot.libdoc MyOwnJavaLibrary.java MyOwnJavaLibrary.html

It seems that libdoc is not taking the class as a dynamic library. I would greatly appreciate any help you can give me in working this problem.

Thanks,
Alejandro Serrano.

Kevin O.

unread,
Jun 13, 2013, 10:20:22 PM6/13/13
to robotframe...@googlegroups.com, korm...@gmail.com
This has tripped up a lot of people. 
See sub-section "Python libraries and dynamic libraries with name or path" under Library documentation tool in the user guide.
If you are building with Maven, you should instead use the Robot Framework plugin for Maven to invoke libdoc.
When invoking as you are, you should pass in the library name, e.g. com.example.MyOwnJavaLibrary as opposed to giving it the path to a java file.  Simply MyOwnJavaLibrary  f you are putting your class in the default package. libdoc will load the library as a dynamic one and should be pulling the contents of the @RobotKeyword annotations.  Don't forget to set the CLASSPATH before that or in the arguments to jython or in the arguments to libdoc.

Kevin

Reply all
Reply to author
Forward
0 new messages