Browsing Library Documentation
robotcode doc shows the documentation of a library, a resource file or the keywords of a suite file the way your project sees it: with the installed library versions, the project's robot.toml configuration and profiles, its python path, variables and variable files, and the import arguments you give. The documentation is generated anew on every call, so a change to a library or resource shows up the next time you run the command.
The output is Markdown: rendered on a colour terminal, raw Markdown in a pipe, with --no-color and in AI-agent sessions, a Markdown file with -o, or JSON with the global --format json for scripts and editor integrations.
Who this is for:
- Developers who want to look up a keyword, its arguments and its documentation without leaving the terminal.
- AI coding agents that need the keywords of the installed libraries and of the project's resource files, instead of guessing from generic knowledge.
- Documentation builds that publish the documentation of a library or resource file as Markdown.
- Editor integrations, which read the JSON output.
The four subcommands take the same target and the same configuration options:
| Subcommand | Use it when you want to … |
|---|---|
lib |
… read the full documentation of a library, resource file or suite file |
keywords |
… list the keywords with their arguments and a short description, optionally filtered |
keyword |
… read the full documentation of one or more keywords |
browse |
… browse the full documentation in the terminal, with links, search and back/forward |
For the exhaustive option list see the auto-generated CLI reference.
Quick start
Section titled “Quick start”# The full documentation of a standard libraryrobotcode doc lib Collections
# Every keyword of Collections with "dictionary" in its namerobotcode doc keywords Collections dictionary
# The documentation of one keywordrobotcode doc keyword Collections "Get Match Count"
# A resource file of the project, with a keyword that has embedded argumentsrobotcode doc keyword resources/common.resource "Open Chrome Browser"
# Browse a library in the terminal viewerrobotcode doc browse BuiltIn
# Write the documentation of a resource file to a Markdown filerobotcode doc lib -o common.md resources/common.resourceTargets
Section titled “Targets”Every subcommand documents exactly one TARGET, like Robot Framework's Libdoc:
- A library name, such as
Collections,SeleniumLibrary, a module ormodule.Class. - The path of a library file, such as
lib/MyLibrary.py. - The path of a resource file, with an extension Robot Framework accepts for resource imports in the installed version, such as
.resource,.robotor.txt, and with Robot Framework 7.5 also Markdown resource files (.md). Resource files take no import arguments. - The path of a suite file, a file with a
*** Test Cases ***or*** Tasks ***section. The keywords of its*** Keywords ***section are documented under the suite's name, with the typeSUITE. - The path of a suite initialization file, such as
tests/__init__.robot. Its keywords are documented under the name Robot Framework gives the suite of its directory:tests/01__login/__init__.robotbecomesSuite *Login*. ANamesetting in the file, available since Robot Framework 6.1, wins.
Relative paths are resolved against the directory you run the command in (see --base-dir). A library name that exists as a path is imported by that path, as Libdoc does, so a directory is imported as a library too. Whether the target is a file or a library is decided after the variables in it are resolved, so -v COMMON:resources/common.resource '${COMMON}' documents the resource file.
Import arguments
Section titled “Import arguments”Import arguments follow the target, separated by ::, as in Libdoc:
robotcode doc keywords 'SeleniumLibrary::plugins=MyPlugin'robotcode doc lib 'Remote::http://localhost:8270'Variables in the target and in its arguments are resolved with the project's variables (see Configuration), so this works too:
robotcode -p dev doc keywords 'MyLibrary::${MODE}'The target is split at :: before variables are resolved. An argument that itself contains ::, such as an IPv6 address, is therefore passed through a variable:
robotcode doc lib -v 'HOST:[::1]' 'Remote::http://${HOST}:8270'Quote the target in the shell, so that the shell leaves ${…} alone. A backslash in the target is part of its text, as in a Windows path such as '${CURDIR}\resources\common.resource'; it is not an escape character as in Robot Framework data.
Configuration
Section titled “Configuration”robotcode doc loads the target the way robot loads it:
robot.tomland the selected profiles (robotcode -p <profile> doc …) provide the environment variables (env), the python path, the variables and variable files, and the languages.-v/--variable,-V/--variablefileand-P/--pythonpathadd variables, variable files and python path entries, as the options of the same name ofrobotdo. Relative paths given to-Vand-Pare relative to the directory you run the command in, like the target.--language LANGadds a language to the languages of the configuration, so that translated resource and suite files can be read (Robot Framework 6.0 or newer). Robot Framework 5.0 has no language support; a language from the configuration or from--languageis rejected there.--base-dir DIRsets the directory for${CURDIR}and for relative paths in the target. Its default is the directory you run the command in.
The analysis settings of [tool.robotcode-analyze] and RobotCode's cache are not used: every call imports the library or parses the file anew.
Output
Section titled “Output”Markdown
Section titled “Markdown”Without --format, lib, keywords and keyword write Markdown. On a colour terminal it is rendered and paged like the other robotcode commands; with --no-color, in a pipe and in AI-agent sessions it is written as raw Markdown.
With -o/--output FILE the Markdown is written to FILE instead, as UTF-8 with \n line endings on every platform. A relative FILE is relative to the directory you run the command in, and a missing directory is created. -o cannot be combined with any --format other than text.
The page of lib has:
- the title with the type and the name (
Library *Collections*), the version and the scope; Introduction, the documentation of the library, resource or suite file, when there is any;Importing, with the arguments of the library, when it takes any;Keywords, starting with an index that links to every keyword, followed by the keywords ordered by name as Libdoc orders them; keywords taggedrobot:privateare left out;Data types, the types the keywords use, with Robot Framework 6.1 or newer.
The headings get the anchors GitHub gives them, so the index, the table of contents and the links from one keyword to another work in GitHub's and in VS Code's Markdown preview. References to data types in the documentation link to their entry under Data types, and so do the types in the argument tables and the return types, such as int to integer (Standard); the rest of a type, such as brackets, the values of a Literal and types without an entry, stays inline code. Robot Framework variables in the text, such as ${name}, are written as inline code, so that Markdown renderers with math support do not show them as formulas; documentation written in HTML or reStructuredText stays as it is.
With the global --format json (or json_indent), lib prints one object:
| Field | Content |
|---|---|
name |
The name of the library, resource file or suite. |
type |
LIBRARY, RESOURCE or SUITE. |
version, scope |
The version, empty when there is none, and the scope (GLOBAL, SUITE or TEST). |
source, lineno |
The file the documentation comes from, empty when it is unknown, and the line in it, -1 when it is unknown. |
markdown |
The page, as robotcode --no-color doc lib prints it. |
keywords |
One entry per keyword, in the order of the page. |
types |
One entry per data type, in the order of the page, with name and anchor: the anchor of its heading in markdown, to which the links to the type point. |
A keyword entry has name, anchor (the anchor of its heading in markdown), args (the arguments as one line of text), short_doc (the first paragraph of the documentation, as one line), tags, doc (the documentation as Markdown), and source and lineno, the file of the keyword and the line in it, empty and -1 when they are unknown. References in doc and short_doc are written as inline code.
keywords and keyword print an object with the same fields except markdown and types; its keywords holds only the selected keywords.
robotcode --format json doc keywords Collections dictionary | jq -r '.keywords[].name'lib: the full documentation
Section titled “lib: the full documentation”robotcode doc lib Collectionsrobotcode doc lib resources/common.resourcerobotcode doc lib -o builtin.md BuiltInlib prints the page described in Markdown. The REPL's .doc command shows the same page for a library or resource the session has imported.
keywords: an overview of the keywords
Section titled “keywords: an overview of the keywords”robotcode doc keywords Collections # every keywordrobotcode doc keywords Collections dictionary # names that contain "dictionary"robotcode doc keywords Collections "get*list" # "get", later followed by "list": Get From List, …robotcode doc keywords Collections append insert # names that contain "append" or "insert"robotcode doc keywords resources/common.resource --tag smoke # keywords tagged "smoke"keywords lists the keywords of the page, one per line, with the name, the arguments and the first paragraph of the documentation.
- A PATTERN selects the keywords whose name contains it; several patterns select the keywords that match any of them.
*and?are wildcards. Case, spaces and underscores are ignored, soget_from_listfindsGet From List. --tag TAG, which can be given more than once, selects the keywords with a tag that matches TAG as a whole, with the same wildcards and ignoring case, spaces and underscores. Patterns and tags apply together.
When no keyword matches, the output says so and the exit code is 0.
keyword: the documentation of single keywords
Section titled “keyword: the documentation of single keywords”robotcode doc keyword Collections "Get Match Count"robotcode doc keyword BuiltIn "Should Be*"robotcode doc keyword resources/common.resource "Open Chrome Browser"keyword shows the full documentation of the keywords the NAMEs select, followed by the data types their arguments use. A NAME selects:
- the keyword whose name matches it, ignoring case, spaces and underscores;
- the keywords that match it as a pattern with
*and?; - the keywords with embedded arguments whose name matches it, so
Open Chrome BrowsershowsOpen ${browser} Browser.
A NAME that selects no keyword is reported on standard error, together with similar keyword names, and the exit code is 1. The keywords the other NAMEs select are still shown.
browse: the documentation in the terminal viewer
Section titled “browse: the documentation in the terminal viewer”robotcode doc browse Collectionsbrowse opens the page of lib in the documentation viewer of the REPL. Tab moves through the links, f or Enter follows one, [ and ] go back and forward, and / searches; the REPL guide lists all keys of the viewer. q closes it.
s opens a sidebar with the outline of the page: the sections of the introduction with their subsections, Importing, every keyword and every data type, each indented below the entry it belongs to. Typing filters the list with the rules of the keywords patterns and keeps an entry while it or one of the entries below it matches. ↑ and ↓ select an entry, the mouse wheel scrolls the list, Enter or a click jumps to the heading of the entry, and Esc hides the sidebar.
- In a terminal with at least 94 columns, the sidebar stands left of the page, which is rendered narrower. It stays open after a jump, and
smoves the focus back to it.Escon the page hides the sidebar; only the nextEsccloses the viewer. - In a narrower terminal, the sidebar lies over the left part of the page, which keeps its width, and closes after a jump.
In AI-agent sessions, in a pipe and without a terminal, browse prints the page as robotcode doc lib does.
When a target cannot be loaded
Section titled “When a target cannot be loaded”Like Libdoc, robotcode doc documents nothing when the target cannot be found, imported or initialised. It reports the error on standard error and exits with 1:
- a library that cannot be imported, or whose initialisation with the given arguments fails — also when it could be loaded without the arguments;
- a library whose keywords cannot be read, such as
Remotewithout a running server; - a variable in the target or its arguments that is not defined;
- a resource or suite file that does not exist, or that can be read neither as a resource file nor as a suite file — the error is the one Robot Framework reports for it as a resource file;
- import arguments given to a resource or suite file;
- an option Robot Framework rejects, such as a language on Robot Framework 5.0.
Other load errors, such as a keyword of a library that cannot be created or an error in a variable file, are reported on standard error while everything else is documented, and the exit code is 0. So are the errors and warnings Robot Framework itself reports while it reads a file.
| Exit code | Meaning |
|---|---|
0 |
The documentation was written. |
1 |
The target could not be loaded, or a NAME of keyword selected no keyword. |
2 |
Invalid usage, such as an empty target or -o together with --format json. |
251 |
A dry run (robotcode --dry doc …) printed the target and the options it would load it with. |
Libraries that need a running test
Section titled “Libraries that need a running test”A library whose keywords only exist while Robot Framework runs — for example, one that calls BuiltIn().get_variable_value(...) in get_keyword_names — cannot be documented this way: the command aborts with the library's error, as Libdoc does. Import the library in the REPL or stop in it with robot-debug, and use .doc <library> there, which shows the documentation of the loaded library.
VS Code
Section titled “VS Code”In VS Code, the Documentation Viewer shows the same documentation in an editor tab, with an outline, links between keywords, search and history.
Released under the Apache-2.0. Copyright © 2022-present Daniel Biehl