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

Double click on function parameter selects parameter type as well #10815

Open
12rambau opened this issue Sep 11, 2022 · 3 comments
Open

Double click on function parameter selects parameter type as well #10815

12rambau opened this issue Sep 11, 2022 · 3 comments
Labels
Milestone

Comments

@12rambau
Copy link

12rambau commented Sep 11, 2022

Describe the bug

This issue was initially opened by @rok here: pydata/pydata-sphinx-theme#388.

When I want to copy a name of a function parameter I typically double-click it to select. Normally that would select the entire parameter and I can now copy and paste it elsewhere.
Here however there seems to be a css or js setting that causes the double click to select the parameter type as well. When I copy it the name of parameter is concatenated to type string without space in between. E.g. double clicking and copy-pasting parameter data from here will result in a string datastructured. Ideally it would result only in data.

After some digging and some help from SO, I think I identified the issue. The problem comes from the structure of the dt line. if everything is written without spaces and without line break it behave as described in the issue:

<dt>
  <strong>data</strong><span class="classifier">structured ndarray, sequence of tuples or dicts, or DataFrame</span>
</dt>

if on the other hand you add an extra space you are good to go

<dt>
  <strong>data</strong> <span class="classifier">structured ndarray, sequence of tuples or dicts, or DataFrame</span>
</dt>

PS: see this copen to have a demo of the different behaviours: https://codepen.io/12rambau/pen/mdXQayr

I thought it was coming from numpydo but apprently is fuly relying on the sphinx HTMLbuilder to create the html output (numpy/numpydoc#427 (comment)).

If you can point me to where this html is generated, I would be happy to make a PR

How to Reproduce

create a documentation and add a documentation build the following file:

Convert structured or record ndarray to DataFrame.

Creates a DataFrame object from a structured ndarray, sequence of
tuples or dicts, or DataFrame.

:Parameters:

    **data** : structured ndarray, sequence of tuples or dicts, or DataFrame
        Structured input data.

    **index** : str, list of fields, array-like
        Field of array to use as the index, alternately a specific set of
        input labels to use.

    **exclude** : sequence, default None
        Columns or fields to exclude.

    **columns** : sequence, default None
        Column names to use. If the passed data do not have names
        associated with them, this argument provides names for the
        columns. Otherwise this argument indicates the order of the columns
        in the result (any names not found in the data will become all-NA
        columns).

    **coerce_float** : bool, default False
        Attempt to convert values of non-string, non-numeric objects (like
        decimal.Decimal) to floating point, useful for SQL result sets.

    **nrows** : int, default None
        Number of rows to read if data is an iterator.

Expected behavior

As mentioned in the issue, I would like to only select the name and not the other word

Your project

https://github.com/pandas-dev/pandas

Screenshots

No response

OS

Any

Python version

3.7-3.10

Sphinx version

Any

@AA-Turner AA-Turner added this to the some future version milestone Sep 29, 2022
@12rambau
Copy link
Author

I found a CSS solution in pydata/pydata-sphinx-theme#1015. The theme is dependent on the basic.css from Sphinx. Should I port it here or should it remain a theme problem ?

@AA-Turner
Copy link
Member

A fix in basic.css is welcome

A

@flying-sheep
Copy link
Contributor

flying-sheep commented Jul 4, 2023

Why in CSS? The problem seems to be that

nodes.definition_list_item('', [
  nodes.term('', 'data', nodes.classifier('', 'structured')),
  nodes.definition('', 'Structured'),
])

gets converted into

<dt>
  <strong>data</strong><span class="classifier">structured</span>
</dt>
<dd>Structured</dd>

instead of

<dt>
  <strong>data</strong> <span class="classifier">structured</span>
</dt>
<dd>Structured</dd>

This seems to be a HTML rendering problem and not a CSS problem.

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

No branches or pull requests

3 participants