-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Docs: How To Pass Objects between JavaScript and PyScript #753
Docs: How To Pass Objects between JavaScript and PyScript #753
Conversation
for more information, see https://pre-commit.ci
Woow! |
Hi @JeffersGlass - you're correct, the basic documentation structure is that it will build in lockstep with tagged releases. The reason it fails here is because its trying to run from a fork but use repo credentials it doesn't have access to. It's interesting because I thought we had disabled it running from forks. All it's doing, really, is create draft docs to make sure it can build and format them correctly. After this PR is merged into main it will show up at docs.pyscript.net/latest and in the next versioned release under, for instance, docs.pyscript.net/2022.08.01. The docs CI is still a work in progress but the basic implementation is there. The CI files themselves can be founds in .github/workflows. Hopefully that all makes sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome!
Super great addition, very grateful @JeffersGlass :)
I just added one comment cause I was wondering if it'd make it simpler, if you disagree, you can simply ignore it and we merge it.
Cheers.
docs/howtos/passing-objects.md
Outdated
from js import console | ||
console.log(f"Hello {name}") | ||
console.log("Adding 1 and 2 in Javascript: " + str(addTwoNumbers(1, 2))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you should use print
here just so it's simpler for users?
print(f'Hello' {name})
...
I feel like introducing that you can just use std JS library now might be confusing for a few, is good to make it clear that we're writing Python.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me! This was mostly a hedge against needing to update the examples pending the changes to things like print
vs display
from #635, #749 etc. But you're right it would be clearer to keep this all in Python. And I imagine a lot of the documentation will need to get updated when that overhaul happens anyway.
Change is made.
Thank you @JeffersGlass, really great work :D |
Following a conversation with @marimeireles, adds a How-To document on passing objects between PyScript and JavaScript environments at runtime, based on this writeup.
This How Tois based on the PyScript as it exists at time of writing - including the Pyodide 21 API changes - and not the most recent stable release (2022.06.1). That way, it's accurate as of the next stable release. I know the documentation release process is still in the works - I imagine the document release cycle will track the pinned releases?