Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Robot's libdoc xml format when defining 3rd party libraries #48

Open
Tattoo opened this issue May 1, 2019 · 3 comments
Open

Comments

@Tattoo
Copy link

Tattoo commented May 1, 2019

Generally with Robot Framework, one ends up with writing a lot of small libraries as well as employing the wealth of existing libraries in the ecosystem (see External tab)

Currently, Intellisense to be able to find keywords from 3rd party libraries by defining them keyword-by-keyword under rfLanguageServer.libraries setting.

Robot Framework has built-in documentation tool libdoc that 3rd party library developers are expected to use to document their libraries. This tool supports outputting library's keyword documentation in XML format, intended for editors and similar tools to have easily programmatically readable format. Users can also create these XML specs themselves as well from any library they might have.

It would be great, if I could simply define paths to the xmls I already have, something akin to this:

"rfLanguageServer.libraries": [
  {
    "name": "MyLibrary",
    "version": "1.0.0",
    "keywords": [
      { "name": "My Keyword 1", "args": ["arg1"], "doc": "documentation" },
      { "name": "My Keyword 2", "args": [],       "doc": "documentation" }
    ]
  },
 '/path/to/MyAnotherLibrary.xml',
'C:\\path\\to\\YetAnotherLibrary.xml'
]
@Snooz82
Copy link
Collaborator

Snooz82 commented Jun 14, 2019

@Tattoo
i made a small python class to convert libdoc xml to this json.
https://github.com/Snooz82/LibDoc2Json

@utknl
Copy link

utknl commented Feb 7, 2020

I am adding the generated json file inside library-docs however when I type the library name vscode says:

Value is not accepted. Valid values: "BuiltIn-2.7.7",......

Is there any suggestion on how to solve this issue?

@Ka55i0peia
Copy link

Ka55i0peia commented Jun 4, 2020

It might be a bit hacky. But i don't like to add all keyword to my settings for several reasons.

Instead of adding all kw to settings (.vscode/settings.json) like this

"rfLanguageServer.libraries": [{
    "name": "MyLibrary",
    "version": "1.0.0",
    "keywords": [
      { "name": "My Keyword 1", "args": ["arg1"], "doc": "documentation" },
      { "name": "My Keyword 2", "args": [],       "doc": "documentation" }
    ]
  }}

I rather simply like todo

"rfLanguageServer.libraries": [
        "MyLib-1.0.0"
    ],

To make this working, I used the nice helper tool from @Snooz82 (robotframework-LibDoc2Json) as follows:

  1. Generate the keyword json doc using robotframework-LibDoc2Json and copy the json file into the extention folder ~/.vscode/extensions/tomiturtiainen.rf-intellisense-2.8.0/server/library-docs/. Lets say we call this file MyLib-1.0.0.json
  2. Edit the extention package.json located at ~/.vscode/extensions/tomiturtiainen.rf-intellisense-2.8.0/package.json by adding an enumeration value to rfLanguageServer.libraries. Lets say we call this MyLib-1.0.0 as in the mini sample above.
  3. Restart vscode and you'll get context support in robot files. 😃

Anyhow, this is a simple workaround with the given tools. Let the extention work with the xml output of libdoc (or maybe trigger robot.libdoc to generate an xml from third party libs) would do the trick much more clean 👍

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

No branches or pull requests

4 participants