Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/whats_new/upcoming_changes/sklearn.utils/32887.fix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- The parameter table in the HTML representation of all scikit-learn
estimators inheritiging from :class:`base.BaseEstimator`, displays
each parameter documentation as a tooltip. The last tooltip of a
parameter in the last table of any HTML representation was partially hidden.
This issue has been fixed.
By :user:`Dea María Léon <DeaMariaLeon>`
16 changes: 16 additions & 0 deletions sklearn/utils/_repr_html/params.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ a.param-doc-link:visited {
padding: .5em;
}

@supports(anchor-name: --doc-link) {
a.param-doc-link,
a.param-doc-link:link,
a.param-doc-link:visited {
anchor-name: --doc-link;
}
}

/* "hack" to make the entire area of the cell containing the link clickable */
a.param-doc-link::before {
position: absolute;
Expand All @@ -109,6 +117,14 @@ a.param-doc-link::before {
border: thin solid var(--sklearn-color-unfitted-level-3);
}

@supports(position-area: center right) {
.param-doc-description {
position-area: center right;
position: fixed;
margin-left: 0;
}
}

/* Fitted state for parameter tooltips */
.fitted .param-doc-description {
/* fitted */
Expand Down
5 changes: 4 additions & 1 deletion sklearn/utils/_repr_html/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@ def _params_html_repr(params):

PARAM_AVAILABLE_DOC_LINK_TEMPLATE = """
<a class="param-doc-link"
style="anchor-name: --doc-link-{param_name};"
rel="noreferrer" target="_blank" href="{link}">
{param_name}
<span class="param-doc-description">{param_description}</span>
<span class="param-doc-description"
style="position-anchor: --doc-link-{param_name};">
{param_description}</span>
</a>
"""
estimator_class_docs = inspect.getdoc(params.estimator_class)
Expand Down
10 changes: 8 additions & 2 deletions sklearn/utils/_repr_html/tests/test_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,13 @@ class MockEstimator:
html_param_a = (
r'<td class="param">'
r'\s*<a class="param-doc-link"'
r'\s*style="anchor-name: --doc-link-a;"'
r'\s*rel="noreferrer" target="_blank"'
r'\shref="mock_module\.MockEstimator\.html#:~:text=a,-int">'
r"\s*a"
r'\s*<span class="param-doc-description">a: int<br><br>'
r'\s*<span class="param-doc-description"'
r'\s*style="position-anchor: --doc-link-a;">\s*a:'
r"\sint<br><br>"
r"Description of a\.</span>"
r"\s*</a>"
r"\s*</td>"
Expand All @@ -120,10 +123,13 @@ class MockEstimator:
html_param_b = (
r'<td class="param">'
r'.*<a class="param-doc-link"'
r'\s*style="anchor-name: --doc-link-b;"'
r'\s*rel="noreferrer" target="_blank"'
r'\shref="mock_module\.MockEstimator\.html#:~:text=b,-str">'
r"\s*b"
r'\s*<span class="param-doc-description">b: str<br><br></span>'
r'\s*<span class="param-doc-description"'
r'\s*style="position-anchor: --doc-link-b;">\s*b:'
r"\sstr<br><br></span>"
r"\s*</a>"
r"\s*</td>"
)
Expand Down
Loading