Skip to content

Commit fa3ff1e

Browse files
committed
Add example for Py2StubTransformer
1 parent 4d301ff commit fa3ff1e

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/docstub/_stubs.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,16 @@ class Py2StubTransformer(cst.CSTTransformer):
298298
References
299299
----------
300300
.. [1] Stub file specification https://typing.readthedocs.io/en/latest/spec/distributing.html#stub-files
301+
302+
Examples
303+
--------
304+
>>> from docstub._stubs import Py2StubTransformer
305+
>>> transformer = Py2StubTransformer()
306+
>>> source = 'def print_upper(x): print(x.upper())'
307+
>>> stub = transformer.python_to_stub(source)
308+
>>> print(stub)
309+
from _typeshed import Incomplete
310+
def print_upper(x: Incomplete) -> None: ...
301311
"""
302312

303313
METADATA_DEPENDENCIES: ClassVar[tuple] = (cst.metadata.PositionProvider,)

0 commit comments

Comments
 (0)