narwhals-dev / narwhals

Lightweight and extensible compatibility layer between dataframe libraries!
https://narwhals-dev.github.io/narwhals/
MIT License
607 stars 90 forks source link

[Doc]: Avoid copying `>>>` and `...` from clipboard #1338

Closed FBruzzesi closed 1 week ago

FBruzzesi commented 1 week ago

What type of report is this?

Improvement

Please describe the issue.

"Copy to clipboard" button in code snippet will also copy >>> and ... characters, which to me is extremely annoying.

However, we need them to be able to run docstest.

I have been looking for how to enable both, yet my css/javascript is not strong enough.

Here some material:

If you have a suggestion on how it should be, add it below.

Maybe the best way is to check how other libraries achieve this 🙈

DeaMariaLeon commented 1 week ago

You may have noticed, but just in case: Using the "official mkdocstrings workaround" works on text. If you try to select the example by hovering+clicking with the mouse, not using the copy-to-clipboard button, you only select the correct text. So the easy option would be to not use (or hide) the copy-to-clipboard-button and add the workaround.

Maybe I'm just stating the obvious, but I can't help it.

FBruzzesi commented 1 week ago

Hey Dea thanks for the tip! No I didn't know it, that's probably a good first step then!

Yet I would still like to aim to have a setup similar to polars since in their docs you can manual copy and copy-to-clipboard avoid getting these characters, and keep those for doctest-ing.

DeaMariaLeon commented 1 week ago

Polars use Sphinx for the API part of the docs.

EdAbati commented 1 week ago

That's an example of how ruff does it: https://github.com/astral-sh/ruff/blob/main/docs/js/extra.js

(JS is not really my strength) 👀

DeaMariaLeon commented 1 week ago

It seems to work using ruff's setup. I can open the PR..

EdAbati commented 1 week ago

It was not closed automatically 👀

AlessandroMiola commented 1 week ago

It was not closed automatically 👀

Observed similar behaviour some days ago on another issue. Perhaps, we might add a comment in the PR template which suggests following the GH's suggested pattern Closes #ISSUE-NUMBER rather than the full URL, whose usage seems to not always guarantee triggering the automatism (https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) or perhaps it is just a useless addition 🤣

FBruzzesi commented 1 week ago

Would you say that the following change is enough?


- - Related issue # 
+ - Related issue #<issue number>
- - Closes #
+ - Closes #<issue number>
AlessandroMiola commented 1 week ago

Would you say that the following change is enough?

- - Related issue # 
+ - Related issue #<issue number>
- - Closes #
+ - Closes #<issue number>

Yes, for me this would make it clearer.