Skip to content

Commit cfe24b8

Browse files
committed
Improve rST consistency for rst2pyi use
1 parent 63b253c commit cfe24b8

30 files changed

Lines changed: 165 additions & 148 deletions

File tree

shared-bindings/_pixelbuf/PixelBuf.c

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ extern const int32_t colorwheel(float pos);
5151
//|
5252
//| :class:`~_pixelbuf.PixelBuf` implements an RGB[W] bytearray abstraction.
5353
//|
54-
//| .. class:: PixelBuf(size, buf, byteorder=BGR, bpp=3)
54+
//| .. class:: PixelBuf(size, buf, byteorder=BGR, brightness=0, rawbuf=None, offset=0, dotstar=False, auto_write=False, write_function=None, write_args=None)
5555
//|
5656
//| Create a PixelBuf object of the specified size, byteorder, and bits per pixel.
5757
//|
@@ -66,14 +66,14 @@ extern const int32_t colorwheel(float pos);
6666
//|
6767
//| :param ~int size: Number of pixelsx
6868
//| :param ~bytearray buf: Bytearray to store pixel data in
69-
//| :param ~_pixelbuf.ByteOrder byteorder: Byte order constant from `_pixelbuf` (also sets the bpp)
69+
//| :param ~_pixelbuf.ByteOrder byteorder: Byte order constant from `_pixelbuf`
7070
//| :param ~float brightness: Brightness (0 to 1.0, default 1.0)
7171
//| :param ~bytearray rawbuf: Bytearray to store raw pixel colors in
7272
//| :param ~int offset: Offset from start of buffer (default 0)
7373
//| :param ~bool dotstar: Dotstar mode (default False)
7474
//| :param ~bool auto_write: Whether to automatically write pixels (Default False)
7575
//| :param ~callable write_function: (optional) Callable to use to send pixels
76-
//| :param ~list write_args: (optional) Tuple or list of args to pass to ``write_function``. The
76+
//| :param ~list write_args: (optional) Tuple or list of args to pass to ``write_function``. The
7777
//| PixelBuf instance is appended after these args.
7878
//|
7979
STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
@@ -95,7 +95,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a
9595
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
9696
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
9797

98-
if (mp_obj_is_subclass_fast(args[ARG_byteorder].u_obj, &pixelbuf_byteorder_type))
98+
if (mp_obj_is_subclass_fast(args[ARG_byteorder].u_obj, &pixelbuf_byteorder_type))
9999
mp_raise_TypeError_varg(translate("byteorder is not an instance of ByteOrder (got a %s)"), mp_obj_get_type_str(args[ARG_byteorder].u_obj));
100100

101101
pixelbuf_byteorder_obj_t *byteorder = (args[ARG_byteorder].u_obj == mp_const_none) ? MP_OBJ_FROM_PTR(&byteorder_BGR) : args[ARG_byteorder].u_obj;
@@ -122,7 +122,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a
122122

123123
if (!MP_OBJ_IS_TYPE(args[ARG_write_args].u_obj, &mp_type_list) &&
124124
!MP_OBJ_IS_TYPE(args[ARG_write_args].u_obj, &mp_type_tuple) &&
125-
args[ARG_write_args].u_obj != mp_const_none)
125+
args[ARG_write_args].u_obj != mp_const_none)
126126
{
127127
mp_raise_ValueError(translate("write_args must be a list, tuple, or None"));
128128
}
@@ -186,8 +186,8 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a
186186
else if (self->brightness > 1)
187187
self->brightness = 1;
188188
}
189-
190-
if (self->dotstar_mode) {
189+
190+
if (self->dotstar_mode) {
191191
// Initialize the buffer with the dotstar start bytes.
192192
// Header and end must be setup by caller
193193
for (uint i = 0; i < self->pixels * 4; i += 4) {
@@ -197,7 +197,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a
197197
}
198198
}
199199
}
200-
200+
201201
return MP_OBJ_FROM_PTR(self);
202202
}
203203

@@ -227,7 +227,7 @@ const mp_obj_property_t pixelbuf_pixelbuf_bpp_obj = {
227227
//| setting this value causes a recomputation of the values in buf.
228228
//| If only a buf was provided, then the brightness only applies to
229229
//| future pixel changes.
230-
//| In DotStar mode
230+
//| In DotStar mode
231231
//|
232232
STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_brightness(mp_obj_t self_in) {
233233
mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type));
@@ -266,7 +266,7 @@ void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self) {
266266
// Compensate for shifted buffer (bpp=3 dotstar)
267267
for (uint i = 0; i < self->bytes; i++) {
268268
// Don't adjust per-pixel luminance bytes in dotstar mode
269-
if (!self->dotstar_mode || (i % 4 != 0))
269+
if (!self->dotstar_mode || (i % 4 != 0))
270270
buf[i] = rawbuf[i] * self->brightness;
271271
}
272272
}
@@ -367,11 +367,13 @@ void call_write_function(pixelbuf_pixelbuf_obj_t *self) {
367367
}
368368
}
369369

370-
371-
372-
//| .. method:: []
370+
//| .. method:: __getitem__(index)
371+
//|
372+
//| Returns the pixel value at the given index.
373373
//|
374-
//| Get or set pixels. Supports individual pixels and slices.
374+
//| .. method:: __setitem__(index, value)
375+
//|
376+
//| Sets the pixel value at the given index.
375377
//|
376378
STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) {
377379
mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type));
@@ -380,7 +382,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp
380382
// delete item
381383
// slice deletion
382384
return MP_OBJ_NULL; // op not supported
383-
}
385+
}
384386

385387
pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in);
386388
if (0) {
@@ -390,7 +392,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp
390392

391393
if (!mp_seq_get_fast_slice_indexes(self->bytes, index_in, &slice))
392394
mp_raise_NotImplementedError(translate("Only slices with step=1 (aka None) are supported"));
393-
if ((slice.stop * self->pixel_step) > self->bytes)
395+
if ((slice.stop * self->pixel_step) > self->bytes)
394396
mp_raise_IndexError(translate("Range out of bounds"));
395397

396398
if (value == MP_OBJ_SENTINEL) { // Get
@@ -422,8 +424,8 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp
422424
for (size_t i = slice.start; i < slice.stop; i++) {
423425
mp_obj_t *item = src_objs[i-slice.start];
424426
if (MP_OBJ_IS_TYPE(value, &mp_type_list) || MP_OBJ_IS_TYPE(value, &mp_type_tuple) || MP_OBJ_IS_INT(value)) {
425-
pixelbuf_set_pixel(self->buf + (i * self->pixel_step),
426-
self->two_buffers ? self->rawbuf + (i * self->pixel_step) : NULL,
427+
pixelbuf_set_pixel(self->buf + (i * self->pixel_step),
428+
self->two_buffers ? self->rawbuf + (i * self->pixel_step) : NULL,
427429
self->brightness, item, &self->byteorder, self->dotstar_mode);
428430
}
429431
}
@@ -438,14 +440,14 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp
438440
} else { // Single index rather than slice.
439441
size_t index = mp_get_index(self->base.type, self->pixels, index_in, false);
440442
size_t offset = (index * self->pixel_step);
441-
if (offset > self->bytes)
443+
if (offset > self->bytes)
442444
mp_raise_IndexError(translate("Pixel beyond bounds of buffer"));
443445

444446
if (value == MP_OBJ_SENTINEL) { // Get
445447
uint8_t *pixelstart = (uint8_t *)(self->two_buffers ? self->rawbuf : self->buf) + offset;
446448
return pixelbuf_get_pixel(pixelstart, &self->byteorder, self->dotstar_mode);
447449
} else { // Store
448-
pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL,
450+
pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL,
449451
self->brightness, value, &self->byteorder, self->dotstar_mode);
450452
if (self->auto_write)
451453
call_write_function(self);

shared-bindings/_pixelbuf/__init__.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
//|
5454
//| PixelBuf
5555

56-
//| .. class:: ByteOrder
56+
//| .. class:: ByteOrder()
5757
//|
5858
//| Classes representing byteorders for circuitpython
5959

@@ -169,34 +169,34 @@ const int32_t colorwheel(float pos) {
169169

170170

171171
/// RGB
172-
//| .. class:: RGB
172+
//| .. data:: RGB
173173
//|
174174
//| * **order** Red, Green, Blue
175175
//| * **bpp** 3
176176
PIXELBUF_BYTEORDER(RGB, 3, 0, 1, 2, 3, false, false)
177-
//| .. class:: RBG
177+
//| .. data:: RBG
178178
//|
179179
//| * **order** Red, Blue, Green
180180
//| * **bpp** 3
181181
PIXELBUF_BYTEORDER(RBG, 3, 0, 2, 1, 3, false, false)
182-
//| .. class:: GRB
182+
//| .. data:: GRB
183183
//|
184184
//| * **order** Green, Red, Blue
185185
//| * **bpp** 3
186186
//|
187187
//| Commonly used by NeoPixel.
188188
PIXELBUF_BYTEORDER(GRB, 3, 1, 0, 2, 3, false, false)
189-
//| .. class:: GBR
189+
//| .. data:: GBR
190190
//|
191191
//| * **order** Green, Blue, Red
192192
//| * **bpp** 3
193193
PIXELBUF_BYTEORDER(GBR, 3, 1, 2, 0, 3, false, false)
194-
//| .. class:: BRG
194+
//| .. data:: BRG
195195
//|
196196
//| * **order** Blue, Red, Green
197197
//| * **bpp** 3
198198
PIXELBUF_BYTEORDER(BRG, 3, 2, 0, 1, 3, false, false)
199-
//| .. class:: BGR
199+
//| .. data:: BGR
200200
//|
201201
//| * **order** Blue, Green, Red
202202
//| * **bpp** 3
@@ -205,39 +205,39 @@ PIXELBUF_BYTEORDER(BRG, 3, 2, 0, 1, 3, false, false)
205205
PIXELBUF_BYTEORDER(BGR, 3, 2, 1, 0, 3, false, false)
206206

207207
// RGBW
208-
//| .. class:: RGBW
208+
//| .. data:: RGBW
209209
//|
210210
//| * **order** Red, Green, Blue, White
211211
//| * **bpp** 4
212212
//| * **has_white** True
213213
PIXELBUF_BYTEORDER(RGBW, 4, 0, 1, 2, 3, true, false)
214-
//| .. class:: RBGW
214+
//| .. data:: RBGW
215215
//|
216216
//| * **order** Red, Blue, Green, White
217217
//| * **bpp** 4
218218
//| * **has_white** True
219219
PIXELBUF_BYTEORDER(RBGW, 4, 0, 2, 1, 3, true, false)
220-
//| .. class:: GRBW
220+
//| .. data:: GRBW
221221
//|
222222
//| * **order** Green, Red, Blue, White
223223
//| * **bpp** 4
224224
//| * **has_white** True
225225
//|
226226
//| Commonly used by RGBW NeoPixels.
227227
PIXELBUF_BYTEORDER(GRBW, 4, 1, 0, 2, 3, true, false)
228-
//| .. class:: GBRW
228+
//| .. data:: GBRW
229229
//|
230230
//| * **order** Green, Blue, Red, White
231231
//| * **bpp** 4
232232
//| * **has_white** True
233233
PIXELBUF_BYTEORDER(GBRW, 4, 1, 2, 0, 3, true, false)
234-
//| .. class:: BRGW
234+
//| .. data:: BRGW
235235
//|
236236
//| * **order** Blue, Red, Green, White
237237
//| * **bpp** 4
238238
//| * **has_white** True
239239
PIXELBUF_BYTEORDER(BRGW, 4, 2, 0, 1, 3, true, false)
240-
//| .. class:: BGRW
240+
//| .. data:: BGRW
241241
//|
242242
//| * **order** Blue, Green, Red, White
243243
//| * **bpp** 4
@@ -248,37 +248,37 @@ PIXELBUF_BYTEORDER(BGRW, 4, 2, 1, 0, 3, true, false)
248248
// Luminosity chosen because the luminosity of a Dotstar at full bright
249249
// burns the eyes like looking at the Sun.
250250
// https://www.thesaurus.com/browse/luminosity?s=t
251-
//| .. class:: LRGB
251+
//| .. data:: LRGB
252252
//|
253253
//| * **order** *Luminosity*, Red, Green, Blue
254254
//| * **bpp** 4
255255
//| * **has_luminosity** True
256256
PIXELBUF_BYTEORDER(LRGB, 4, 1, 2, 3, 0, false, true)
257-
//| .. class:: LRBG
257+
//| .. data:: LRBG
258258
//|
259259
//| * **order** *Luminosity*, Red, Blue, Green
260260
//| * **bpp** 4
261261
//| * **has_luminosity** True
262262
PIXELBUF_BYTEORDER(LRBG, 4, 1, 3, 2, 0, false, true)
263-
//| .. class:: LGRB
263+
//| .. data:: LGRB
264264
//|
265265
//| * **order** *Luminosity*, Green, Red, Blue
266266
//| * **bpp** 4
267267
//| * **has_luminosity** True
268268
PIXELBUF_BYTEORDER(LGRB, 4, 2, 1, 3, 0, false, true)
269-
//| .. class:: LGBR
269+
//| .. data:: LGBR
270270
//|
271271
//| * **order** *Luminosity*, Green, Blue, Red
272272
//| * **bpp** 4
273273
//| * **has_luminosity** True
274274
PIXELBUF_BYTEORDER(LGBR, 4, 2, 3, 1, 0, false, true)
275-
//| .. class:: LBRG
275+
//| .. data:: LBRG
276276
//|
277277
//| * **order** *Luminosity*, Blue, Red, Green
278278
//| * **bpp** 4
279279
//| * **has_luminosity** True
280280
PIXELBUF_BYTEORDER(LBRG, 4, 3, 1, 2, 0, false, true)
281-
//| .. class:: LBGR
281+
//| .. data:: LBGR
282282
//|
283283
//| * **order** *Luminosity*, Blue, Green, Red
284284
//| * **bpp** 4

shared-bindings/audiobusio/PDMIn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
//|
4444
//| PDMIn can be used to record an input audio signal on a given set of pins.
4545
//|
46-
//| .. class:: PDMIn(clock_pin, data_pin, \*, sample_rate=16000, bit_depth=8, mono=True, oversample=64, startup_delay=0.11)
46+
//| .. class:: PDMIn(clock_pin, data_pin, *, sample_rate=16000, bit_depth=8, mono=True, oversample=64, startup_delay=0.11)
4747
//|
4848
//| Create a PDMIn object associated with the given pins. This allows you to
4949
//| record audio signals from the given pins. Individual ports may put further

shared-bindings/audioio/WaveFile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
//| A .wav file prepped for audio playback. Only mono and stereo files are supported. Samples must
4242
//| be 8 bit unsigned or 16 bit signed.
4343
//|
44-
//| .. class:: WaveFile(filename)
44+
//| .. class:: WaveFile(file)
4545
//|
4646
//| Load a .wav file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`.
4747
//|
48-
//| :param bytes-like file: Already opened wave file
48+
//| :param typing.BinaryIO file: Already opened wave file
4949
//|
5050
//| Playing a wave file from flash::
5151
//|

shared-bindings/bitbangio/I2C.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
//| :class:`I2C` --- Two wire serial protocol
4343
//| ------------------------------------------
4444
//|
45-
//| .. class:: I2C(scl, sda, \*, frequency=400000)
45+
//| .. class:: I2C(scl, sda, *, frequency=400000, timeout)
4646
//|
4747
//| I2C is a two-wire protocol for communicating between devices. At the
4848
//| physical level it consists of 2 wires: SCL and SDA, the clock and data
@@ -75,7 +75,7 @@ STATIC mp_obj_t bitbangio_i2c_make_new(const mp_obj_type_t *type, size_t n_args,
7575
return (mp_obj_t)self;
7676
}
7777

78-
//| .. method:: I2C.deinit()
78+
//| .. method:: deinit()
7979
//|
8080
//| Releases control of the underlying hardware so other classes can use it.
8181
//|
@@ -86,13 +86,13 @@ STATIC mp_obj_t bitbangio_i2c_obj_deinit(mp_obj_t self_in) {
8686
}
8787
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_deinit_obj, bitbangio_i2c_obj_deinit);
8888

89-
//| .. method:: I2C.__enter__()
89+
//| .. method:: __enter__()
9090
//|
9191
//| No-op used in Context Managers.
9292
//|
9393
// Provided by context manager helper.
9494

95-
//| .. method:: I2C.__exit__()
95+
//| .. method:: __exit__()
9696
//|
9797
//| Automatically deinitializes the hardware on context exit. See
9898
//| :ref:`lifetime-and-contextmanagers` for more info.
@@ -110,7 +110,7 @@ static void check_lock(bitbangio_i2c_obj_t *self) {
110110
}
111111
}
112112

113-
//| .. method:: I2C.scan()
113+
//| .. method:: scan()
114114
//|
115115
//| Scan all I2C addresses between 0x08 and 0x77 inclusive and return a list of
116116
//| those that respond. A device responds if it pulls the SDA line low after
@@ -132,7 +132,7 @@ STATIC mp_obj_t bitbangio_i2c_scan(mp_obj_t self_in) {
132132
}
133133
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_scan_obj, bitbangio_i2c_scan);
134134

135-
//| .. method:: I2C.try_lock()
135+
//| .. method:: try_lock()
136136
//|
137137
//| Attempts to grab the I2C lock. Returns True on success.
138138
//|
@@ -143,7 +143,7 @@ STATIC mp_obj_t bitbangio_i2c_obj_try_lock(mp_obj_t self_in) {
143143
}
144144
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_try_lock_obj, bitbangio_i2c_obj_try_lock);
145145

146-
//| .. method:: I2C.unlock()
146+
//| .. method:: unlock()
147147
//|
148148
//| Releases the I2C lock.
149149
//|
@@ -155,7 +155,7 @@ STATIC mp_obj_t bitbangio_i2c_obj_unlock(mp_obj_t self_in) {
155155
}
156156
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_unlock_obj, bitbangio_i2c_obj_unlock);
157157

158-
//| .. method:: I2C.readfrom_into(address, buffer, \*, start=0, end=len(buffer))
158+
//| .. method:: readfrom_into(address, buffer, *, start=0, end=None)
159159
//|
160160
//| Read into ``buffer`` from the slave specified by ``address``.
161161
//| The number of bytes read will be the length of ``buffer``.
@@ -203,7 +203,7 @@ STATIC mp_obj_t bitbangio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_a
203203
}
204204
MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_readfrom_into_obj, 3, bitbangio_i2c_readfrom_into);
205205

206-
//| .. method:: I2C.writeto(address, buffer, \*, start=0, end=len(buffer), stop=True)
206+
//| .. method:: writeto(address, buffer, *, start=0, end=None, stop=True)
207207
//|
208208
//| Write the bytes from ``buffer`` to the slave specified by ``address``.
209209
//| Transmits a stop bit if ``stop`` is set.

0 commit comments

Comments
 (0)