Repository navigation
Description
Is your enhancement request related to a problem? Please describe.
robotcode doc can't read a Libdoc spec file. robot.libdoc itself takes a spec file as its input (python -m robot.libdoc String.json list Split works), but robotcode doc keywords String.json Split fails:
-
A JSON spec is parsed as a JSON resource file (supported since RF 7.0), which fails on the spec's first key:
python -m robot.libdoc String String.json robotcode doc keywords String.json Split; echo "exit: $?"
[ ERROR ] Parsing JSON resource file '.../String.json' failed: Creating 'robot.running.ResourceFile' object from dictionary failed: 'robot.running.ResourceFile' object does not have attribute 'specversion' exit: 1 -
An XML spec is rejected as an import:
python -m robot.libdoc String String.libspec robotcode doc keywords String.libspec Split; echo "exit: $?"
[ ERROR ] Importing library '.../String.libspec' failed: Not a valid file or directory to import. exit: 1
robotcode doc keyword behaves the same. The help text names a library, library path, resource or suite file as TARGET, so I read this as a gap rather than a bug.
Where this comes up: a spec file is often the only documentation at hand, for example when a library can't be installed where the tests are written (a desktop or mobile library on a CI runner). I run an eval that gives AI agents a committed PlatynUI.BareMetal.json spec and asks them to check keyword names against it. Agents that tried robotcode doc keywords specs/PlatynUI.BareMetal.json got the specversion error. From the message they couldn't tell that spec files aren't supported, so they fell back to parsing the 84 KB JSON with python -c one-liners, which took 12 to 16 tool calls per session.
Describe the solution you'd like
When TARGET is a Libdoc spec file, load it with robot.libdocpkg.LibraryDocumentation, which already reads .json, .libspec and .xml specs, and show it like an imported library. A JSON spec can be told apart from a JSON resource file by its top-level specversion key; an XML spec by its <keywordspec> root element. Import arguments and robot.toml settings would not apply to a spec, since it is already generated.
Describe alternatives you've considered
- If reading specs is out of scope, a clearer error for this case would already help, for example: "TARGET looks like a Libdoc spec file; robotcode doc reads libraries, resources and suites. Use
python -m robot.libdoc <spec> listfor specs." python -m robot.libdoc <spec> list|showworks today. But it doesn't supportrobotcode doc's pattern matching, Markdown output or--format json, and agents who were told to userobotcode docdon't think of it.
Additional context
I reproduced both cases with the String library on 2.8.0 (Robot Framework 7.4.2) and on 2.9.0.dev186 (Robot Framework 7.5.1). On 2.8.0 the XML case printed the error but exited 0; 2.9.0.dev186 exits 1. I searched the issues for "libspec", "specversion" and "doc keywords json" and found no existing report.
AI / tooling disclosure
This request was prepared with assistance from Claude Code (Anthropic), which also ran the reproduction and the eval it refers to. I reviewed the text manually and re-ran the steps above locally on 2.8.0 and 2.9.0.dev186.
Environment
- Scope: robotcode CLI only (no VS Code / IntelliJ involved)
- RobotCode version: 2.8.0 (PyPI
robotcode[all]); also 2.9.0.dev186 - OS: Linux (Ubuntu, kernel 6.8, x86_64)
- Python version: 3.13.11 / 3.12.12
- Robot Framework version: 7.4.2 / 7.5.1
Activity
d-biehl commentedon Nov 15, 2026
Thanks for the detailed report.
Before I add something, I'd like to understand where this comes up outside the eval. There, the agents get the spec and are told where it is. In a real project I don't see yet how that would work:
I'm not against reading specs in
robotcode doc, but I only want to add it if there's a real workflow that needs it. Could you describe such a case?manykarim commentedon Nov 16, 2026
Thanks for asking. Looking into it, I have to correct my premise. Both libraries in that eval install fine where the agent works (PlatynUI has Linux, macOS and Windows wheels and needs no display for
robotcode doc, and AppiumLibrary is pure Python). The agents only had a spec because our fixture'srequires-pythonwas wrong, so the library never got installed. We'll fix that on our side.So I don't have a concrete project that needs
robotcode docto read specs. I also noticed you had listed "Libdoc spec files as targets" as a non-goal in thedocCLI design. If you want to keep it that way, I'd be happy with the smaller alternative from the issue: a clear error when TARGET is a JSON file with a top-levelspecversionkey, or an XML file with a<keywordspec>root. The current errors sent the agents (and would send people) in the wrong direction:The message says the file is a broken resource file, not that spec files aren't supported. The agents read it as a problem with the file and started parsing the JSON themselves. The
.libspeccase is similar:Importing test library '.../String.libspec' failed: Not a valid file or directory to import.(robotcode 2.8.0, Robot Framework 7.5.1, both exit 1.)Otherwise feel free to close this.
AI disclosure: Claude Code (Anthropic) helped check the eval and draft this reply. I reviewed it.
manykarim commentedon Nov 16, 2026
Small correction to my last comment: the library was installed in the eval environment. The agents used the spec because our task prompt pointed them to it ("a libdoc spec is in specs/"), which was misleading. The fixture bug only broke
uv runinside the workspace. So the error came from a misleading task, not from a missing library.[-][ENHANCEMENT] robotcode CLI: let `robotcode doc` read Libdoc spec files (.json, .libspec)[/-][+][ENHANCEMENT] Use Libdoc spec files and JSON resource files in RobotCode[/+]d-biehl commentedon Nov 17, 2026
Thanks again. Reading spec files only in
robotcode docwouldn't add much, because nothing else in RobotCode can use them yet: the analysis, completion and the other language features can't take a spec, and they don't read JSON resource files either, which Robot Framework runs since 6.1. So I'm keeping this issue open for the larger idea. Here is what I have in mind; nothing of it is planned or scheduled yet.JSON resource files
Robot Framework 6.1 and later import a resource file in JSON format (
Resource shop.json, written withResourceFile.to_json()). RobotCode reads it as an empty resource today:ResourceEmptyfor the import andKeywordNotFoundfor every keyword from it. RobotCode should read it like any other resource file.Libdoc spec files for libraries that can't be loaded
Some libraries only have keywords while they run: a Remote library needs its server, a dynamic library can build its keywords from its import arguments or from a device or a connection, and some libraries can't be installed where the code is analyzed, such as a Windows-only library on a Linux CI runner. The analysis then reports the failed import and
KeywordNotFoundfor every call.The idea is that a spec file, generated beforehand and kept in the project, stands in for such a library:
# robotcode:comment at the import, like the comments that change diagnostics, with the path of the spec relative to the file, for example:robot.tomlcould follow for a library that many files import.python -m robot.libdoc Remote::http://127.0.0.1:8270 specs/Remote.libspec, with import arguments asMyLibrary::arg1::arg2. A command in the editor could do the same for an import later.robotcode docwould show such a library through the suite that imports it, and could then also take a spec file as TARGET.Open points: the name and form of the comment, whether a given spec is used only when the import fails or always, the mapping in
robot.toml, and generating specs from the editor.Use cases and comments are welcome, especially from projects with Remote or dynamic libraries.