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
Unify width and height related docstrings #8441
Conversation
Desired width of the dataframe expressed in pixels. If None (default), | ||
selects the width automatically. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Desired width of the dataframe expressed in pixels. If None (default), | |
selects the width automatically. | |
Desired width of the dataframe expressed in pixels. If ``width`` is | |
``None`` (default), Streamlit selects the width automatically. |
Or possibly:
Desired width of the dataframe expressed in pixels. If None (default), | |
selects the width automatically. | |
Desired width of the dataframe expressed in pixels. If ``width`` is | |
``None`` (default), Streamlit sets the dataframe width to fit its | |
contents up to the width of the parent container. If ``width`` is | |
greater than the width of the parent container, Streamlit sets the | |
dataframe width to match the width of the parent container. |
One thing I've been grappling with recently is standardizing the grammar within docstrings. We have a mix of fragments and complete sentences and I want to consciously draw a line for when we use each. I've been kicking around the idea that we let the first "sentence" be a noun phrase, stated as a definition, but then switch to complete sentences thereafter if we're going to describe behavior or cases.
I'm a little hesitant that that might be too extreme and get too wordy when applied broadly, so I'm curious about other opinions here. (As an aside, I also want to make sure Python objects are formatted as code. This isn't consistent everywhere yet, but I'm inclined to use None
in code format.)
When I poke around other libraries, I don't see a lot of consistency elsewhere. Our parameter descriptions tend to be comparatively more complex with a lot more switching behavior, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also need to have a separate discussion about "dataframe" vs "DataFrame" since pandas, Arrow, and Spark all use the capitalized form. It'd be nice to have an uncapitalized, generic version (and we mostly do in the docs), but I've had a hard time finding anyone else doing that in any official documentation. Maybe we can just choose to lead the charge. 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding: I think there was some discussion some time ago related to dataframe vs DataFrame. I believe the outcome was that we only use DataFrame if we are referring to a specific implementation of a dataframe, e.g. Pandas DataFrame, Snowpark DataFrame. But if we are talking about this topic more high-level or if we are talking about the actual table UI we are using lowercased dataframe version. But not sure if we ever made a decision on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggested docstring sounds good to me 👍 and it would be awesome to have this kind of general guidelines on how we write / structure docstrings
Desired height of the dataframe expressed in pixels. If None, a | ||
default height is used. | ||
Desired height of the dataframe expressed in pixels. If None (default), | ||
selects the height automatically. | ||
|
||
use_container_width : bool | ||
If True, set the dataframe width to the width of the parent container. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If True, set the dataframe width to the width of the parent container. | |
Whether to override ``width`` with the width of the parent container. | |
The default is ``False``. If ``use_contatiner_width`` is ``True``, | |
Streamlit sets the width of the dataframe to match the width of the | |
parent container. |
or possibly:
If True, set the dataframe width to the width of the parent container. | |
Whether to override ``width`` with the width of the parent container. | |
The default is ``False``. If ``use_contatiner_width`` is ``True``, | |
Streamlit ignores ``width`` and sets the width of the dataframe to | |
match the width of the parent container. |
To follow through with my above comment, this argument could be something like this. (It didn't explicitly state its default before.) Note that the comment isn't letting me include next line. I'm proposing the "overrides" language in place of "takes precedence." GitHub wouldn't let me include line 94 in the comment. :)
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'll get the edits added per our conversation. |
@sfc-gh-dmatthews Sounds good; sorry that I didn't get to this ... I'm fully focused on wrapping up selections for the 1.35 release. |
No worries. I had intended to update the PR and just got busy on the rest of 1.34.0 and hadn't circled back yet. |
width=width or 0, | ||
height=height or 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LukasMasuch I'm copying these edits into my PR, but I'm not sure what this line is and I'm a little less confident copying into where I think it goes. I found the built_in_chart_utils.py file and I updated the parts in def _generate_chart
to have int | None = None
. What is this part exactly that previously assigned an int and is not assigning a bool?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could either use the width or 0
whenever generate_chart
is called in vega_charts.py
, or allow None
in generate_chart
for width and height and add this into the top of generate_chart
function:
width = width or 0
height = height or 0
this basically says that its guaranteed to be a number or 0
## Describe your changes Docstring updates for release 1.35.0. * New selection feature added for `st.dataframe`, `st.plotly_chart`, `st.altair_chart`, and `st.vega_lite_chart`. * New event and selection states (dictionary schemas) * New function: `st.logo` * Additional docstring edits for other chart functions for consistency. This PR copies docstring edits from #8441. In particular, there is a small change in parameter types for width and height (previously `int` with an initial value of 0, and now `int | None = None`. This is the one thing outside of docstrings. ## GitHub Issue Link (if applicable) ## Testing Plan None. --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
## Describe your changes Docstring updates for release 1.35.0. * New selection feature added for `st.dataframe`, `st.plotly_chart`, `st.altair_chart`, and `st.vega_lite_chart`. * New event and selection states (dictionary schemas) * New function: `st.logo` * Additional docstring edits for other chart functions for consistency. This PR copies docstring edits from #8441. In particular, there is a small change in parameter types for width and height (previously `int` with an initial value of 0, and now `int | None = None`. This is the one thing outside of docstrings. ## GitHub Issue Link (if applicable) ## Testing Plan None. --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
Closing this PR since the edits were copied into the docstrings for 1.35.0. |
Describe your changes
This PR unifies the docstrings of the
width
,height
anduse_container_width
parameters across our commands.Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.