Skip to content

Commit 1cf3762

Browse files
committed
Merge remote-tracking branch 'origin/main' into stm32-sdioio
2 parents 0e2d231 + ce911c5 commit 1cf3762

File tree

110 files changed

+927
-782
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+927
-782
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ _build
5757
######################
5858
genrst/
5959
/autoapi/
60-
/shared-bindings/**/*.rst
60+
/shared-bindings/*/**/*.rst
6161

6262
# ctags and similar
6363
###################
@@ -80,3 +80,8 @@ TAGS
8080
*.mo
8181

8282
.vscode
83+
84+
# Python Virtual Environments
85+
####################
86+
.venv
87+
.env

.readthedocs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
version: 2
1010

11+
submodules:
12+
include:
13+
- extmod/ulab
14+
1115
python:
1216
version: 3
1317
install:

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ stubs:
245245
@$(PYTHON) tools/extract_pyi.py ports/atmel-samd/bindings $(STUBDIR)
246246
@$(PYTHON) setup.py -q sdist
247247

248+
.PHONY: check-stubs
249+
check-stubs: stubs
250+
MYPYPATH=$(STUBDIR) mypy --strict $(STUBDIR)
251+
248252
update-frozen-libraries:
249253
@echo "Updating all frozen libraries to latest tagged version."
250254
cd frozen; for library in *; do cd $$library; ../../tools/git-checkout-latest-tag.sh; cd ..; done

conf.py

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@
1717
#
1818
# SPDX-License-Identifier: MIT
1919

20-
import json
2120
import logging
2221
import os
22+
import re
2323
import subprocess
2424
import sys
2525
import urllib.parse
2626

2727
import recommonmark
28+
from sphinx.transforms import SphinxTransform
29+
from docutils import nodes
30+
from sphinx import addnodes
2831

2932
# If extensions (or modules to document with autodoc) are in another directory,
3033
# add these directories to sys.path here. If the directory is relative to the
@@ -84,6 +87,7 @@
8487
autoapi_add_toctree_entry = False
8588
autoapi_options = ['members', 'undoc-members', 'private-members', 'show-inheritance', 'special-members', 'show-module-summary']
8689
autoapi_template_dir = 'docs/autoapi/templates'
90+
autoapi_python_class_content = "both"
8791
autoapi_python_use_implicit_namespaces = True
8892
autoapi_root = "shared-bindings"
8993

@@ -106,7 +110,25 @@
106110
#
107111
# We don't follow "The short X.Y version" vs "The full version, including alpha/beta/rc tags"
108112
# breakdown, so use the same version identifier for both to avoid confusion.
109-
version = release = '0.0.0'
113+
114+
final_version = ""
115+
git_describe = subprocess.run(
116+
["git", "describe", "--dirty", "--tags"],
117+
stdout=subprocess.PIPE,
118+
stderr=subprocess.STDOUT,
119+
encoding="utf-8"
120+
)
121+
if git_describe.returncode == 0:
122+
git_version = re.search(
123+
r"^\d(?:\.\d){0,2}(?:\-(?:alpha|beta|rc)\.\d+){0,1}",
124+
str(git_describe.stdout)
125+
)
126+
if git_version:
127+
final_version = git_version[0]
128+
else:
129+
print("Failed to retrieve git version:", git_describe.stdout)
130+
131+
version = release = final_version
110132

111133
# The language for content autogenerated by Sphinx. Refer to documentation
112134
# for a list of supported languages.
@@ -423,7 +445,38 @@ def generate_redirects(app):
423445
with open(redirected_filename, 'w') as f:
424446
f.write(TEMPLATE % urllib.parse.quote(to_path, '#/'))
425447

448+
449+
class CoreModuleTransform(SphinxTransform):
450+
default_priority = 870
451+
452+
def _convert_first_paragraph_into_title(self):
453+
title = self.document.next_node(nodes.title)
454+
paragraph = self.document.next_node(nodes.paragraph)
455+
if not title or not paragraph:
456+
return
457+
if isinstance(paragraph[0], nodes.paragraph):
458+
paragraph = paragraph[0]
459+
if all(isinstance(child, nodes.Text) for child in paragraph.children):
460+
for child in paragraph.children:
461+
title.append(nodes.Text(" \u2013 "))
462+
title.append(child)
463+
paragraph.parent.remove(paragraph)
464+
465+
def _enable_linking_to_nonclass_targets(self):
466+
for desc in self.document.traverse(addnodes.desc):
467+
for xref in desc.traverse(addnodes.pending_xref):
468+
if xref.attributes.get("reftype") == "class":
469+
xref.attributes.pop("refspecific", None)
470+
471+
def apply(self, **kwargs):
472+
docname = self.env.docname
473+
if docname.startswith(autoapi_root) and docname.endswith("/index"):
474+
self._convert_first_paragraph_into_title()
475+
self._enable_linking_to_nonclass_targets()
476+
477+
426478
def setup(app):
427479
app.add_css_file("customstyle.css")
428480
app.add_config_value('redirects_file', 'redirects', 'env')
429481
app.connect('builder-inited', generate_redirects)
482+
app.add_transform(CoreModuleTransform)

docs/autoapi/templates/python/module.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
{% set visible_subpackages = obj.subpackages|selectattr("display")|list %}
1919
{% if visible_subpackages %}
2020
.. toctree::
21-
:titlesonly:
22-
:maxdepth: 3
21+
:maxdepth: 2
2322

2423
{% for subpackage in visible_subpackages %}
2524
{{ subpackage.short_name }}/index.rst

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
sphinx<3
1+
sphinx<4
22
recommonmark==0.6.0
33
sphinxcontrib-svg2pdfconverter==0.1.0
44
astroid

extmod/moductypes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t base_in, mp_obj_t index_in, mp_ob
520520
uint val_type = GET_TYPE(arr_sz, VAL_TYPE_BITS);
521521
arr_sz &= VALUE_MASK(VAL_TYPE_BITS);
522522
if (index >= arr_sz) {
523-
nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, translate("struct: index out of range")));
523+
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_struct);
524524
}
525525

526526
if (t->len == 2) {

extmod/vfs_fat_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const byte fresult_to_errno_table[20] = {
4242

4343
STATIC void file_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
4444
(void)kind;
45-
mp_printf(print, "<io.%s %p>", mp_obj_get_type_str(self_in), MP_OBJ_TO_PTR(self_in));
45+
mp_printf(print, "<io.%q %p>", mp_obj_get_type_qstr(self_in), MP_OBJ_TO_PTR(self_in));
4646
}
4747

4848
STATIC mp_uint_t file_obj_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) {

extmod/vfs_posix_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ STATIC void check_fd_is_open(const mp_obj_vfs_posix_file_t *o) {
3434
STATIC void vfs_posix_file_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
3535
(void)kind;
3636
mp_obj_vfs_posix_file_t *self = MP_OBJ_TO_PTR(self_in);
37-
mp_printf(print, "<io.%s %d>", mp_obj_get_type_str(self_in), self->fd);
37+
mp_printf(print, "<io.%q %d>", mp_obj_get_type_qstr(self_in), self->fd);
3838
}
3939

4040
mp_obj_t mp_vfs_posix_file_open(const mp_obj_type_t *type, mp_obj_t file_in, mp_obj_t mode_in) {

0 commit comments

Comments
 (0)