Commit Graph
100 Commits
Author SHA1 Message Date
Laurens Valk bd7806d2d4 all: Format with black.
Also activate auto formatting. Bump flake8 and mark black
disagreements in setup.cfg.
2022-05-27 16:22:05 +02:00
Laurens Valk 24f7d7c288 pybricks.common.Motor: Add typing. 2022-05-27 16:01:18 +02:00
Laurens Valk 5e0ba1de07 doc/common/conf: Format units in return type.
This formats return types so they don't look like tuples:

int: deg

If we can figure out how these nodes work, we can create proper links
and maybe use italics for the units or a slightly different font color.
2022-05-27 14:59:32 +02:00
Laurens Valk 2f8ba40034 poetry: Patch Sphinx to use docstring signatures when given.
This is the intended behavior everywhere, but it wasn't working for overloaded functions and methods.

See https://github.com/pybricks/sphinx/commit/f57417c042cbf4a72448518b7599517495cc6fde
2022-05-27 12:21:45 +02:00
Laurens Valk c4a09ab62a pybricks.common.DCMotor: Add typing. 2022-05-09 15:05:09 +02:00
Laurens Valk c0c53db5ee pybricks.common.System: Add typing. 2022-05-09 10:41:39 +02:00
Laurens Valk 5e09a6f1bd .vscode/settings: Add rewrap setting.
Now we can press Alt+Q to hard (re)wrap comments and docstrings.
2022-05-09 10:28:39 +02:00
Laurens Valk 5e9a8c5737 doc/main/signaltypes: Change how units are documented.
Previously, arguments had "types" like ":ref:`speed`", which would be rendered by Sphinx as a hyperlink and displayed as "rotational speed: deg/s".

This worked well enough but it had a few shortcomings:
- It looks bad on autocomplete, which doesn't know how to render RST with cross references.
- No real type information: int, float, ... ?
- Some units are very long, making the docs less concise.
- The unified approach doesn't always work. Some method arguments can be either deg/s or mm/s, depending on the application. This gets even lengthier.
- It's hard to maintain if you don't know what to link to.

In the new approach, the unit is just added to the type as plain text. Instead of giving the physical signal name, we give the real data type, which is more standard. The physical signal name is usually apparent from the docstring anyway, and can be inferred from the unit as well. This also solves all of the above problems.

Since most Pybricks methods allow both int and float for numeric inputs, we document these as a Number type, which is the union of int and float. Since the type is no longer directly tied to the type, we can still document the return type correctly, since this is never a union.

Instead of having complicated hacks in Sphinx to make this work (I have tried many), it turns out we can conveniently suppress broken references and still display the units. The only downside is that units will no longer have hyperlinks to the signal pages, at least for the moment. We should be able to make on_missing_reference a bit smarter to format the units as we see fit if needed.

The approach here is exemplified in the Motor.run_until_stalled method. Subsequent commits will apply it everywhere. Also clarify the behavior for duty_limit=None while we are updating this code anyway.
2022-05-09 10:28:31 +02:00
Laurens Valk f934fdd9bd pybricks.common.IMU: Change example to print G force.
Since we changed the acceleration units to mm/s/s, the output values are
fairly large.

The Matrix repr function prints values up to 999, so this avoids
truncating the output.

It is also a good demo of scalar division for a Matrix / Vector.
2022-04-01 16:32:39 +02:00
Laurens Valk 556728937f pybricks.common.Accelerometer: Use mm/s/s units.
Fixes https://github.com/pybricks/pybricks-api/issues/94

For Move Hub, this is a breaking change since Move Hub IMU support
was already released. For the other hubs, the IMU API has not been
released yet, so we can do this silently.
2022-04-01 15:41:15 +02:00
Laurens Valk 813ea61308 doc/main/conf.py: Show beta features on RTD/latest. 2022-04-01 14:51:38 +02:00
Laurens Valk 2e8e43bcdf rtd-requirements: Upgrade to Sphinx 4.4.0. 2022-04-01 14:31:35 +02:00
Laurens Valk e4ddd1ffce pybricks.geometry.Axis: Drop ANY.
This was previously dropped in a2583944d9
but it was added in again in c666009511.

Since this module was never included in a release (it was hidden),
it is OK to do this.
2022-04-01 14:28:38 +02:00
Laurens Valk 243f2948ef pybricks.hubs.primehub: Show in beta version.
Make it show up in the beta build and hide it in the release build.
2022-04-01 14:28:31 +02:00
Laurens Valk 81a1379781 doc/Makefile: Allow BETA=1 to include beta features.
Prior to every previous release, we we had to delete certain
features that did not make it into the release. This lets us
do that with a tag instead. This way we can keep a clean git
history that is easier to follow.
2022-04-01 13:39:04 +02:00
Laurens Valk 93a9370790 doc/common/extensions: Hide version directives in IDE build.
Version tags can be useful to keep track of new or updated features.

This lets us hide such details in the documentation that ships with the IDE to keep it concise.
2022-04-01 09:38:41 +02:00
Laurens Valk 1989561c90 .github/workflows: Fix typo in build name. 2022-03-22 15:49:23 +01:00
Laurens Valk 4101f9be79 poetry: Update Sphinx and RTD-theme.
We were not using a proper release for sphinx-rtd-theme
in order to work around some bugs. Meanwhile, a proper
release has come out, so let's upgrade to 1.0.0.

Also bump Sphinx to 4.4.

Also update and fix workarounds for cross references.
Fixes https://github.com/pybricks/pybricks-api/issues/98.
2022-03-22 15:38:04 +01:00
Laurens Valk 0a31bc711f pybricks.common.Control: Add deceleration setter.
Fixes https://github.com/pybricks/pybricks-api/issues/97
2022-03-21 11:17:34 +01:00
Laurens Valk e69c422f83 pybricks.common.Motor: Add absolute value example.
Fixes https://github.com/pybricks/support/issues/611
2022-01-20 08:39:43 +01:00
Laurens Valk 0ceabe8497 pybricks.common.Charger: Document it. 2022-01-14 15:14:28 +01:00
Laurens Valk d3ae4ec9ee pybricks.pupdevices.ColorSensor: Move cleanup example.
The color sensor light is much brighter, so having an example
to turn it off is a bit more useful.

Fixes https://github.com/pybricks/pybricks-api/pull/90
2022-01-07 14:11:03 +01:00
Laurens Valk ffb2f8aa96 pybricks.pupdevices.UltrasonicSensor: Move cleanup example.
Also generalize the example so that it can be used on all hubs.
2022-01-07 13:38:07 +01:00
Laurens Valk d806fe9fbe pybricks.common.Control: Fix docstring and type hints for limits().
Fixes https://github.com/pybricks/support/issues/565
2021-12-30 09:12:27 +01:00
Laurens Valk 30803fc017 pybricks.robotics.DriveBase: Add curve method.
This generalizes motion to curves (arcs), which is in
between straight lines and in-place turns.
2021-12-01 15:38:27 +01:00
Laurens Valk 749eceefc4 pybricks.robotics.DriveBase: Document then and wait arguments. 2021-12-01 15:35:37 +01:00
Laurens Valk 57f6f0fbef pybricks.pupdevices.DCMotor: Document settings method.
Also update changelog for recent changes.
2021-12-01 14:55:34 +01:00
Laurens Valk e061617c34 pybricks.common.Control: Drop integral_range.
This setting is no longer used. We leave a placeholder setting so we don't break existing programs.

See https://github.com/pybricks/pybricks-micropython/commit/e82dd6a2be4e378ab0b1ee7e3b2643fe654de4a9#diff-e529f43c94cf766ade4b68930f9713a45b62618f4305e4c0c88ba872e9f9cd0e
2021-12-01 14:54:21 +01:00
Laurens Valk eb09ecd7c7 pybricks.common.Control: Drop duty limit.
This is now a per-motor voltage limit.

See https://github.com/pybricks/support/issues/536
2021-12-01 14:41:09 +01:00
Laurens Valk 06a1542613 pybricks.pupdevices.DCMotor: Document settings method.
See https://github.com/pybricks/support/issues/536
2021-12-01 14:40:06 +01:00
Laurens Valk 82a8f2ae89 pybricks.pupdevices.Motor: Add small motor render.
Fixes https://github.com/pybricks/support/issues/441
2021-11-23 08:59:44 +01:00
Laurens Valk 7d0fe9cb85 doc/common/extensions: Fix classlink.
Allow the link to be different from the name.

This lets us fix the link for the Inventor Hub, which was linking to a non-existent page.
2021-11-22 14:49:20 +01:00
Laurens Valk 1af876ac8f pybricks.pupdevices.ColorLightMatrix: Fix render.
- Use isometric projection
- Fix broken plug
- Use correct background color

While we are at it, add colors to show which 9 colors this device supports.
2021-11-22 14:49:20 +01:00
Laurens Valk dd2e6e8603 ubuiltins.int: Document from_bytes manually.
Sphinx fails to show the docsting for class methods. Since we have very few of them, it is easier to just document this one manually

Fixes https://github.com/pybricks/pybricks-api/issues/86
2021-08-22 12:15:42 +02:00
Laurens Valk a0f4818e26 ubuiltins.int: Document it. 2021-08-06 14:59:45 +02:00
Laurens Valk af23c10566 ubuiltins.float: Document it.
Override typed docstrings in order to hide types like SupportsFloat.
2021-08-06 14:58:19 +02:00
Laurens Valk d7096dad80 ubuiltins.complex: Document it.
Override typed docstrings in order to hide types like SupportsFloat and SupportsComplex.

Avoid use of ``real`` and ``imag``, since both ``a`` and ``b`` can be
either.

Also reduce number of overloads by letting ``b`` default to 0, which is true in practice.

See also https://github.com/pybricks/pybricks-api/issues/84
2021-08-06 14:25:00 +02:00
Laurens Valk 1d2b1f0307 rtd-requirements: Update to Sphinx 4.1
See https://github.com/pybricks/pybricks-api/issues/70
2021-08-06 10:47:14 +02:00
Laurens Valk 9945b43713 pyproject: Update to Sphinx 4.1.
Also bump to a development version of sphinx-rtd-theme that supports Sphinx 4.

Fixes https://github.com/pybricks/pybricks-api/issues/70
2021-08-06 10:40:26 +02:00
Laurens Valk 4124e1dd4e doc/common/conf: Drop unused imports.
These prevent us from upgrading Sphinx and they aren't being used anyway.

Fixes e4c7e5abeb
2021-08-06 10:07:42 +02:00
Laurens Valk d86b5584fb ubuiltins: Type enumerate as a class.
This reverts commit a0ea0d8ca0 because of https://github.com/pybricks/pybricks-api/issues/72
2021-08-06 09:51:52 +02:00
Laurens Valk 1c01e981e0 usys: Clean up.
Add requirements, drop autodoc, and add a few cross references.
2021-08-05 16:13:50 +02:00
Laurens Valk 8a6ddf677c pybricks.pupdevices.Remote: Light examples. 2021-08-05 14:56:00 +02:00
Laurens Valk 5d4481dbb0 pybricks.pupdevices.ColorDistanceSensor: Drop duplicate example. 2021-08-05 13:45:57 +02:00
Laurens Valk 786770cff2 ubuiltins.bool: Use arguments.
https://github.com/pybricks/pybricks-api/issues/82
2021-08-05 12:49:44 +02:00
Laurens Valk 572b573d2f ubuiltins: Fix _type typos.
This was accidentally introduced via https://github.com/pybricks/pybricks-api/issues/71 by replacing too many things automatically.
2021-08-05 12:33:00 +02:00
Laurens Valk 15bd870140 ubuiltins: Use argument layout.
https://github.com/pybricks/pybricks-api/issues/82
2021-08-05 12:32:56 +02:00
Laurens Valk b101d1992d ubuiltins.print: Use English. 2021-08-05 12:32:51 +02:00
Laurens Valk b013204f88 ubuiltins.input: Say what it does.
The docstring said something about an argument, but not what this function is for.
2021-08-05 12:32:47 +02:00
Laurens Valk b3c5353dd6 ubuiltins: Reorganize page.
Fixes https://github.com/pybricks/pybricks-api/issues/80
2021-08-05 12:32:41 +02:00
Laurens Valk 0ecf536cda ubuiltins: Add compatibility everywhere.
This lets us sort everything by category or alphabetically without having to make special categories for Move Hub.
2021-08-05 12:32:37 +02:00
Laurens Valk 49ade9d9c6 pybricks.robotics: Show compatibility. 2021-08-05 12:32:03 +02:00
Laurens Valk 045312921e pybricks.geometry: Show compatibility. 2021-08-05 12:32:03 +02:00
Laurens Valk 39f58b9e03 pybricks.tools: Show compatibility. 2021-08-05 12:32:03 +02:00
Laurens Valk a0467b8d8e doc/common/requirements: Fix image paths.
This ensures that the requirements directive works regardless of the depth of the document in the tree.
2021-08-05 12:32:03 +02:00
Laurens Valk 4945156d9a pybricks.parameters: Show compatibility. 2021-08-05 12:32:03 +02:00
Laurens Valk 97b2de46ac pybricks.hubs: Show compatibility. 2021-08-05 12:32:03 +02:00
Laurens Valk e8d7281626 doc/common/requirements: A hub supports itself.
This way we can do the following, which is useful if it cannot be expressed in terms of other requirements.

.. pybricks-requirements:: movehub

A good example is on the specific hub page itself. The Move Hub requires the Move Hub.
2021-08-05 12:32:03 +02:00
Laurens Valk 979da8b170 pybricks.pupdevices: Show compatibility. 2021-08-05 12:32:03 +02:00
Laurens Valk ac4a913be3 doc/common/requirements: Toggle hub table.
This makes it possible to hide/unhide the compatibility table.

It is adapted from the sphinxcontrib-contentui extension: https://github.com/ulrobix/sphinxcontrib-contentui
2021-08-05 12:32:03 +02:00
Laurens Valk 31a30f380f doc/common/requirements: Rename to static.
We will work on a version that can be toggled dynamically. It will just include this static version. This keeps things simple and still lets
us use the static version as needed.
2021-08-05 12:32:03 +02:00
Laurens Valk 87dacfbf76 doc/common/extensions/requirements: Allow none.
With no requirements imposed, this means all hubs will work.
2021-08-05 12:32:03 +02:00
Laurens Valk b02895e5fc ubuiltins: Use raw strings for inline math.
This resolves the following warnings:
./src/ubuiltins/__init__.py:143:31: W605 invalid escape sequence '\l'
./src/ubuiltins/__init__.py:143:38: W605 invalid escape sequence '\l'
./src/ubuiltins/__init__.py:174:31: W605 invalid escape sequence '\l'
./src/ubuiltins/__init__.py:174:38: W605 invalid escape sequence '\l'
2021-08-05 12:32:21 +02:00
Laurens Valk 486ac60ea0 ubuiltins.bool: Clarify docs.
Avoid double and triple negatives.
2021-08-05 12:32:17 +02:00
Laurens Valk a3b6507a15 ubuiltins.bytes: Clarify docs. 2021-08-05 12:32:14 +02:00
Laurens Valk 75bc15f071 ubuiltins: Add bytearray. 2021-08-05 12:32:03 +02:00
Laurens Valk 0b9280a8df uerrno: Display on separate page.
Fixes https://github.com/pybricks/pybricks-api/issues/78
2021-08-02 11:01:20 +02:00
Laurens Valk a8ab8b2314 pybricks.pupdevices.Motor: Add reset_angle kwarg.
Documents https://github.com/pybricks/support/issues/389
2021-07-28 16:07:53 +02:00
Laurens Valk 62bb262b96 pybricks.pupdevices.Remote: Add more examples. 2021-07-28 14:50:43 +02:00
Laurens Valk 8463206f8e pybricks.pupdevices.Remote: Add name().
https://github.com/pybricks/support/issues/404
2021-07-28 13:41:00 +02:00
Laurens Valk 1cf6f8d31b pybricks.iodevices: Document availability. 2021-07-27 15:55:38 +02:00
Laurens Valk a0bd4a6812 doc/common/extensions: Show compatibility on hub.
This simplifies the table and reduces its size.

Also copy assets manually since Sphinx does not automatically copy
images to _images when used for custom directives.
2021-07-27 15:43:13 +02:00
Laurens Valk efc907fb0c doc/main: Add hub compatibility icons.
Also render to git tree.
2021-07-27 14:56:11 +02:00
Laurens Valk be0903de9e doc/common/extensions: Basic styling.
Turns it into a table with images, using builtin RTD classes for CSS.
2021-07-26 15:47:02 +02:00
Laurens Valk 20361971da doc/main/images: Crop City Hub.
This hub had extra whitespace so they were all the same height, but this is no longer needed in the current layout.
2021-07-26 15:03:42 +02:00
Laurens Valk cefa78270a doc/common/extensions: Add requirements directive.
Displays compatibility for each hub depending on its features.
2021-07-26 12:18:55 +02:00
Laurens Valk 1f5eb1790b doc/main/package: Reenable warnings as errors.
This gets disabled when overriding SPHINXOPTS.
2021-07-23 15:59:33 +02:00
Laurens Valk 84335d0032 doc/make: Build main doc target by default.
Less typing is better.
2021-07-23 15:46:58 +02:00
Laurens Valk cb74f8e302 doc/main: Move signals to Pybricks TOC.
This was the only remaining section under "extras", so it is better to have it elsewhere. Since it only applies to the Pybricks package, put it there.

Also rename Pybricks Modules heading to Pybricks Package, since it behaves more like a package in contrast with the MicroPython modules that we now document as well.
2021-07-23 15:38:05 +02:00
Laurens Valk 78bd21b197 pybricks.common.Control: Drop feed_forward.
The implementation no longer includes this, so it is removed from the docs as well.

Fixes https://github.com/pybricks/pybricks-api/issues/74
2021-07-23 15:35:13 +02:00
Laurens Valk 24bba6d24c pybricks.pupdevices.Motor: Document control here.
Based on user feedback, we learned that the control attribute is used more frequently than anticipated. Therefore it makes sense to document it here, just like we do with instances of pybricks.common classes in hubs.

This makes it a bit easier to find and see how it is used, along with some of the existing examples.
2021-07-23 15:33:18 +02:00
Laurens Valk 0edddbb0c2 pybricks.common.Control: Fix scale doc.
Document it as an attribute instead of in the main docstring. This way we can choose where it shows up in the docs.
2021-07-23 14:51:21 +02:00
Laurens Valk a11af0845b doc/main/motors: Drop commented sections.
This is not going to be completed here in the API docs.
2021-07-23 14:37:28 +02:00
Laurens Valk 3b71bce0b0 doc/main: Build IDE docs from main docs.
With EV3 dropped from the 3.X documentation, the main docs are now nearly identical to the IDE docs, save for some layout changes.

Having just one set of docs is easier to maintain. This drops the IDE doc target.
2021-07-23 12:56:33 +02:00
Laurens Valk 434ff5e346 doc/common/conf: Keep IDE conf settings.
We are going to be deleting the ide build files, so make sure we keep what's needed.
2021-07-23 12:45:30 +02:00
Laurens Valk f7239fc9a9 pybricks.parameters.Port: Drop EV3 sensor ports.
We can restore these if the docs cover EV3 once more.
2021-07-23 12:35:46 +02:00
Laurens Valk 7e13611bc5 doc/common/conf: Default to main on RTD.
It would be nicer to specify this in the .readthedocs.yaml file, but this appears to not to be supported.
2021-07-23 12:34:10 +02:00
Laurens Valk 78feab8949 pybricks.tools: Drop Datalog class from doc.
We can unhide this if/when we support this on Powered Up.
2021-07-23 11:35:32 +02:00
Laurens Valk f692e5a127 pybricks.iodevices: Drop EV3 specific devices.
Some of these could be brought back if we add Powered Up support.
2021-07-23 11:32:01 +02:00
Laurens Valk fbd843cb54 doc/main/index: Unify IDE and main build.
The `only` directive can be used to include content selectively. It cannot be used to select a different TOC, which is why we resorted to separate doc builds before.

Now that we have dropped EV3 references from the docs, we can use a single build and just customize the content on the landing page with the only directive.

The docs can now be built with:

# Main docs:
make -C doc html SPHINXOPTS=-tmain

# IDE docs:
make -C doc html SPHINXOPTS=-tide
2021-07-23 11:25:51 +02:00
Laurens Valk e4c7e5abeb doc/common/conf: Drop class method hack.
This can be traced back to 0013a74d72 and 92e3735d63.

It was used to work around things like

sound.beeps(number)
   Description

being incorrectly displayed as

classmethod sound.beeps(number)
   Description

But the current version of sphinx appears to display this correctly even without the hack. We want to reduce the number of hacks because they tend to break updates (https://github.com/pybricks/pybricks-api/issues/69#issuecomment-879822417).
2021-07-23 11:04:03 +02:00
Laurens Valk 8d521c1b1f doc/common/conf: Drop EV3 hack.
This is no longer required, perhaps not even for EV3. For example, PrimeHub.speaker looks as intended.

We want to reduce the number of hacks because they tend to break updates (https://github.com/pybricks/pybricks-api/issues/69#issuecomment-879822417).
2021-07-23 10:48:07 +02:00
Laurens Valk 1be7fce116 doc/main: Drop EV3 references.
To make the documentation easier to use and maintain, EV3 content will be hidden.

The stable 2.0 docs should be used for EV3 instead.
2021-07-23 10:41:34 +02:00
Laurens Valk 5ab81dc732 doc/main: Update landing page with link to EV3. 2021-07-21 19:27:45 +02:00
Laurens Valk 72e0d87f77 ubuiltins: Examples for common exceptions. 2021-07-21 14:53:56 +02:00
Laurens Valk 923e8caf84 ubuiltins: Organize exceptions. 2021-07-21 11:12:51 +02:00
Laurens Valk e8d47ffca1 uerrno: Document alongside OSError.
These are meant to be used together, so document them in the same place along with a practical example.
2021-07-19 15:03:10 +02:00
Laurens Valk 2c32d093d0 ubuiltins.bytes: Clarify range up to 255.
Be consistent and use <= for both. A bit more intuitive because the number 256 cannot be used in bytes objects.
2021-07-16 16:12:43 +02:00
Laurens Valk ba6d7ac3f5 ubuiltins: Fix unwanted ubuiltins prefix.
Fixes https://github.com/pybricks/pybricks-api/issues/71.
2021-07-16 16:07:55 +02:00
Laurens Valk 64ea5e341c ubuiltins: Sort classes and functions by use case. 2021-07-16 16:07:55 +02:00