mirror of
https://github.com/huggingface/lerobot.git
synced 2026-08-08 17:39:44 +00:00
docs: write the API reference docstrings
Every docstring change for the API reference, on top of the infrastructure PR which contains none. Two halves: a repo-wide pass over what the renderer cannot handle, and `src/lerobot/robots/` taken to 100% as the worked example. **Renderer fixes, repo-wide.** Both of these render incorrectly the moment `[[autodoc]]` is on, and both were verified against a local build: - 24 Sphinx roles across three files. They are unsupported and render as literal `:pymeth:` text. Method references become doc-builder cross-references; the ones pointing at instance attributes become inline code, since attributes get no autodoc anchor and a cross-reference would be a dead link. - 43 `Attributes:` sections across 27 files. doc-builder parses a bare `Attributes:` as a synonym for `Parameters:` — `Robot`'s attributes rendered inside `<paramsdesc>`, presenting `config_class` and `name` to readers as constructor arguments when the actual parameter is `config`. Where the original carried no type, the type comes from the real class annotation rather than being invented. The four base classes every other module inherits from — `robot.py`, `teleoperator.py`, `motors_bus.py`, `camera.py` — are rewritten to the standard, since subclasses document only their deviations from that text. Three docstring errors corrected in passing: `Teleoperator.get_action` pointed at `observation_features`, which `Teleoperator` does not have; `send_feedback` documented a `Returns:` for a method returning `None`; and `config_class` was typed `RobotConfig` instead of `type[TeleoperatorConfig]`. **`robots/`, 109/306 -> 306/306.** The configuration dataclasses were the substantial part. Their fields were documented only with `#` comments above each field, which doc-builder cannot see: before this, `SO101FollowerConfig` rendered all eleven of its fields with not one description. Each config now carries an `Args:` block on the concrete registered class, covering inherited fields too, because doc-builder renders only a class's own docstring and several of these configs are thin multiple-inheritance shims whose body is `pass`. The inline comments are kept rather than removed, so fields stay annotated in the source as well as on the rendered page. Note this leaves each field described twice, and only the `Args:` block is checked against the signature by `make check-docstrings`, so the two can drift. Writing them turned up things worth stating plainly on the page rather than leaving in a comment: which configs have no serial port at all because they talk over a network or the cloud (Reachy 2, Unitree G1, LeKiwi's client, EarthRover), which manage their own calibration so `calibration_dir` does nothing, that OpenArm's default joint limits are deliberately tiny until `side` is set, and that reBot's `port` means a different thing depending on `can_adapter`. Two pre-existing docstring bugs that the doctest infrastructure surfaced are fixed here: `SerialMotorsBus` used `>>>` inside a ```bash block to show CLI output, which doctest read as Python and failed on with a SyntaxError, and `MotorsBus.torque_disabled`'s example referenced an undefined name. `ensure_safe_goal_position` gains a genuinely executing example so the doctest gate is not vacuous. **Gates ratcheted**, each of which the infrastructure PR left deliberately loose: - `check_docstrings.py`'s ignore list emptied — the ten objects it held all had bare `Attributes:` sections, now converted. - `check_config_docstrings.py`'s ignore list emptied — every registered robot config documents its port and calibration semantics. - `robots/` removed from the ruff `D` per-file-ignores, as are the two package-root files, whose one-line docstring issues are fixed here. D100 and D104 are ignored globally instead: they ask for a banner on every file and every `__init__.py`, which appears on no rendered page. - `interrogate` raised 52 -> 55 against a measured 55.3%. - The four `robots/` files carrying examples added to the doctest allowlist, which shipped empty. Verified: all 66 changed files under `src/lerobot/` are provably docstring-only (AST with docstrings stripped is byte-identical to main), no comment line is removed anywhere in `robots/`, and 708 tests pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,3 +10,9 @@
|
||||
# `utils/check_doctest_list.py` does not care which way round it is.
|
||||
#
|
||||
# Keep alphabetically sorted: `make check-doctest-list` enforces it, `make fix-docstrings` sorts it.
|
||||
src/lerobot/motors/motors_bus.py
|
||||
src/lerobot/robots/robot.py
|
||||
src/lerobot/robots/so_follower/config_so_follower.py
|
||||
src/lerobot/robots/so_follower/so_follower.py
|
||||
src/lerobot/robots/utils.py
|
||||
src/lerobot/teleoperators/teleoperator.py
|
||||
|
||||
Reference in New Issue
Block a user