Skip to content

ENH Adding a column to link each parameter docstring row in params table display #31564

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

Open
wants to merge 85 commits into
base: main
Choose a base branch
from

Conversation

DeaMariaLeon
Copy link
Contributor

@DeaMariaLeon DeaMariaLeon commented Jun 17, 2025

Reference Issues/PRs

Adds a column with a link to each parameter docstring in the params table (in the HTML display).
This was discussed while working on the PR that added the table.

"Text fragments" code shared by @ogrisel here :
#30763 (comment)

What does this implement/fix? Explain your changes.

Added a column to the table with the new link
Modified ParamsDict to include the estimator_type. After several tries it was the only way I found at the moment.

Any other comments?

@glemaitre

Screenshot 2025-06-18 at 11 47 55

Copy link

github-actions bot commented Jun 17, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: c84354f. Link to the linter CI: here

@glemaitre glemaitre self-requested a review June 17, 2025 21:20
@DeaMariaLeon
Copy link
Contributor Author

DeaMariaLeon commented Jun 18, 2025

Example here

TODO:

  1. Address Olivier's comment (during a call). He mentioned that the ReprHTMLMixin could be set-up in a way that we only add documentation link of estimators that have similar HTML structure.
  2. Test for broken links
  3. The "?" link is too small, but it's the same size of the text. latest doc built - It seems that having the same text for each hyperlink is different than the recommended "best practices".

@DeaMariaLeon DeaMariaLeon marked this pull request as ready for review June 20, 2025 12:25
@DeaMariaLeon DeaMariaLeon changed the title WIP: ENH Adding a column to link each parameter docstring row in params table display ENH Adding a column to link each parameter docstring row in params table display Jun 20, 2025
@@ -23,6 +76,31 @@ def _read_params(name, value, non_default_params):
return {"param_type": param_type, "param_name": name, "param_value": cleaned_value}

Copy link
Contributor Author

@DeaMariaLeon DeaMariaLeon Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that r.maxstringis not working.
Noticed while working on adding methods table.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe open a dedicated issue with a reproducer?

Copy link
Member

@jeremiedbb jeremiedbb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @DeaMariaLeon.

I tested on the example you linked and it worked fine except for the C parameter of LogisticRegression. Maybe the text fragment requires more than 1 character ?

Besides that, here are some comments

@DeaMariaLeon
Copy link
Contributor Author

tested on the example you linked and it worked fine except for the C parameter of LogisticRegression. Maybe the text fragment requires more than 1 character ?

Thanks for the feedback! - the link to C that you mention works for me locally. But the link to my example doesn't work (the whole example, not the parameter link). Maybe on the next doc build I can see it.. ?
I addressed some of the comments you left. I'll work on the rest.

@DeaMariaLeon
Copy link
Contributor Author

Docs build failure unrelated. See #31918 (comment)

@DeaMariaLeon
Copy link
Contributor Author

I would like to know if I should implement:

If we go for the tooltip, then I don't think that a link for each parameter is needed anymore. The link for the estimator is enough then. And the tooltip could be displayed on hovering over the param name cell.

Up to now, it looks like below. Example here

Screenshot 2025-08-19 at 09 49 10

@DeaMariaLeon
Copy link
Contributor Author

DeaMariaLeon commented Aug 20, 2025

After changes requested by Guillaume
example
Screenshot 2025-08-20 at 13 38 39

@glemaitre
Copy link
Member

I think that we need to keep the <br> because with bullet point list, we are going to join each line which is not a nice rendering.

Since we are writing a 88 characters length line, I think that we should be OK with the length of the original docstring.

It could be nice to interpret the RST to HTML but it would require additional dependencies and it will be rather annoying.

@DeaMariaLeon
Copy link
Contributor Author

So, Guillaume's previous comment overrides Olivier's comment here. I added back the <br>

@DeaMariaLeon
Copy link
Contributor Author

There is now a scroll inside the tooltip (not obvious in the screen-shoot).
I fixed a bunch of issues with the latests changes, so I'm waiting for feedback before working again on the tests.

Screenshot 2025-08-21 at 10 36 28

@jeremiedbb
Copy link
Member

I like what I see in the screen shot. Do you mind pushing a new commit with a doc build to try it out live (@glemaitre cancelled it by sync'ing with main) ?

@glemaitre
Copy link
Member

The documentation build is available @jeremiedbb

@jeremiedbb
Copy link
Member

I find this new iteration really nice and better than the previous ? cell. I'm not sure that linking to the full doc page is necessary then but why not if you want to have the rst properly rendered.

One thing that is not very easy is to enable the focus to be able to scroll within the tooltip (I have a laptop with a mouse pad). When I hover on a param name, the tooltip appears and then if I move my cursor to enter the tooltip and scroll, it just displays the tooltip of the next param instead. I have to hover and move quickly to be able to enter the tooltip with my cursor.

I noticed that the scroll bar doesn't appear when the tooltip pops up on hovering the param name. It appears only when I managed to make my cursor enter the tooltip. I believe that if it appeared right away I might be able to scroll without having to move the cursor inside the tooltip, not sure though.

@glemaitre
Copy link
Member

One thing that is not very easy is to enable the focus to be able to scroll within the tooltip (I have a laptop with a mouse pad).

Yep it is a bug. We need to figure out the right way to do so.

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

Successfully merging this pull request may close these issues.

4 participants