Skip to content

Commit a2d9c33

Browse files
committed
jedi: add new pybricks_jedi package
This package will be used in Pybricks Code to provide some intellesense operations.
1 parent 6d0de1e commit a2d9c33

27 files changed

+2213
-210
lines changed

.github/workflows/jedi.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: pybricks_jedi
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
if: github.ref_type != 'tag'
8+
runs-on: ubuntu-22.04
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: actions/setup-python@v2
12+
with:
13+
python-version: "3.10"
14+
- run: pipx install poetry
15+
- run: poetry install
16+
working-directory: ./jedi
17+
- run: poetry run pytest -vv
18+
working-directory: ./jedi
19+
20+
publish:
21+
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'pybricks_jedi/')
22+
runs-on: ubuntu-20.04
23+
steps:
24+
- uses: actions/checkout@v2
25+
- uses: actions/setup-python@v2
26+
with:
27+
python-version: "3.10"
28+
- run: pipx install poetry
29+
- run: poetry install
30+
- run: poetry build
31+
- run: poetry publish
32+
env:
33+
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_PYBRICKS_JEDI_TOKEN }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ build/
2626
build-*/
2727
_build/
2828

29-
# Test failure outputs
29+
# Tests
3030
######################
31+
.pytest_cache/
3132
tests/*.exp
3233
tests/*.out
3334

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"python.autoComplete.extraPaths": ["jedi/src"],
23
"python.formatting.provider": "black",
34
"python.linting.pylintEnabled": false,
45
"python.linting.flake8Enabled": true,
@@ -9,6 +10,11 @@
910
"editor.defaultFormatter": "ms-python.python"
1011
},
1112
"python.languageServer": "Pylance",
13+
"python.testing.pytestArgs": [
14+
"jedi/tests"
15+
],
16+
"python.testing.unittestEnabled": false,
17+
"python.testing.pytestEnabled": true,
1218
"files.associations": {"*.inc": "restructuredtext"},
1319
"restructuredtext.confPath": "${workspaceFolder}/doc/main",
1420
"spellright.language": [
@@ -40,4 +46,7 @@
4046
"restructuredtext",
4147
],
4248
"rewrap.wrappingColumn": 78,
49+
"python.analysis.extraPaths": [
50+
"jedi/src"
51+
],
4352
}

doc/common/conf.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
from docutils.parsers.rst.directives import flag
2828
from docutils.parsers.rst import Directive
2929
from sphinx.application import Sphinx
30+
from sphinx.addnodes import pending_xref
31+
from sphinx.environment import BuildEnvironment
32+
from sphinx.util.nodes import make_refnode
3033
import toml
3134

3235
TOP_DIR = os.path.abspath(os.path.join("..", ".."))
@@ -307,7 +310,16 @@ def run(self):
307310
]
308311

309312

310-
def on_missing_reference(app, env, node, contnode):
313+
def on_missing_reference(
314+
app: Sphinx, env: BuildEnvironment, node: pending_xref, contnode: nodes.Element
315+
) -> nodes.Element:
316+
# The Number type alias is on the Signals and Units page instead of on the
317+
# pybricks.parameters page so normal resolution doesn't work
318+
if node["reftype"] == "class" and node["reftarget"] == "Number":
319+
return make_refnode(
320+
app.builder, node["refdoc"], "signaltypes", "numbers", contnode
321+
)
322+
311323
# References with special characters can't exist, so we have to supress
312324
# warnings when Sphinx tries to cross reference units like deg/s. For
313325
# consistency, we also treat units without special characters this way.

doc/main/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
if os.environ.get("READTHEDOCS", None) == "True":
2626
tags.add("main") # noqa F821
2727

28+
# HACK: this allows Number type alias to be imported by Sphinx
29+
os.environ["SPHINX_BUILD"] = "True"
30+
2831
# Addtional configuration of the IDE docs
2932
if "ide" in tags.tags: # noqa F821
3033
_DISCLAIMER = ""

doc/main/signaltypes.rst

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,8 @@ quantities. This page gives an overview of each quantity and its unit.
77
Numbers
88
~~~~~~~
99

10-
.. class:: Number
11-
12-
Numbers can be represented as integers or floating point values:
13-
14-
* Integers (:class:`int <ubuiltins.int>`) are whole numbers
15-
like ``15`` or ``-123``.
16-
* Floating point values (:class:`float <ubuiltins.float>`) are decimal
17-
numbers like ``3.14`` or ``-123.45``.
18-
19-
If you see :class:`Number <Number>` as the argument type, both
20-
:class:`int <ubuiltins.int>` and :class:`float <ubuiltins.float>` may be used.
21-
22-
For example, :func:`wait(15) <pybricks.tools.wait>` and
23-
:func:`wait(15.75) <pybricks.tools.wait>` are both allowed. In most functions,
24-
however, your input value will be truncated to a whole number anyway. In this
25-
example, either command makes the program pause for just 15 milliseconds.
10+
.. autodata:: pybricks.parameters.Number
11+
:noindex:
2612

2713
Time
2814
~~~~~~

0 commit comments

Comments
 (0)