Compare commits

..
Author SHA1 Message Date
David Lechner 3a60d40bac @pybricks/ide-docs v2.4.0 2022-11-11 11:39:47 -06:00
David Lechner cb0dee3e99 npm/jedi: v1.3.0
Update `pybricks_jedi` Python package to v1.3.0.
2022-11-11 11:36:31 -06:00
David Lechner 19673da32e jedi/pyproject: v1.3.0 2022-11-11 11:31:02 -06:00
David Lechner b8b5652cb6 jedi: update pybricks package to v3.2.0b5 2022-11-11 11:30:01 -06:00
David Lechner 7b4953bc5f pyproject: v3.2.0b5
Update version for `pybricks` Python package release.
2022-11-11 11:24:57 -06:00
David Lechner 62f6fc85a5 jedi: fix code completion for Color and Icon
The pybricks.parameters.Color and Icon types were not working with Jedi
for code completion since the constants were never assigned a value.
2022-11-10 12:23:24 -06:00
Laurens Valk d2b1b2183b pybricks.parameters.Icon: Document it.
Fixes https://github.com/pybricks/pybricks-api/issues/107
2022-11-10 16:38:44 +01:00
15 changed files with 510 additions and 55 deletions
+5
View File
@@ -4,6 +4,11 @@
## Unreleased
## 3.2.0b5 - 2022-11-11
### Fixed
- Fixed Jedi code completion for `Color` and `Icon` classes in `pybricks.parameters`.
## 3.2.0b4 - 2022-10-21
### Added
+2 -2
View File
@@ -24,8 +24,8 @@ HUB_FEATURES = {
"movehub": {"movehub"} | FEATURES_SMALL,
"cityhub": {"cityhub"} | FEATURES_MEDIUM,
"technichub": {"technichub"} | FEATURES_MEDIUM,
"primehub": {"primehub", "inventorhub"} | FEATURES_LARGE,
"inventorhub": {"primehub", "inventorhub"} | FEATURES_LARGE,
"primehub": {"primehub", "inventorhub", "light-matrix"} | FEATURES_LARGE,
"inventorhub": {"primehub", "inventorhub", "light-matrix"} | FEATURES_LARGE,
"essentialhub": {"essentialhub"} | FEATURES_LARGE,
}
+3 -1
View File
@@ -177,13 +177,15 @@ Changing the display orientation
.. literalinclude::
../../../examples/pup/hub_primehub/display_orientation_imu.py
.. _make_icons:
Making your own images
**********************
.. literalinclude::
../../../examples/pup/hub_primehub/display_matrix.py
Combining images to make expressions
Combining icons to make expressions
************************************
.. literalinclude::
+8
View File
@@ -0,0 +1,8 @@
.. pybricks-requirements:: light-matrix
Icon
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autoclass:: pybricks.parameters.Icon
See the :ref:`make_icons` section for examples.
+3
View File
@@ -13,6 +13,7 @@
button
color
direction
icon
port
side
stop
@@ -23,6 +24,8 @@
.. pybricks-classlink:: Direction
.. pybricks-classlink:: Icon
.. pybricks-classlink:: Port
.. pybricks-classlink:: Side
+8
View File
@@ -4,6 +4,14 @@
## Unreleased
## 1.3.0 - 2022-11-11
### Changed
- Updated `pybricks` package to v3.2.0b5.
### Fixed
- Fixed code completion for `Color` and `Icon` classes in `pybricks.parameters`.
## 1.2.0 - 2022-10-21
### Added
+2 -2
View File
@@ -185,7 +185,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[[package]]
name = "pybricks"
version = "3.2.0b4"
version = "3.2.0b5"
description = "Documentation and user-API stubs for Pybricks MicroPython"
category = "main"
optional = false
@@ -263,7 +263,7 @@ python-versions = ">=3.7"
[metadata]
lock-version = "1.1"
python-versions = ">= 3.10, < 3.11"
content-hash = "f3cd92de360fc68d8bc8ad0999eb5d0591e7f33dc5f20a32409b3787cac71965"
content-hash = "4f27a31e5659d2900dfa700d0e7a87ec6a2b4557af49f21102fbbc78054371c2"
[metadata.files]
atomicwrites = [
+2 -2
View File
@@ -1,13 +1,13 @@
[tool.poetry]
name = "pybricks_jedi"
version = "1.2.0"
version = "1.3.0"
description = "Code completion for Pybricks."
authors = ["The Pybricks Authors"]
license = "MIT"
[tool.poetry.dependencies]
python = ">= 3.10, < 3.11"
pybricks = "3.2.0b4"
pybricks = "3.2.0b5"
jedi = "0.18.1"
typing-extensions = "4.2.0"
docstring-parser = "0.14.1"
+139
View File
@@ -0,0 +1,139 @@
import json
import pytest
from pybricks_jedi import CompletionItem, complete
def _create_snippet(class_name: str) -> str:
"""
Creates a code snippet::
from pybricks.parameters import {class_name}
{class_name}.
Args:
line: The value substituted for ``{class_name}``
"""
return "\n".join(
(f"from pybricks.parameters import {class_name}", f"{class_name}.")
)
ENUMS = [
pytest.param(
"Button",
[
"BEACON",
"BLUETOOTH",
"CENTER",
"DOWN",
"LEFT",
"LEFT_DOWN",
"LEFT_MINUS",
"LEFT_PLUS",
"LEFT_UP",
"RIGHT",
"RIGHT_DOWN",
"RIGHT_MINUS",
"RIGHT_PLUS",
"RIGHT_UP",
"UP",
],
),
pytest.param(
"Color",
[
"BLACK",
"BLUE",
"BROWN",
"CYAN",
"GRAY",
"GREEN",
"MAGENTA",
"NONE",
"ORANGE",
"RED",
"VIOLET",
"WHITE",
"YELLOW",
],
),
pytest.param("Direction", ["CLOCKWISE", "COUNTERCLOCKWISE"]),
pytest.param(
"Icon",
[
"ARROW_DOWN",
"ARROW_LEFT",
"ARROW_LEFT_DOWN",
"ARROW_LEFT_UP",
"ARROW_RIGHT",
"ARROW_RIGHT_DOWN",
"ARROW_RIGHT_UP",
"ARROW_UP",
"CIRCLE",
"CLOCKWISE",
"COUNTERCLOCKWISE",
"DOWN",
"EMPTY",
"EYE_LEFT",
"EYE_LEFT_BLINK",
"EYE_LEFT_BROW",
"EYE_LEFT_BROW_UP",
"EYE_RIGHT",
"EYE_RIGHT_BLINK",
"EYE_RIGHT_BROW",
"EYE_RIGHT_BROW_UP",
"FALSE",
"FULL",
"HAPPY",
"HEART",
"LEFT",
"PAUSE",
"RIGHT",
"SAD",
"SQUARE",
"TRIANGLE_DOWN",
"TRIANGLE_LEFT",
"TRIANGLE_RIGHT",
"TRIANGLE_UP",
"TRUE",
"UP",
],
),
pytest.param("Port", ["A", "B", "C", "D", "E", "F", "S1", "S2", "S3", "S4"]),
pytest.param("Side", ["BACK", "BOTTOM", "FRONT", "LEFT", "RIGHT", "TOP"]),
pytest.param("Stop", ["BRAKE", "COAST", "HOLD"]),
]
@pytest.mark.parametrize("class_name,members", ENUMS)
def test_get_parameter_class_member_completion(class_name: str, members: list[str]):
code = _create_snippet(class_name)
completions: list[CompletionItem] = json.loads(
complete(code, 2, len(class_name) + 2)
)
assert [c["insertText"] for c in completions] == members
def test_get_parameter_color_completion():
code = "\n".join(["from pybricks.parameters import Color", "Color.RED."])
completions: list[CompletionItem] = json.loads(complete(code, 2, 11))
assert [c["insertText"] for c in completions] == [
"BLACK",
"BLUE",
"BROWN",
"CYAN",
"GRAY",
"GREEN",
"h",
"MAGENTA",
"NONE",
"ORANGE",
"RED",
"s",
"v",
"VIOLET",
"WHITE",
"YELLOW",
]
+5
View File
@@ -2,6 +2,11 @@
<!-- refer to https://keepachangelog.com/en/1.0.0/ for guidance -->
## 2.4.0 - 2022-11-11
### Changed
- Updated docs to v3.2.0b5.
## 2.3.0 - 2022-10-21
### Changed
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@pybricks/ide-docs",
"version": "2.3.0",
"version": "2.4.0",
"description": "Special build of Pybricks API docs for embedding in an IDE.",
"repository": {
"type": "git",
+6 -1
View File
@@ -2,7 +2,12 @@
<!-- refer to https://keepachangelog.com/en/1.0.0/ for guidance -->
## 1.1.0 - 2022-10-21
## 1.3.0 - 2022-11-11
### Changed
- Updated `pybricks_jedi` Python package to v1.3.0.
## 1.2.0 - 2022-10-21
### Changed
- Updated `pybricks_jedi` Python package to v1.2.0.
+2 -2
View File
@@ -12,7 +12,7 @@ BUILD_DIR = (pathlib.Path(__file__).parent / "build").resolve()
package_json = {
"name": "@pybricks/jedi",
"version": "1.2.0",
"version": "1.3.0",
"description": "Binary distribution of pybricks-jedi Python package and dependencies for use with Pyodide.",
"repository": {
"type": "git",
@@ -38,7 +38,7 @@ subprocess.check_call(
"pip",
"download",
"--only-binary=any",
"pybricks-jedi==1.2.0",
"pybricks-jedi==1.3.0",
],
cwd=BUILD_DIR,
)
+1 -1
View File
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pybricks"
version = "3.2.0b4"
version = "3.2.0b5"
description = "Documentation and user-API stubs for Pybricks MicroPython"
authors = ["The Pybricks Authors <dev@pybricks.com>"]
maintainers = ["Laurens Valk <laurens@pybricks.com>", "David Lechner <david@pybricks.com>" ]
+323 -43
View File
@@ -60,21 +60,43 @@ class _PybricksEnum(Enum, metaclass=_PybricksEnumMeta):
class Color:
"""Light or surface color."""
h: int
s: int
v: int
NONE: Color = ...
BLACK: Color = ...
GRAY: Color = ...
WHITE: Color = ...
RED: Color = ...
ORANGE: Color = ...
BROWN: Color = ...
YELLOW: Color = ...
GREEN: Color = ...
CYAN: Color = ...
BLUE: Color = ...
VIOLET: Color = ...
MAGENTA: Color = ...
def __init__(self, h: Number, s: Number = 100, v: Number = 100):
"""Color(h, s=100, v=100)
Arguments:
h (Number, deg): Hue (0--360)
h (Number, deg): Hue.
s (Number, %): Saturation.
v (Number, %): Brightness value.
"""
self.h = h % 360
self.s = max(0, min(s, 100))
self.v = max(0, min(v, 100))
self.h = int(h) % 360
"""
The hue.
"""
self.s = max(0, min(int(s), 100))
"""
The saturation.
"""
self.v = max(0, min(int(v), 100))
"""
The brightness value.
"""
def __repr__(self):
return "Color(h={}, s={}, v={})".format(self.h, self.s, self.v)
@@ -185,39 +207,297 @@ class Side(_PybricksEnum):
class Icon:
UP: _Matrix
DOWN: _Matrix
LEFT: _Matrix
RIGHT: _Matrix
ARROW_RIGHT_UP: _Matrix
ARROW_RIGHT_DOWN: _Matrix
ARROW_LEFT_UP: _Matrix
ARROW_LEFT_DOWN: _Matrix
ARROW_UP: _Matrix
ARROW_DOWN: _Matrix
ARROW_LEFT: _Matrix
ARROW_RIGHT: _Matrix
HAPPY: _Matrix
SAD: _Matrix
EYE_LEFT: _Matrix
EYE_RIGHT: _Matrix
EYE_LEFT_BLINK: _Matrix
EYE_RIGHT_BLINK: _Matrix
EYE_RIGHT_BROW: _Matrix
EYE_LEFT_BROW: _Matrix
EYE_LEFT_BROW_UP: _Matrix
EYE_RIGHT_BROW_UP: _Matrix
HEART: _Matrix
PAUSE: _Matrix
EMPTY: _Matrix
FULL: _Matrix
SQUARE: _Matrix
TRIANGLE_RIGHT: _Matrix
TRIANGLE_LEFT: _Matrix
TRIANGLE_UP: _Matrix
TRIANGLE_DOWN: _Matrix
CIRCLE: _Matrix
CLOCKWISE: _Matrix
COUNTERCLOCKWISE: _Matrix
TRUE: _Matrix
FALSE: _Matrix
"""Icons to display on a light matrix.
Each of the following attributes are matrices. This means you can scale
icons to adjust the brightness or add icons to make composites.
"""
UP: _Matrix = ...
"""
| ⬜⬜🟨⬜⬜
| ⬜🟨🟨🟨⬜
| 🟨🟨🟨🟨🟨
| ⬜🟨🟨🟨⬜
| ⬜🟨🟨🟨⬜
"""
DOWN: _Matrix = ...
"""
| ⬜🟨🟨🟨⬜
| ⬜🟨🟨🟨⬜
| 🟨🟨🟨🟨🟨
| ⬜🟨🟨🟨⬜
| ⬜⬜🟨⬜⬜
"""
LEFT: _Matrix = ...
"""
| ⬜⬜🟨⬜⬜
| ⬜🟨🟨🟨🟨
| 🟨🟨🟨🟨🟨
| ⬜🟨🟨🟨🟨
| ⬜⬜🟨⬜⬜
"""
RIGHT: _Matrix = ...
"""
| ⬜⬜🟨⬜⬜
| 🟨🟨🟨🟨⬜
| 🟨🟨🟨🟨🟨
| 🟨🟨🟨🟨⬜
| ⬜⬜🟨⬜⬜
"""
ARROW_RIGHT_UP: _Matrix = ...
"""
| ⬜⬜🟨🟨🟨
| ⬜⬜⬜🟨🟨
| ⬜⬜🟨⬜🟨
| ⬜🟨⬜⬜⬜
| 🟨⬜⬜⬜⬜
"""
ARROW_RIGHT_DOWN: _Matrix = ...
"""
| 🟨⬜⬜⬜⬜
| ⬜🟨⬜⬜⬜
| ⬜⬜🟨⬜🟨
| ⬜⬜⬜🟨🟨
| ⬜⬜🟨🟨🟨
"""
ARROW_LEFT_UP: _Matrix = ...
"""
| 🟨🟨🟨⬜⬜
| 🟨🟨⬜⬜⬜
| 🟨⬜🟨⬜⬜
| ⬜⬜⬜🟨⬜
| ⬜⬜⬜⬜🟨
"""
ARROW_LEFT_DOWN: _Matrix = ...
"""
| ⬜⬜⬜⬜🟨
| ⬜⬜⬜🟨⬜
| 🟨⬜🟨⬜⬜
| 🟨🟨⬜⬜⬜
| 🟨🟨🟨⬜⬜
"""
ARROW_UP: _Matrix = ...
"""
| ⬜⬜🟨⬜⬜
| ⬜🟨🟨🟨⬜
| 🟨⬜🟨⬜🟨
| ⬜⬜🟨⬜⬜
| ⬜⬜🟨⬜⬜
"""
ARROW_DOWN: _Matrix = ...
"""
| ⬜⬜🟨⬜⬜
| ⬜⬜🟨⬜⬜
| 🟨⬜🟨⬜🟨
| ⬜🟨🟨🟨⬜
| ⬜⬜🟨⬜⬜
"""
ARROW_LEFT: _Matrix = ...
"""
| ⬜⬜🟨⬜⬜
| ⬜🟨⬜⬜⬜
| 🟨🟨🟨🟨🟨
| ⬜🟨⬜⬜⬜
| ⬜⬜🟨⬜⬜
"""
ARROW_RIGHT: _Matrix = ...
"""
| ⬜⬜🟨⬜⬜
| ⬜⬜⬜🟨⬜
| 🟨🟨🟨🟨🟨
| ⬜⬜⬜🟨⬜
| ⬜⬜🟨⬜⬜
"""
HAPPY: _Matrix = ...
"""
| 🟨🟨⬜🟨🟨
| 🟨🟨⬜🟨🟨
| ⬜⬜⬜⬜⬜
| 🟨⬜⬜⬜🟨
| ⬜🟨🟨🟨⬜
"""
SAD: _Matrix = ...
"""
| 🟨🟨⬜🟨🟨
| 🟨🟨⬜🟨🟨
| ⬜⬜⬜⬜⬜
| ⬜🟨🟨🟨⬜
| 🟨⬜⬜⬜🟨
"""
EYE_LEFT: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| 🟨🟨⬜⬜⬜
| 🟨🟨⬜⬜⬜
| ⬜⬜⬜⬜⬜
"""
EYE_RIGHT: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜🟨🟨
| ⬜⬜⬜🟨🟨
| ⬜⬜⬜⬜⬜
"""
EYE_LEFT_BLINK: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| 🟨🟨⬜⬜⬜
| ⬜⬜⬜⬜⬜
"""
EYE_RIGHT_BLINK: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜🟨🟨
| ⬜⬜⬜⬜⬜
"""
EYE_RIGHT_BROW: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜🟨🟨
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
"""
EYE_LEFT_BROW: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| 🟨🟨⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
"""
EYE_LEFT_BROW_UP: _Matrix = ...
"""
| 🟨🟨⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
"""
EYE_RIGHT_BROW_UP: _Matrix = ...
"""
| ⬜⬜⬜🟨🟨
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
"""
HEART: _Matrix = ...
"""
| ⬜🟨⬜🟨⬜
| 🟨🟨🟨🟨🟨
| 🟨🟨🟨🟨🟨
| ⬜🟨🟨🟨⬜
| ⬜⬜🟨⬜⬜
"""
PAUSE: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| ⬜🟨⬜🟨⬜
| ⬜🟨⬜🟨⬜
| ⬜🟨⬜🟨⬜
| ⬜⬜⬜⬜⬜
"""
EMPTY: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
"""
FULL: _Matrix = ...
"""
| 🟨🟨🟨🟨🟨
| 🟨🟨🟨🟨🟨
| 🟨🟨🟨🟨🟨
| 🟨🟨🟨🟨🟨
| 🟨🟨🟨🟨🟨
"""
SQUARE: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| ⬜🟨🟨🟨⬜
| ⬜🟨🟨🟨⬜
| ⬜🟨🟨🟨⬜
| ⬜⬜⬜⬜⬜
"""
TRIANGLE_RIGHT: _Matrix = ...
"""
| ⬜🟨⬜⬜⬜
| ⬜🟨🟨⬜⬜
| ⬜🟨🟨🟨⬜
| ⬜🟨🟨⬜⬜
| ⬜🟨⬜⬜⬜
"""
TRIANGLE_LEFT: _Matrix = ...
"""
| ⬜⬜⬜🟨⬜
| ⬜⬜🟨🟨⬜
| ⬜🟨🟨🟨⬜
| ⬜⬜🟨🟨⬜
| ⬜⬜⬜🟨⬜
"""
TRIANGLE_UP: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| ⬜⬜🟨⬜⬜
| ⬜🟨🟨🟨⬜
| 🟨🟨🟨🟨🟨
| ⬜⬜⬜⬜⬜
"""
TRIANGLE_DOWN: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| 🟨🟨🟨🟨🟨
| ⬜🟨🟨🟨⬜
| ⬜⬜🟨⬜⬜
| ⬜⬜⬜⬜⬜
"""
CIRCLE: _Matrix = ...
"""
| ⬜🟨🟨🟨⬜
| 🟨🟨🟨🟨🟨
| 🟨🟨🟨🟨🟨
| 🟨🟨🟨🟨🟨
| ⬜🟨🟨🟨⬜
"""
CLOCKWISE: _Matrix = ...
"""
| 🟨🟨🟨🟨⬜
| 🟨⬜⬜🟨⬜
| 🟨⬜⬜🟨⬜
| 🟨⬜🟨🟨🟨
| ⬜⬜⬜🟨⬜
"""
COUNTERCLOCKWISE: _Matrix = ...
"""
| ⬜🟨🟨🟨🟨
| ⬜🟨⬜⬜🟨
| ⬜🟨⬜⬜🟨
| 🟨🟨🟨⬜🟨
| ⬜🟨⬜⬜⬜
"""
TRUE: _Matrix = ...
"""
| ⬜⬜⬜⬜🟨
| ⬜⬜⬜🟨⬜
| 🟨⬜🟨⬜⬜
| ⬜🟨⬜⬜⬜
| ⬜⬜⬜⬜⬜
"""
FALSE: _Matrix = ...
"""
| 🟨⬜⬜⬜🟨
| ⬜🟨⬜🟨⬜
| ⬜⬜🟨⬜⬜
| ⬜🟨⬜🟨⬜
| 🟨⬜⬜⬜🟨
"""