Skip to content

Commit 4e8de3c

Browse files
committed
Swap sphinx to autoapi and the inline stubs
1 parent c534a87 commit 4e8de3c

File tree

139 files changed

+337
-1239
lines changed

Some content is hidden

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

139 files changed

+337
-1239
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 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
3838
- name: Versions
3939
run: |
4040
gcc --version

.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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ clean:
6969
rm -rf $(BUILDDIR)/*
7070
rm -rf $(STUBDIR) $(DISTDIR) *.egg-info
7171

72-
html:
72+
html: stubs
7373
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
7474
@echo
7575
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
@@ -213,8 +213,10 @@ check-translate: locale/circuitpython.pot $(wildcard locale/*.po)
213213
$(PYTHON) tools/check_translations.py $^
214214

215215
stubs:
216+
mkdir -p circuitpython-stubs
216217
python tools/extract_pyi.py shared-bindings/ $(STUBDIR)
217-
#python setup.py sdist
218+
python tools/extract_pyi.py ports/atmel-samd/bindings $(STUBDIR)
219+
python setup.py sdist
218220

219221
update-frozen-libraries:
220222
@echo "Updating all frozen libraries to latest tagged version."

conf.py

Lines changed: 11 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,17 @@
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 = ['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'
7279

7380
# The encoding of source files.
7481
#source_encoding = 'utf-8-sig'
@@ -78,7 +85,7 @@
7885

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

8390
# These are overwritten on ReadTheDocs.
8491
# The version info for the project you're documenting, acts as replacement for
@@ -105,6 +112,7 @@
105112
".git",
106113
".venv",
107114
".direnv",
115+
"docs/autoapi",
108116
"docs/README.md",
109117
"drivers",
110118
"examples",

docs/c2rst.py

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

ports/atmel-samd/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ Port Specific modules
2121
---------------------
2222

2323
.. toctree::
24-
bindings/samd/__init__
24+
../../autoapi/samd/index

ports/atmel-samd/bindings/samd/Clock.c

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,12 @@
3030
#include "py/objproperty.h"
3131
#include "py/runtime.h"
3232

33-
//| .. currentmodule:: samd
33+
//| import typing
34+
//| class Clock:
35+
//| """Identifies a clock on the microcontroller.
3436
//|
35-
//| :class:`Clock` --- Clock reference
36-
//| ------------------------------------------
37-
//|
38-
//| Identifies a clock on the microcontroller.
39-
//|
40-
//| .. class:: Clock
41-
//|
42-
//| Identifies a clock on the microcontroller. They are fixed by the
43-
//| hardware so they cannot be constructed on demand. Instead, use
44-
//| `samd.clock` to reference the desired clock.
37+
//| They are fixed by the hardware so they cannot be constructed on demand. Instead, use
38+
//| ``samd.clock`` to reference the desired clock."""
4539
//|
4640

4741
STATIC void samd_clock_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
@@ -50,9 +44,8 @@ STATIC void samd_clock_print(const mp_print_t *print, mp_obj_t self_in, mp_print
5044
mp_printf(print, "%q.%q.%q", MP_QSTR_samd, MP_QSTR_clock, self->name);
5145
}
5246

53-
//| .. attribute:: enabled
54-
//|
55-
//| Is the clock enabled? (read-only)
47+
//| enabled: bool = ...
48+
//| """Is the clock enabled? (read-only)"""
5649
//|
5750
STATIC mp_obj_t samd_clock_get_enabled(mp_obj_t self_in) {
5851
samd_clock_obj_t *self = MP_OBJ_TO_PTR(self_in);
@@ -69,9 +62,8 @@ const mp_obj_property_t samd_clock_enabled_obj = {
6962
},
7063
};
7164

72-
//| .. attribute:: parent
73-
//|
74-
//| Clock parent. (read-only)
65+
//| parent: typing.Union(Clock | None) = ...
66+
//| """Clock parent. (read-only)"""
7567
//|
7668
STATIC mp_obj_t samd_clock_get_parent(mp_obj_t self_in) {
7769
samd_clock_obj_t *self = MP_OBJ_TO_PTR(self_in);
@@ -98,9 +90,8 @@ const mp_obj_property_t samd_clock_parent_obj = {
9890
},
9991
};
10092

101-
//| .. attribute:: frequency
102-
//|
103-
//| Clock frequency. (read-only)
93+
//| frequency: int = ...
94+
//| """Clock frequency in Herz. (read-only)"""
10495
//|
10596
STATIC mp_obj_t samd_clock_get_frequency(mp_obj_t self_in) {
10697
samd_clock_obj_t *self = MP_OBJ_TO_PTR(self_in);
@@ -117,9 +108,8 @@ const mp_obj_property_t samd_clock_frequency_obj = {
117108
},
118109
};
119110

120-
//| .. attribute:: calibration
121-
//|
122-
//| Clock calibration. Not all clocks can be calibrated.
111+
//| calibration: int = ...
112+
//| """Clock calibration. Not all clocks can be calibrated."""
123113
//|
124114
STATIC mp_obj_t samd_clock_get_calibration(mp_obj_t self_in) {
125115
samd_clock_obj_t *self = MP_OBJ_TO_PTR(self_in);

ports/atmel-samd/bindings/samd/__init__.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,16 @@
3030

3131
#include "bindings/samd/Clock.h"
3232

33-
//| :mod:`samd` --- SAMD implementation settings
34-
//| =================================================
35-
//|
36-
//| .. module:: samd
37-
//| :synopsis: SAMD implementation settings
38-
//| :platform: SAMD21
39-
//|
40-
//| Libraries
41-
//|
42-
//| .. toctree::
43-
//| :maxdepth: 3
44-
//|
45-
//| Clock
46-
//|
33+
//| """SAMD implementation settings"""
4734

48-
//| :mod:`samd.clock` --- samd clock names
35+
//| """:mod:`samd.clock` --- samd clock names
4936
//| --------------------------------------------------------
5037
//|
5138
//| .. module:: samd.clock
5239
//| :synopsis: samd clock names
5340
//| :platform: SAMD21
5441
//|
55-
//| References to clocks as named by the microcontroller
42+
//| References to clocks as named by the microcontroller"""
5643
//|
5744
const mp_obj_module_t samd_clock_module = {
5845
.base = { &mp_type_module },

setup.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@
55
stub_root = Path("circuitpython-stubs")
66
stubs = [p.relative_to(stub_root).as_posix() for p in stub_root.glob("*.pyi")]
77

8-
now = datetime.utcnow()
9-
version = now.strftime("%Y.%m.%d")
10-
118
setup(
129
name="circuitpython-stubs",
1310
description="PEP 561 type stubs for CircuitPython",
1411
url="https://github.com/adafruit/circuitpython",
1512
maintainer="CircuitPythonistas",
1613
author_email="[email protected]",
17-
version=version,
14+
use_scm_version=True,
1815
license="MIT",
1916
package_data={"circuitpython-stubs": stubs},
2017
packages=["circuitpython-stubs"],
21-
setup_requires=["setuptools>=38.6.0"],
18+
setup_requires=["setuptools>=38.6.0",
19+
"setuptools_scm"],
2220
)

shared-bindings/_bleio/Adapter.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@
4848
#define WINDOW_DEFAULT (0.1f)
4949

5050
//| class Adapter:
51-
//| """.. currentmodule:: _bleio
52-
//|
53-
//| :class:`Adapter` --- BLE adapter
54-
//| ----------------------------------------------------
51+
//| """BLE adapter
5552
//|
5653
//| The Adapter manages the discovery and connection to other nearby Bluetooth Low Energy devices.
5754
//| This part of the Bluetooth Low Energy Specification is known as Generic Access Profile (GAP).

0 commit comments

Comments
 (0)