Skip to content

Commit 991045b

Browse files
committed
Did struct, supervisor, terminalio
1 parent 603df58 commit 991045b

File tree

5 files changed

+82
-84
lines changed

5 files changed

+82
-84
lines changed

shared-bindings/struct/__init__.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include "shared-module/struct/__init__.h"
3939
#include "supervisor/shared/translate.h"
4040

41-
//| :mod:`struct` --- manipulation of c-style data
41+
//| """:mod:`struct` --- manipulation of c-style data
4242
//| ========================================================
4343
//|
4444
//| .. module:: struct
@@ -52,13 +52,13 @@
5252
//| Supported size/byte order prefixes: *@*, *<*, *>*, *!*.
5353
//|
5454
//| Supported format codes: *b*, *B*, *x*, *h*, *H*, *i*, *I*, *l*, *L*, *q*, *Q*,
55-
//| *s*, *P*, *f*, *d* (the latter 2 depending on the floating-point support).
55+
//| *s*, *P*, *f*, *d* (the latter 2 depending on the floating-point support)."""
5656
//|
5757

5858

59-
//| .. function:: calcsize(fmt)
60-
//|
61-
//| Return the number of bytes needed to store the given fmt.
59+
//| def calcsize(fmt: Any) -> Any:
60+
//| """Return the number of bytes needed to store the given fmt."""
61+
//| ...
6262
//|
6363

6464
STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
@@ -67,10 +67,10 @@ STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
6767
}
6868
MP_DEFINE_CONST_FUN_OBJ_1(struct_calcsize_obj, struct_calcsize);
6969

70-
//| .. function:: pack(fmt, *values)
71-
//|
72-
//| Pack the values according to the format string fmt.
73-
//| The return value is a bytes object encoding the values.
70+
//| def pack(fmt: Any, *values: Any) -> Any:
71+
//| """Pack the values according to the format string fmt.
72+
//| The return value is a bytes object encoding the values."""
73+
//| ...
7474
//|
7575

7676
STATIC mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) {
@@ -85,10 +85,10 @@ STATIC mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) {
8585
}
8686
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_obj, 1, MP_OBJ_FUN_ARGS_MAX, struct_pack);
8787

88-
//| .. function:: pack_into(fmt, buffer, offset, *values)
89-
//|
90-
//| Pack the values according to the format string fmt into a buffer
91-
//| starting at offset. offset may be negative to count from the end of buffer.
88+
//| def pack_into(fmt: Any, buffer: Any, offset: Any, *values: Any) -> Any:
89+
//| """Pack the values according to the format string fmt into a buffer
90+
//| starting at offset. offset may be negative to count from the end of buffer."""
91+
//| ...
9292
//|
9393

9494
STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) {
@@ -111,11 +111,11 @@ STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) {
111111
}
112112
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_into_obj, 3, MP_OBJ_FUN_ARGS_MAX, struct_pack_into);
113113

114-
//| .. function:: unpack(fmt, data)
115-
//|
116-
//| Unpack from the data according to the format string fmt. The return value
117-
//| is a tuple of the unpacked values. The buffer size must match the size
118-
//| required by the format.
114+
//| def unpack(fmt: Any, data: Any) -> Any:
115+
//| """Unpack from the data according to the format string fmt. The return value
116+
//| is a tuple of the unpacked values. The buffer size must match the size
117+
//| required by the format."""
118+
//| ...
119119
//|
120120

121121
STATIC mp_obj_t struct_unpack(size_t n_args, const mp_obj_t *args) {
@@ -129,12 +129,12 @@ STATIC mp_obj_t struct_unpack(size_t n_args, const mp_obj_t *args) {
129129
}
130130
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_unpack_obj, 2, 3, struct_unpack);
131131

132-
//| .. function:: unpack_from(fmt, data, offset=0)
133-
//|
134-
//| Unpack from the data starting at offset according to the format string fmt.
135-
//| offset may be negative to count from the end of buffer. The return value is
136-
//| a tuple of the unpacked values. The buffer size must be at least as big
137-
//| as the size required by the form.
132+
//| def unpack_from(fmt: Any, data: Any, offset: Any = 0) -> Any:
133+
//| """Unpack from the data starting at offset according to the format string fmt.
134+
//| offset may be negative to count from the end of buffer. The return value is
135+
//| a tuple of the unpacked values. The buffer size must be at least as big
136+
//| as the size required by the form."""
137+
//| ...
138138
//|
139139

140140
STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {

shared-bindings/supervisor/Runtime.c

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,35 +29,35 @@
2929
#include "shared-bindings/supervisor/Runtime.h"
3030

3131
//TODO: add USB, REPL to description once they're operational
32-
//| .. currentmodule:: supervisor
32+
//| class Runtime:
33+
//| """.. currentmodule:: supervisor
3334
//|
34-
//| :class:`Runtime` --- Supervisor Runtime information
35-
//| ----------------------------------------------------
35+
//| :class:`Runtime` --- Supervisor Runtime information
36+
//| ----------------------------------------------------
3637
//|
37-
//| Get current status of runtime objects.
38+
//| Get current status of runtime objects.
3839
//|
39-
//| Usage::
40+
//| Usage::
4041
//|
41-
//| import supervisor
42-
//| if supervisor.runtime.serial_connected:
43-
//| print("Hello World!")
42+
//| import supervisor
43+
//| if supervisor.runtime.serial_connected:
44+
//| print("Hello World!")"""
4445
//|
4546

46-
//| .. class:: Runtime()
47-
//|
48-
//| You cannot create an instance of `supervisor.Runtime`.
49-
//| Use `supervisor.runtime` to access the sole instance available.
47+
//| def __init__(self, ):
48+
//| """You cannot create an instance of `supervisor.Runtime`.
49+
//| Use `supervisor.runtime` to access the sole instance available."""
50+
//| ...
5051
//|
5152

52-
//| .. attribute:: runtime.serial_connected
53-
//|
54-
//| Returns the USB serial communication status (read-only).
53+
//| runtime.serial_connected: Any = ...
54+
//| """Returns the USB serial communication status (read-only).
5555
//|
5656
//| .. note::
5757
//|
5858
//| SAMD: Will return ``True`` if the USB serial connection
5959
//| has been established at any point. Will not reset if
60-
//| USB is disconnected but power remains (e.g. battery connected)
60+
//| USB is disconnected but power remains (e.g. battery connected)"""
6161
//|
6262

6363
STATIC mp_obj_t supervisor_get_serial_connected(mp_obj_t self){
@@ -78,11 +78,10 @@ const mp_obj_property_t supervisor_serial_connected_obj = {
7878
};
7979

8080

81-
//| .. attribute:: runtime.serial_bytes_available
82-
//|
83-
//| Returns the whether any bytes are available to read
84-
//| on the USB serial input. Allows for polling to see whether
85-
//| to call the built-in input() or wait. (read-only)
81+
//| runtime.serial_bytes_available: Any = ...
82+
//| """Returns the whether any bytes are available to read
83+
//| on the USB serial input. Allows for polling to see whether
84+
//| to call the built-in input() or wait. (read-only)"""
8685
//|
8786
STATIC mp_obj_t supervisor_get_serial_bytes_available(mp_obj_t self){
8887
if (!common_hal_get_serial_bytes_available()) {

shared-bindings/supervisor/__init__.c

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include "shared-bindings/supervisor/__init__.h"
3737
#include "shared-bindings/supervisor/Runtime.h"
3838

39-
//| :mod:`supervisor` --- Supervisor settings
39+
//| """:mod:`supervisor` --- Supervisor settings
4040
//| =================================================
4141
//|
4242
//| .. module:: supervisor
@@ -50,41 +50,40 @@
5050
//| .. toctree::
5151
//| :maxdepth: 3
5252
//|
53-
//| Runtime
53+
//| Runtime"""
5454
//|
5555

56-
//| .. attribute:: runtime
57-
//|
58-
//| Runtime information, such as `runtime.serial_connected`
59-
//| (USB serial connection status).
60-
//| This object is the sole instance of `supervisor.Runtime`.
56+
//| runtime: Any = ...
57+
//| """Runtime information, such as `runtime.serial_connected`
58+
//| (USB serial connection status).
59+
//| This object is the sole instance of `supervisor.Runtime`."""
6160
//|
6261

63-
//| .. method:: enable_autoreload()
64-
//|
65-
//| Enable autoreload based on USB file write activity.
62+
//| def enable_autoreload(self, ) -> Any:
63+
//| """Enable autoreload based on USB file write activity."""
64+
//| ...
6665
//|
6766
STATIC mp_obj_t supervisor_enable_autoreload(void) {
6867
autoreload_enable();
6968
return mp_const_none;
7069
}
7170
MP_DEFINE_CONST_FUN_OBJ_0(supervisor_enable_autoreload_obj, supervisor_enable_autoreload);
7271

73-
//| .. method:: disable_autoreload()
74-
//|
75-
//| Disable autoreload based on USB file write activity until
76-
//| `enable_autoreload` is called.
72+
//| def disable_autoreload(self, ) -> Any:
73+
//| """Disable autoreload based on USB file write activity until
74+
//| `enable_autoreload` is called."""
75+
//| ...
7776
//|
7877
STATIC mp_obj_t supervisor_disable_autoreload(void) {
7978
autoreload_disable();
8079
return mp_const_none;
8180
}
8281
MP_DEFINE_CONST_FUN_OBJ_0(supervisor_disable_autoreload_obj, supervisor_disable_autoreload);
8382

84-
//| .. method:: set_rgb_status_brightness()
85-
//|
86-
//| Set brightness of status neopixel from 0-255
87-
//| `set_rgb_status_brightness` is called.
83+
//| def set_rgb_status_brightness(self, ) -> Any:
84+
//| """Set brightness of status neopixel from 0-255
85+
//| `set_rgb_status_brightness` is called."""
86+
//| ...
8887
//|
8988
STATIC mp_obj_t supervisor_set_rgb_status_brightness(mp_obj_t lvl){
9089
// This must be int. If cast to uint8_t first, will never raise a ValueError.
@@ -97,9 +96,9 @@ STATIC mp_obj_t supervisor_set_rgb_status_brightness(mp_obj_t lvl){
9796
}
9897
MP_DEFINE_CONST_FUN_OBJ_1(supervisor_set_rgb_status_brightness_obj, supervisor_set_rgb_status_brightness);
9998

100-
//| .. method:: reload()
101-
//|
102-
//| Reload the main Python code and run it (equivalent to hitting Ctrl-D at the REPL).
99+
//| def reload(self, ) -> Any:
100+
//| """Reload the main Python code and run it (equivalent to hitting Ctrl-D at the REPL)."""
101+
//| ...
103102
//|
104103
STATIC mp_obj_t supervisor_reload(void) {
105104
reload_requested = true;
@@ -108,9 +107,9 @@ STATIC mp_obj_t supervisor_reload(void) {
108107
}
109108
MP_DEFINE_CONST_FUN_OBJ_0(supervisor_reload_obj, supervisor_reload);
110109

111-
//| .. method:: set_next_stack_limit(size)
112-
//|
113-
//| Set the size of the stack for the next vm run. If its too large, the default will be used.
110+
//| def set_next_stack_limit(self, size: Any) -> Any:
111+
//| """Set the size of the stack for the next vm run. If its too large, the default will be used."""
112+
//| ...
114113
//|
115114
STATIC mp_obj_t supervisor_set_next_stack_limit(mp_obj_t size_obj) {
116115
mp_int_t size = mp_obj_get_int(size_obj);

shared-bindings/terminalio/Terminal.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@
3737
#include "shared-bindings/fontio/BuiltinFont.h"
3838
#include "supervisor/shared/translate.h"
3939

40-
41-
//| .. currentmodule:: terminalio
42-
//|
43-
//| :class:`Terminal` -- display a character stream with a TileGrid
44-
//| ================================================================
40+
//| class Terminal:
41+
//| """.. currentmodule:: terminalio
4542
//|
46-
//| .. class:: Terminal(tilegrid, font)
43+
//| :class:`Terminal` -- display a character stream with a TileGrid
44+
//| ================================================================"""
4745
//|
48-
//| Terminal manages tile indices and cursor position based on VT100 commands. The font should be
49-
//| a `fontio.BuiltinFont` and the TileGrid's bitmap should match the font's bitmap.
46+
//| def __init__(self, tilegrid: Any, font: Any):
47+
//| """Terminal manages tile indices and cursor position based on VT100 commands. The font should be
48+
//| a `fontio.BuiltinFont` and the TileGrid's bitmap should match the font's bitmap."""
49+
//| ...
5050
//|
5151

5252
STATIC mp_obj_t terminalio_terminal_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
@@ -75,12 +75,12 @@ STATIC mp_obj_t terminalio_terminal_make_new(const mp_obj_type_t *type, size_t n
7575

7676
// These are standard stream methods. Code is in py/stream.c.
7777
//
78-
//| .. method:: write(buf)
79-
//|
80-
//| Write the buffer of bytes to the bus.
78+
//| def write(self, buf: Any) -> Any:
79+
//| """Write the buffer of bytes to the bus.
8180
//|
82-
//| :return: the number of bytes written
83-
//| :rtype: int or None
81+
//| :return: the number of bytes written
82+
//| :rtype: int or None"""
83+
//| ...
8484
//|
8585
STATIC mp_uint_t terminalio_terminal_write(mp_obj_t self_in, const void *buf_in, mp_uint_t size, int *errcode) {
8686
terminalio_terminal_obj_t *self = MP_OBJ_TO_PTR(self_in);

shared-bindings/terminalio/__init__.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
#include "py/runtime.h"
3737

38-
//| :mod:`terminalio` --- Displays text in a TileGrid
38+
//| """:mod:`terminalio` --- Displays text in a TileGrid
3939
//| =================================================
4040
//|
4141
//| .. module:: terminalio
@@ -49,7 +49,7 @@
4949
//| .. toctree::
5050
//| :maxdepth: 3
5151
//|
52-
//| Terminal
52+
//| Terminal"""
5353
//|
5454
//|
5555
STATIC const mp_rom_map_elem_t terminalio_module_globals_table[] = {

0 commit comments

Comments
 (0)