Skip to content

Commit 70237af

Browse files
committed
feat: stubs and docstrings for python binding
1 parent 0574204 commit 70237af

File tree

8 files changed

+1246
-472
lines changed

8 files changed

+1246
-472
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,24 @@ pip3 install --use-feature=in-tree-build -e .
8080
To update the `.pyi` stubs after changing the binding:
8181

8282
```bash
83-
cd pyudmaio
84-
python3 -m pybind11_stubgen pyudmaio --no-setup-py -o /tmp \
85-
&& cp -a /tmp/pyudmaio-stubs/* pyudmaio
83+
# (re-)generate docstrings
84+
python3 -m pybind11_mkdoc -I ./inc -o pyudmaio/src/docstrings.hpp \
85+
inc/udmaio/UioConfig.hpp \
86+
inc/udmaio/UioIf.hpp \
87+
inc/udmaio/DmaBufferAbstract.hpp \
88+
inc/udmaio/FpgaMemBufferOverAxi.hpp \
89+
inc/udmaio/FpgaMemBufferOverXdma.hpp \
90+
inc/udmaio/UDmaBuf.hpp \
91+
inc/udmaio/UioAxiDmaIf.hpp \
92+
inc/udmaio/UioMemSgdma.hpp \
93+
pyudmaio/src/DataHandlerPython.hpp \
94+
inc/udmaio/FrameFormat.hpp
95+
96+
# build & install binding
97+
pip3 install ./pyudmaio
98+
99+
# update stubs
100+
python3 -m pybind11_stubgen pyudmaio -o pyudmaio
86101
```
87102

88103
## Usage example

pyudmaio/pyudmaio/_UioReg.pyi

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from __future__ import annotations
2+
import bitstruct as bitstruct
3+
__all__ = ['UioReg', 'UioRegTest', 'bitstruct']
4+
class UioReg:
5+
def __getattr__(self, name):
6+
...
7+
def __init__(self, intf, offs, fields = None):
8+
...
9+
def __setattr__(self, name, value):
10+
...
11+
def rd(self):
12+
...
13+
def wr(self, val = None):
14+
...
15+
class UioRegTest:
16+
def __init__(self):
17+
...
18+
def _rd32(self, offs):
19+
...
20+
def _wr32(self, offs, val):
21+
...
22+
def test(self):
23+
...

pyudmaio/pyudmaio/_UioReg/__init__.pyi

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

pyudmaio/pyudmaio/__init__.pyi

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from __future__ import annotations
2-
import pyudmaio
3-
import typing
2+
from pyudmaio._UioReg import UioReg
43
from pyudmaio.binding import ConfigUio
54
from pyudmaio.binding import ConfigXdma
65
from pyudmaio.binding import DataHandler
6+
from pyudmaio.binding import FpgaMemBufferOverAxi
77
from pyudmaio.binding import FpgaMemBufferOverXdma
88
from pyudmaio.binding import FrameFormat
99
from pyudmaio.binding import LogLevel
@@ -12,27 +12,8 @@ from pyudmaio.binding import UioAxiDmaIf
1212
from pyudmaio.binding import UioDeviceLocation
1313
from pyudmaio.binding import UioIf
1414
from pyudmaio.binding import UioMemSgdma
15-
from pyudmaio._UioReg import UioReg
1615
from pyudmaio.binding import UioRegion
17-
18-
__all__ = [
19-
"ConfigUio",
20-
"ConfigXdma",
21-
"DataHandler",
22-
"FpgaMemBufferOverXdma",
23-
"FrameFormat",
24-
"LogLevel",
25-
"UDmaBuf",
26-
"UioAxiDmaIf",
27-
"UioDeviceLocation",
28-
"UioIf",
29-
"UioMemSgdma",
30-
"UioReg",
31-
"UioRegion",
32-
"binding",
33-
"set_logging_level"
34-
]
35-
36-
37-
def set_logging_level(arg0: binding.LogLevel) -> None:
38-
pass
16+
from pyudmaio.binding import set_logging_level
17+
from . import _UioReg
18+
from . import binding
19+
__all__ = ['ConfigUio', 'ConfigXdma', 'DataHandler', 'FpgaMemBufferOverAxi', 'FpgaMemBufferOverXdma', 'FrameFormat', 'LogLevel', 'UDmaBuf', 'UioAxiDmaIf', 'UioDeviceLocation', 'UioIf', 'UioMemSgdma', 'UioReg', 'UioRegion', 'binding', 'set_logging_level']

0 commit comments

Comments
 (0)