-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate the Python stubs automatically #1661
base: master
Are you sure you want to change the base?
Generate the Python stubs automatically #1661
Conversation
Except where class inheritance requires a different order.
And then in alphabetical order, if two enum constants have the same numeric value.
44284b9
to
c4766ec
Compare
The generated signature for |
I think |
Not quite finished yet, but it can generate a Plasma.py that's relatively close to what we currently have in the repo.
c4766ec
to
e76a5a8
Compare
Fixes CI errors because of the stub incorrectly indicating that these keyword arguments are required.
Type annotations are now supported by the stub generator. I've introduced a new I've also brought all of the C++-defined docstrings up-to-date with the manual changes and added type annotations in the stubs. This should resolve all of the spurious changes. This PR is basically finished now. I'll un-draft it once #1662 is merged and I've rebased this PR onto that (so that this PR's diff is more readable for reviewing). |
Closes #1660. Adds a script to automatically generate the Python "stub" files under Scripts/Python/plasma. The script must be run from the in-game Python console:
This will generate stubs for all Plasma built-in modules into a subfolder "plasma_stubs_generated" under the game folder.
Everything happens fully automatically using runtime introspection. Only one part is "semi-manual": because Python cannot introspect the signatures of C-defined functions, all function parameters must be specified manually in the C++-defined function docstrings, on a line starting with
Params:
. This convention was apparently used by Cyan originally, so most function docstrings already follow this format.The generator itself is almost completely finished, but this PR still needs a bit of work:
Params:
lines in the C++-defined docstrings.Returns:
.With those things in mind, early feedback is welcome. I'm particularly interested in the opinion of @Hoikas, who has recently hand-written some stubs that will be overwritten by this script.