sphinx
sphinx copied to clipboard
Double click on function parameter selects parameter type as well
Describe the bug
This issue was initially opened by @rok here: https://github.com/pydata/pydata-sphinx-theme/issues/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 (https://github.com/numpy/numpydoc/issues/427#issuecomment-1242515604).
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