Skip to content

[ENHANCEMENT] Use Libdoc spec files and JSON resource files in RobotCode #689

Open

Description

@manykarim

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> list for specs."
  • python -m robot.libdoc <spec> list|show works today. But it doesn't support robotcode doc's pattern matching, Markdown output or --format json, and agents who were told to use robotcode doc don'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

  1. d-biehl commented on Nov 15, 2026

    @d-biehl
    Member

    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:

    • Where does the spec come from if the library isn't installed where the tests are written? Who generates it?
    • Where is it stored, and how would an agent, or a person, know that it's there and that it should use it?

    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?

  2. manykarim commented on Nov 16, 2026

    @manykarim
    Author

    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's requires-python was 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 doc to read specs. I also noticed you had listed "Libdoc spec files as targets" as a non-goal in the doc CLI 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-level specversion key, or an XML file with a <keywordspec> root. The current errors sent the agents (and would send people) in the wrong direction:

    python -m robot.libdoc -s raw String String.json
    robotcode doc keywords String.json Split
    [ 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'
    

    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 .libspec case 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.

  3. manykarim commented on Nov 16, 2026

    @manykarim
    Author

    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 run inside the workspace. So the error came from a misleading task, not from a missing library.

  4. changed the title [-][ENHANCEMENT] robotcode CLI: let `robotcode doc` read Libdoc spec files (.json, .libspec)[/-] [+][ENHANCEMENT] Use Libdoc spec files and JSON resource files in RobotCode[/+] on Nov 17, 2026
  5. added
    enhancement
    on Nov 17, 2026
  6. d-biehl commented on Nov 17, 2026

    @d-biehl
    Member

    Thanks again. Reading spec files only in robotcode doc wouldn'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 with ResourceFile.to_json()). RobotCode reads it as an empty resource today: ResourceEmpty for the import and KeywordNotFound for 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 KeywordNotFound for every call.

    The idea is that a spec file, generated beforehand and kept in the project, stands in for such a library:

    • The project says which spec goes with which import; RobotCode doesn't search for spec files on its own. One way is a # robotcode: comment at the import, like the comments that change diagnostics, with the path of the spec relative to the file, for example:
      Library    Remote    http://127.0.0.1:8270    # robotcode: libspec[specs/Remote.libspec]
      The spec then belongs to that import with its arguments. A mapping in robot.toml could follow for a library that many files import.
    • The spec is used only when the import fails: where the server runs or the library is installed, the real library is used, on a CI runner the spec. A diagnostic says when a spec stands in, and why, so that an outdated spec doesn't go unnoticed.
    • Robot Framework already writes spec files: python -m robot.libdoc Remote::http://127.0.0.1:8270 specs/Remote.libspec, with import arguments as MyLibrary::arg1::arg2. A command in the editor could do the same for an import later.
    • robotcode doc would 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.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions