8000 Merge pull request #4 from adafruit/master · adafruit/circuitpython@7fa5009 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7fa5009

Browse files
authored
Merge pull request #4 from adafruit/master
merge from adafruit
2 parents 114f06d + 2c2b533 commit 7fa5009

File tree

306 files changed

+12162
-6618
lines changed
  • multiterminal
  • neopixel_write
  • network
  • nvm
  • os
  • ps2io
  • pulseio
  • random
  • rgbmatrix
  • rotaryio
  • rtc
  • socket
  • storage
  • struct
  • supervisor
  • terminalio
  • time
  • touchio
  • uheap
  • ulab
  • usb_hid
  • usb_midi
  • ustack
  • vectorio
  • wiznet
  • shared-module
  • supervisor
  • Some content is hidden

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

    306 files changed

    +12162
    -6618
    lines changed

    .github/workflows/build.yml

    Lines changed: 6 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -34,7 +34,7 @@ jobs:
    3434
    run: |
    3535
    sudo apt-get install -y eatmydata
    3636
    sudo eatmydata apt-get install -y gettext librsvg2-bin mingw-w64
    37-
    pip install requests sh click setuptools cpp-coveralls "Sphinx<4" sphinx-rtd-theme recommonmark sphinxcontrib-svg2pdfconverter polib pyyaml
    37+
    pip install requests sh click setuptools cpp-coveralls "Sphinx<4" sphinx-rtd-theme recommonmark sphinx-autoapi sphinxcontrib-svg2pdfconverter polib pyyaml astroid
    3838
    - name: Versions
    3939
    run: |
    4040
    gcc --version
    @@ -64,6 +64,8 @@ jobs:
    6464
    - name: mpy Tests
    6565
    run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -j1 --via-mpy -d basics float
    6666
    working-directory: tests
    67+
    - name: Stubs
    68+
    run: make stubs -j2
    6769
    - name: Docs
    6870
    run: sphinx-build -E -W -b html . _build/html
    6971
    - name: Translations
    @@ -216,11 +218,13 @@ jobs:
    216218
    - "pewpew10"
    217219
    - "pewpew_m4"
    218220
    - "pirkey_m0"
    221+
    - "pitaya_go"
    219222
    - "pyb_nano_v2"
    220223
    - "pybadge"
    221224
    - "pybadge_airlift"
    222225
    - "pyboard_v11"
    223226
    - "pycubed"
    227+
    - "pycubed_mram"
    224228
    - "pygamer"
    225229
    - "pygamer_advance"
    226230
    - "pyportal"
    @@ -249,6 +253,7 @@ jobs:
    249253
    - "stm32f746g_discovery"
    250254
    - "stringcar_m0_express"
    251255
    - "teensy40"
    256+
    - "teensy41"
    252257
    - "teknikio_bluebird"
    253258
    - "thunderpack"
    254259
    - "trellis_m4_express"

    .gitignore

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -14,6 +14,7 @@
    1414
    ############
    1515
    dist/
    1616
    *.egg-info
    17+
    .eggs
    1718

    1819
    # Logs and Databases
    1920
    ######################
    @@ -51,6 +52,7 @@ _build
    5152
    # Generated rst files
    5253
    ######################
    5354
    genrst/
    55+
    /autoapi/
    5456

    5557
    # ctags and similar
    5658
    ###################

    Makefile

    Lines changed: 6 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -67,9 +67,10 @@ help:
    6767

    6868
    clean:
    6969
    rm -rf $(BUILDDIR)/*
    70+
    rm -rf autoapi
    7071
    rm -rf $(STUBDIR) $(DISTDIR) *.egg-info
    7172

    72-
    html:
    73+
    html: stubs
    7374
    $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
    7475
    @echo
    7576
    @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
    @@ -213,8 +214,10 @@ check-translate: locale/circuitpython.pot $(wildcard locale/*.po)
    213214
    $(PYTHON) tools/check_translations.py $^
    214215

    215216
    stubs:
    216-
    rst2pyi $(VALIDATE) shared-bindings/ $(STUBDIR)
    217-
    python setup.py sdist
    217+
    @mkdir -p circuitpython-stubs
    218+
    @$(PYTHON) tools/extract_pyi.py shared-bindings/ $(STUBDIR)
    219+
    @$(PYTHON) tools/extract_pyi.py ports/atmel-samd/bindings $(STUBDIR)
    220+
    @$(PYTHON) setup.py -q sdist
    218221

    219222
    update-frozen-libraries:
    220223
    @echo "Updating all frozen libraries to latest tagged version."

    README.rst

    Lines changed: 3 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -3,7 +3,7 @@ CircuitPython
    33

    44
    .. image:: https://s3.amazonaws.com/adafruit-circuit-python/CircuitPython_Repo_header_logo.png
    55

    6-
    |Build Status| |Doc Status| |License| |Discord|
    6+
    |Build Status| |Doc Status| |License| |Discord| |Weblate|
    77

    88
    `circuitpython.org <https://circuitpython.org>`__ \| `Get CircuitPython <#get-circuitpython>`__ \|
    99
    `Documentation <#documentation>`__ \| `Contributing <#contributing>`__ \|
    @@ -219,3 +219,5 @@ The remaining port directories not listed above are in the repo to maintain comp
    219219
    :target: https://adafru.it/discord
    220220
    .. |License| image:: https://img.shields.io/badge/License-MIT-brightgreen.svg
    221221
    :target: https://choosealicense.com/licenses/mit/
    222+
    .. |Weblate| image:: https://hosted.weblate.org/widgets/circuitpython/-/svg-badge.svg
    223+
    :target: https://hosted.weblate.org/engage/circuitpython/?utm_source=widget

    conf.py

    Lines changed: 12 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -55,7 +55,6 @@
    5555
    'sphinx.ext.todo',
    5656
    'sphinx.ext.coverage',
    5757
    'rstjinja',
    58-
    'c2rst',
    5958
    'recommonmark',
    6059
    ]
    6160

    @@ -66,9 +65,18 @@
    6665
    source_suffix = {
    6766
    '.rst': 'restructuredtext',
    6867
    '.md': 'markdown',
    69-
    '.c': ''
    7068
    }
    7169

    70+
    extensions.append('autoapi.extension')
    71+
    72+
    autoapi_type = 'python'
    73+
    # Uncomment this if debugging autoapi
    74+
    autoapi_keep_files = True
    75+
    autoapi_dirs = [os.path.join('circuitpython-stubs', x) for x in os.listdir('circuitpython-stubs')]
    76+
    autoapi_add_toctree_entry = False
    77+
    autoapi_options = ['members', 'undoc-members', 'private-members', 'show-inheritance', 'special-members', 'show-module-summary']
    78+
    autoapi_template_dir = 'docs/autoapi/templates'
    79+
    autoapi_python_use_implicit_namespaces = True
    7280

    7381
    # The encoding of source files.
    7482
    #source_encoding = 'utf-8-sig'
    @@ -78,7 +86,7 @@
    7886

    7987
    # General information about the project.
    8088
    project = 'Adafruit CircuitPython'
    81-
    copyright = '2014-2018, MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)'
    89+
    copyright = '2014-2020, MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)'
    8290

    8391
    # These are overwritten on ReadTheDocs.
    8492
    # The version info for the project you're documenting, acts as replacement for
    @@ -105,6 +113,7 @@
    105113
    ".git",
    106114
    ".venv",
    107115
    ".direnv",
    116+
    "docs/autoapi",
    108117
    "docs/README.md",
    109118
    "drivers",
    110119
    "examples",
    Lines changed: 93 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,93 @@
    1+
    {% if not obj.display %}
    2+
    :orphan:
    3+
    4+
    {% endif %}
    5+
    :mod:`{{ obj.name }}`
    6+
    ======={{ "=" * obj.name|length }}
    7+
    8+
    .. py:module:: {{ obj.name }}
    9+
    10+
    {% if obj.docstring %}
    11+
    .. autoapi-nested-parse::
    12+
    13+
    {{ obj.docstring|prepare_docstring|indent(3) }}
    14+
    15+
    {% endif %}
    16+
    17+
    {% block subpackages %}
    18+
    {% set visible_subpackages = obj.subpackages|selectattr("display")|list %}
    19+
    {% if visible_subpackages %}
    20+
    .. toctree::
    21+
    :titlesonly:
    22+
    :maxdepth: 3
    23+
    24+
    {% for subpackage in visible_subpackages %}
    25+
    {{ subpackage.short_name }}/index.rst
    26+
    {% endfor %}
    27+
    28+
    29+
    {% endif %}
    30+
    {% endblock %}
    31+
    {% block submodules %}
    32+
    {% set visible_submodules = obj.submodules|selectattr("display")|list %}
    33+
    {% if visible_submodules %}
    34+
    35+
    .. toctree::
    36+
    :titlesonly:
    37+
    :maxdepth: 1
    38+
    39+
    {% for submodule in visible_submodules %}
    40+
    {{ submodule.short_name }}/index.rst
    41+
    {% endfor %}
    42+
    43+
    44+
    {% endif %}
    45+
    {% endblock %}
    46+
    {% block content %}
    47+
    {% if obj.all is not none %}
    48+
    {% set visible_children = obj.children|selectattr("short_name", "in", obj.all)|list %}
    49+
    {% elif obj.type is equalto("package") %}
    50+
    {% set visible_children = obj.children|selectattr("display")|list %}
    51+
    {% else %}
    52+
    {% set visible_children = obj.children|selectattr("display")|rejectattr("imported")|list %}
    53+
    {% endif %}
    54+
    {% if visible_children %}
    55+
    56+
    {% set visible_classes = visible_children|selectattr("type", "equalto", "class")|list %}
    57+
    {% set visible_functions = visible_children|selectattr("type", "equalto", "function")|list %}
    58+
    {% if "show-module-summary" in autoapi_options and (visible_classes or visible_functions) %}
    59+
    {% block classes %}
    60+
    {% if visible_classes %}
    61+
    Classes
    62+
    ~~~~~~~
    63+
    64+
    .. autoapisummary::
    65+
    66+
    {% for klass in visible_classes %}
    67+
    {{ klass.id }}
    68+
    {% endfor %}
    69+
    70+
    71+
    {% endif %}
    72+
    {% endblock %}
    73+
    74+
    {% block functions %}
    75+
    {% if visible_functions %}
    76+
    Functions
    77+
    ~~~~~~~~~
    78+
    79+
    .. autoapisummary::
    80+
    81+
    {% for function in visible_functions %}
    82+
    {{ function.id }}
    83+
    {% endfor %}
    84+
    85+
    86+
    {% endif %}
    87+
    {% endblock %}
    88+
    {% endif %}
    89+
    {% for obj_item in visible_children %}
    90+
    {{ obj_item.rendered|indent(0) }}
    91+
    {% endfor %}
    92+
    {% endif %}
    93+
    {% endblock %}

    docs/c2rst.py

    Lines changed: 0 additions & 31 deletions
    This file was deleted.

    extmod/modujson.c

    Lines changed: 24 additions & 9 deletions
    Original file li 10000 ne numberDiff line numberDiff line change
    @@ -53,6 +53,10 @@ STATIC mp_obj_t mod_ujson_dumps(mp_obj_t obj) {
    5353
    }
    5454
    STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_dumps_obj, mod_ujson_dumps);
    5555

    56+
    #define JSON_DEBUG(...) (void)0
    57+
    // #define JSON_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__)
    58+
    59+
    5660
    // The function below implements a simple non-recursive JSON parser.
    5761
    //
    5862
    // The JSON specification is at http://www.ietf.org/rfc/rfc4627.txt
    @@ -80,6 +84,7 @@ typedef struct _ujson_stream_t {
    8084

    8185
    STATIC byte ujson_stream_next(ujson_stream_t *s) {
    8286
    mp_uint_t ret = s->read(s->stream_obj, &s->cur, 1, &s->errcode);
    87+
    JSON_DEBUG(" usjon_stream_next err:%2d cur: %c \n", s->errcode, s->cur);
    8388
    if (s->errcode != 0) {
    8489
    mp_raise_OSError(s->errcode);
    8590
    }
    @@ -89,9 +94,10 @@ STATIC byte ujson_stream_next(ujson_stream_t *s) {
    8994
    return s->cur;
    9095
    }
    9196

    92-
    STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) {
    97+
    STATIC mp_obj_t _mod_ujson_load(mp_obj_t stream_obj, bool return_first_json) {
    9398
    const mp_stream_p_t *stream_p = mp_get_stream_raise(stream_obj, MP_STREAM_OP_READ);
    9499
    ujson_stream_t s = {stream_obj, stream_p->read, 0, 0};
    100+
    JSON_DEBUG("got JSON stream\n");
    95101
    vstr_t vstr;
    96102
    vstr_init(&vstr, 8);
    97103
    mp_obj_list_t stack; // we use a list as a simple stack for nested JSON
    @@ -262,13 +268,18 @@ STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) {
    262268
    }
    263269
    }
    264270
    success:
    265-
    // eat trailing whitespace
    266-
    while (unichar_isspace(S_CUR(s))) {
    267-
    S_NEXT(s);
    268-
    }
    269-
    if (!S_END(s)) {
    270-
    // unexpected chars
    271-
    goto fail;
    271+
    // It is legal for a stream to have contents after JSON.
    272+
    // E.g., A UART is not closed after receiving an object; in load() we will
    273+
    // return the first complete JSON object, while in loads() we will retain
    274+
    // strict adherence to the buffer's complete semantic.
    275+
    if (!return_first_json) {
    276+
    while (unichar_isspace(S_CUR(s))) {
    277+
    S_NEXT(s);
    278+
    }
    279+
    if (!S_END(s)) {
    280+
    // unexpected chars
    281+
    goto fail;
    282+
    }
    272283
    }
    273284
    if (stack_top == MP_OBJ_NULL || stack.len != 0) {
    274285
    // not exactly 1 object
    @@ -280,14 +291,18 @@ STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) {
    280291
    fail:
    281292
    mp_raise_ValueError(translate("syntax error in JSON"));
    282293
    }
    294+
    295+
    STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) {
    296+
    return _mod_ujson_load(stream_obj, true);
    297+
    }
    283298
    STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_load_obj, mod_ujson_load);
    284299

    285300
    STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
    286301
    size_t len;
    287302
    const char *buf = mp_obj_str_get_data(obj, &len);
    288303
    vstr_t vstr = {len, len, (char*)buf, true};
    289304
    mp_obj_stringio_t sio = {{&mp_type_stringio}, &vstr, 0, MP_OBJ_NULL};
    290-
    return mod_ujson_load(MP_OBJ_FROM_PTR(&sio));
    305+
    return _mod_ujson_load(MP_OBJ_FROM_PTR(&sio), false);
    291306
    }
    292307
    STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_loads_obj, mod_ujson_loads);
    293308

    0 commit comments

    Comments
     (0)
    0