Skip to content

Commit

Permalink
feat: stubs and docstrings for python binding
Browse files Browse the repository at this point in the history
  • Loading branch information
patrislav1 committed Nov 29, 2024
1 parent 0574204 commit 70237af
Show file tree
Hide file tree
Showing 8 changed files with 1,246 additions and 472 deletions.
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,24 @@ pip3 install --use-feature=in-tree-build -e .
To update the `.pyi` stubs after changing the binding:

```bash
cd pyudmaio
python3 -m pybind11_stubgen pyudmaio --no-setup-py -o /tmp \
&& cp -a /tmp/pyudmaio-stubs/* pyudmaio
# (re-)generate docstrings
python3 -m pybind11_mkdoc -I ./inc -o pyudmaio/src/docstrings.hpp \
inc/udmaio/UioConfig.hpp \
inc/udmaio/UioIf.hpp \
inc/udmaio/DmaBufferAbstract.hpp \
inc/udmaio/FpgaMemBufferOverAxi.hpp \
inc/udmaio/FpgaMemBufferOverXdma.hpp \
inc/udmaio/UDmaBuf.hpp \
inc/udmaio/UioAxiDmaIf.hpp \
inc/udmaio/UioMemSgdma.hpp \
pyudmaio/src/DataHandlerPython.hpp \
inc/udmaio/FrameFormat.hpp

# build & install binding
pip3 install ./pyudmaio

# update stubs
python3 -m pybind11_stubgen pyudmaio -o pyudmaio
```

## Usage example
Expand Down
23 changes: 23 additions & 0 deletions pyudmaio/pyudmaio/_UioReg.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from __future__ import annotations
import bitstruct as bitstruct
__all__ = ['UioReg', 'UioRegTest', 'bitstruct']
class UioReg:
def __getattr__(self, name):
...
def __init__(self, intf, offs, fields = None):
...
def __setattr__(self, name, value):
...
def rd(self):
...
def wr(self, val = None):
...
class UioRegTest:
def __init__(self):
...
def _rd32(self, offs):
...
def _wr32(self, offs, val):
...
def test(self):
...
16 changes: 0 additions & 16 deletions pyudmaio/pyudmaio/_UioReg/__init__.pyi

This file was deleted.

31 changes: 6 additions & 25 deletions pyudmaio/pyudmaio/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import annotations
import pyudmaio
import typing
from pyudmaio._UioReg import UioReg
from pyudmaio.binding import ConfigUio
from pyudmaio.binding import ConfigXdma
from pyudmaio.binding import DataHandler
from pyudmaio.binding import FpgaMemBufferOverAxi
from pyudmaio.binding import FpgaMemBufferOverXdma
from pyudmaio.binding import FrameFormat
from pyudmaio.binding import LogLevel
Expand All @@ -12,27 +12,8 @@ from pyudmaio.binding import UioAxiDmaIf
from pyudmaio.binding import UioDeviceLocation
from pyudmaio.binding import UioIf
from pyudmaio.binding import UioMemSgdma
from pyudmaio._UioReg import UioReg
from pyudmaio.binding import UioRegion

__all__ = [
"ConfigUio",
"ConfigXdma",
"DataHandler",
"FpgaMemBufferOverXdma",
"FrameFormat",
"LogLevel",
"UDmaBuf",
"UioAxiDmaIf",
"UioDeviceLocation",
"UioIf",
"UioMemSgdma",
"UioReg",
"UioRegion",
"binding",
"set_logging_level"
]


def set_logging_level(arg0: binding.LogLevel) -> None:
pass
from pyudmaio.binding import set_logging_level
from . import _UioReg
from . import binding
__all__ = ['ConfigUio', 'ConfigXdma', 'DataHandler', 'FpgaMemBufferOverAxi', 'FpgaMemBufferOverXdma', 'FrameFormat', 'LogLevel', 'UDmaBuf', 'UioAxiDmaIf', 'UioDeviceLocation', 'UioIf', 'UioMemSgdma', 'UioReg', 'UioRegion', 'binding', 'set_logging_level']
Loading

0 comments on commit 70237af

Please sign in to comment.