Skip to content

Commit

Permalink
first pass at generating pyi stubs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Muream committed May 25, 2021
1 parent 5b9c56a commit d57e221
Show file tree
Hide file tree
Showing 13 changed files with 1,220 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*.dist-info
*.pyd
*.py[id]
build/**
tmp/*
*.pyc
*.pyc
17 changes: 17 additions & 0 deletions scripts/generate_typing_stubs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Generate stubs for cmdc
For the script to run it needs the following:
1. `pybind11-stubgen` has been installed in mayapy.
`mayapy -m pip install pybind11-stubgen`
2. All the generated Types and functions to be declared
before any of them are implemented. Or at least before being used as type arguments
3. cmdc to be in the PYTHONPATH
"""
import pybind11_stubgen

module = pybind11_stubgen.ModuleStubsGenerator("cmdc")

module.parse() # this throws a bunch of warning and then freezes after some point.

with open("build/cmdc.pyi", "w") as handle:
handle.write("\n".join(module.to_lines()))
23 changes: 23 additions & 0 deletions src/ForwardDeclarations.inl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
py::class_<MAngle> Angle(m, "Angle");
py::class_<MDAGDrawOverrideInfo> DAGDrawOverrideInfo(m, "DAGDrawOverrideInfo");
py::class_<MDagPath> DagPath(m, "DagPath");
py::class_<MDataBlock> DataBlock(m, "DataBlock");
py::class_<MDataHandle> DataHandle(m, "DataHandle");
py::class_<MDistance> Distance(m, "Distance");
py::class_<MFn> Fn(m, "Fn");
py::class_<MFnDependencyNode> FnDependencyNode(m, "FnDependencyNode");
py::class_<MMatrix> Matrix(m, "Matrix");
py::class_<MObject> Object(m, "Object");
py::class_<MObjectHandle> ObjectHandle(m, "ObjectHandle");
py::class_<MPlug> plug(m, "Plug");
py::class_<MPoint> Point(m, "Point");
py::class_<MPxData> PxData(m, "PxData");
py::class_<MQuaternion> Quaternion(m, "Quaternion");
py::class_<MSelectionList> SelectionList(m, "SelectionList");
py::class_<MStatus> Status(m, "Status");
py::class_<MString> String(m, "String");
py::class_<MTime> Time(m, "Time");
py::class_<MTypeId> TypeId(m, "TypeId");
py::class_<MVector> Vector(m, "Vector");
py::enum_<MFn::Type> fn_type(Fn, "Type");
py::class_<MUuid> Uuid(m, "Uuid");
2 changes: 1 addition & 1 deletion src/MDagPath.inl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
py::class_<MDagPath>(m, "DagPath")
DagPath
.def(py::init<>())

.def(py::self == MDagPath())
Expand Down
Loading

0 comments on commit d57e221

Please sign in to comment.