Skip to content
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

Question, how do you generate and test the Python examples in the README? #17309

Open
shner-elmo opened this issue Jun 30, 2024 · 2 comments
Open
Labels
documentation Improvements or additions to documentation

Comments

@shner-elmo
Copy link

Description

Hey, this is not an issue, just a question. Was wondering how you generate the examples in the README, and if (and how) you test them in the CI? (I imagine you need to manually parse the >>> and ... )
I would appreciate if you could point me to the code that handles this, thanks.

(like this for example)

Link

https://github.com/pola-rs/polars?tab=readme-ov-file#python

@shner-elmo shner-elmo added the documentation Improvements or additions to documentation label Jun 30, 2024
@mcrumiller
Copy link
Contributor

mcrumiller commented Jun 30, 2024

Good point, that should be fixed. I'll explain why it looks like that though. If you enter a multi-line command into the python prompt, that's what you see:

image

In the codebase, the function docstrings show these extra characters so as to mimic would it looks like running in terminal, but the html renders such that those characters aren't actually copied. See the example in keep_name: if you copy the code, only the relevant code portions are selectable:

image

It was probably intended to have the UI work this same way too, but it currently doesn't in the README.

@shner-elmo
Copy link
Author

So if I understand correctly, the examples in the README are written by hand and are not tested in the CI as of yet.

But I wonder how you can change the CSS of the text that matches a pattern, like ^(?:\.\.\.|>>>) (.*)$ to modify those characters to be non-selectable? not sure if its possible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants