Skip to content

Add code-completion for keywords #20

Closed

Description

@fabioz
No description provided.

Activity

  1. added this to the 0.0.4 milestone on Feb 8, 2020
  2. Snooz82 commented on Mar 3, 2020

    @Snooz82
    Contributor

    Hi Fabio,

    With Robot Framework there is a tool coming that documents Robot Libraries and Keyword Resources to XML.

    It is called Libdoc (robot.libdoc)
    python -m robot.libdoc --format XML:HTML SeleniumLibrary sl.xml
    the format XML:HTML is used to tell libdoc to embed HTML rendered documentation text into the XML.

    i think it could be very useful, if Language Server is able to read these XML Files.
    One issue with getting all possible Keywords is, that you have three to four different sources where keywords can come from.

    1. *.Resource Files. Here are the Robot Keywords defined, written by users.
    2. *.py Libraries. (static) These are modules or classes where the methods/functions are the keywords.
    3. *.py Libraries (dynamic) These classes have the keywords somewhere else and Robot Framework get the list of keywords by calling the method get_keyword_names()
      These can not be parsed but actually "executed" to get the Keywords. This could be an issue.
    4. Remote Libraries: These are Libraries written in a different language or just running on an other computer. The Remote Library connects to the Remote Server with xml-rpc and the Remote Server has the actual Library loaded. Without the Remote Server running it is not possible to get the names of the keywords.

    Because of type 3 and 4 and because often when writing tests, the remote Libraries are not available on this particular machine, it would be good to be able to read keywords from XML.
    Then the users can generate the XML once and just place it in their project folder.

    Maybe these XML Files could even be the first implementation where to get the list of keywords.
    And the second step could be using Robot Frameworks parser to read User Keywords from *.resource files.

    Kind Regards
    René

  3. Snooz82 commented on Mar 3, 2020

    @Snooz82
    Contributor

    snipped of the XML:

    <keywordspec name="SeleniumLibrary" type="library" format="HTML" generated="20200303 14:38:50">
        <version>4.2.0</version>
        <scope>global</scope>
        <namedargs>yes</namedargs>
        <doc>&lt;p&gt;SeleniumLibrary is a web testing library for Robot Framework.&lt;</doc>
        <init>
            <arguments>
                <arg>timeout=5.0</arg>
                <arg>implicit_wait=0.0</arg>
                <arg>run_on_failure=Capture Page Screenshot</arg>
                <arg>screenshot_root_directory=None</arg>
                <arg>plugins=None</arg>
                <arg>event_firing_webdriver=None</arg>
            </arguments>
            <doc>&lt;p&gt;SeleniumLibrary can be imported with several optional arguments.&lt;</doc>
            <tags>
            </tags>
        </init>
        <kw name="Add Cookie">
            <arguments>
                <arg>name</arg>
                <arg>value</arg>
                <arg>path=None</arg>
                <arg>domain=None</arg>
                <arg>secure=None</arg>
                <arg>expiry=None</arg>
            </arguments>
            <doc>&lt;p&gt;Adds a cookie to your current session.&lt;</doc>
            <tags>
            </tags>
        </kw>
        <kw name="Add Location Strategy">
            <arguments>
                <arg>strategy_name</arg>
                <arg>strategy_keyword</arg>
                <arg>persist=False</arg>
            </arguments>
            <doc></doc>
            <tags>
            </tags>
        </kw>
    </keywordspec>```
    
  4. fabioz commented on Mar 4, 2020

    @fabioz
    ContributorAuthor

    @Snooz82 this seems like a good idea for a first implementation... I was thinking about using the api directly, but having that intermediary step with the xml seems good and can make things more flexible (I can probably generate those on-demand for the user and have instructions for the user to generate those when the language-server can't do it).

    I think it could be a custom extension (maybe .robotapi) to be able to locate it (and maybe even allow libraries to provide it themselves)...

    That way we'd search for these files in the following places:

    • PYTHONPATH folders,
    • Workspace folders
    • ${extension}/robotframework/api/ (this is the place where the automatically generated files would be searched -- it'd probably have some intermediary directories so that we can match a python interpreter).

    @pekkaklarck right now I think that one of the difficult things for the language server is discovering what are the libraries available. Having .robotapi files as proposed could be a solution to discover those.

    So, we could ask for libraries to provide such a file and distribute it to make it possible to discover it automatically in the language server -- what do you think, is that something reasonable?

    -- on some cases, after the user imports a library the language server could do that automatically, but if that file is already provided by a library it'd be able to suggest it as an import.

  5. pekkaklarck commented on Mar 4, 2020

    @pekkaklarck

    I agree supporting XML files that Libdoc can generate is a good idea. Good news is that Libdoc can also read these files using its LibraryDocumentation API that also handles all other kind of libraries. This is why robotframework/robotframework#3448 is so important.

  6. fabioz commented on Mar 5, 2020

    @fabioz
    ContributorAuthor

    Note: the extension to be used is .kwspec.

  7. Snooz82 commented on Mar 5, 2020

    @Snooz82
    Contributor

    @pekkaklarck @fabioz
    As long as you have no strong opinions, i would propose to use *.libspec because RED (the eclipse plugin) already uses this extension for the XML files which it generates with Libdoc.

    Using the same extension would help them to migrate to language Server later and would somehow standardize the ext.

  8. modified the milestones: 0.0.4, 0.0.5 on Mar 5, 2020
  9. fabioz commented on Mar 5, 2020

    @fabioz
    ContributorAuthor

    I'm ok on any extension... Is .libspec reasonable for you @pekkaklarck?

  10. pekkaklarck commented on Mar 6, 2020

    @pekkaklarck

    I'm fine with .libspec if it's used by RED already. I'll submit an issue about Robot's LibraryDocumentation automatically supporting this extension when reading information from files.

  11. pekkaklarck commented on Mar 6, 2020

    @pekkaklarck

    Submitted robotframework/robotframework#3491 about official *.libspec support.

    Would it be a good idea to specify that libspec files should have their library and keyword docs in HTML? Libdoc nowadays supports that as XML:HTML format (robotframework/robotframework#3301) and I would expect it to be easiest for editors if they didn't need to think about different doc formats. If we do that, then

    python -m robot.libdoc Example Example.libspec
    

    should just automatically use the XML:HTML format. Deciding about this is part of robotframework/robotframework#3491 so let's continue discussion there.

  12. fabioz commented on Mar 30, 2020

    @fabioz
    ContributorAuthor

    The initial implementation for code-completion for keywords is now done in the language server (0.0.5) -- just released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions