Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

docs: update docstrings to Google Style format (#3218)

devin-ai-integration[bot]f339884f45cb
diff --git a/marimo/_plugins/stateless/flex.py b/marimo/_plugins/stateless/flex.py
index 45cc38db38..7c994c279e 100644
--- a/marimo/_plugins/stateless/flex.py
+++ b/marimo/_plugins/stateless/flex.py
@@ -101,17 +101,17 @@ def vstack(
Args:
items (Sequence[object]): A list of items.
- align (Literal["start", "end", "center", "stretch"], optional): Align items
+ align (Optional[Literal["start", "end", "center", "stretch"]]): Align items
horizontally: start, end, center, or stretch.
justify (Literal["start", "center", "end", "space-between", "space-around"]):
Justify items vertically: start, center, end, space-between, or space-around.
Defaults to "start".
- gap (float, optional): Gap between items as a float in rem. 1rem is 16px by default.
+ gap (float): Gap between items as a float in rem. 1rem is 16px by default.
Defaults to 0.5.
- heights (Union[Literal["equal"], Sequence[float]], optional): "equal" to give items
+ heights (Optional[Literal["equal"] | Sequence[float]]): "equal" to give items
equal height; or a list of relative heights with same length as `items`,
- eg, [1, 2] means the second item is twice as tall as the first;
- or None for a sensible default.
+ eg, [1, 2] means the second item is twice as tall as the first; or None
+ for a sensible default.
Returns:
Html: An Html object.
@@ -168,15 +168,15 @@ def hstack(
justify (Literal["start", "center", "end", "space-between", "space-around"]):
Justify items horizontally: start, center, end, space-between, or space-around.
Defaults to "space-between".
- align (Literal["start", "end", "center", "stretch"], optional): Align items
+ align (Optional[Literal["start", "end", "center", "stretch"]]): Align items
vertically: start, end, center, or stretch.
- wrap (bool, optional): Wrap items or not. Defaults to False.
- gap (float, optional): Gap between items as a float in rem. 1rem is 16px by default.
+ wrap (bool): Wrap items or not. Defaults to False.
+ gap (float): Gap between items as a float in rem. 1rem is 16px by default.
Defaults to 0.5.
- widths (Union[Literal["equal"], Sequence[float]], optional): "equal" to give items
+ widths (Optional[Literal["equal"] | Sequence[float]]): "equal" to give items
equal width; or a list of relative widths with same length as `items`,
- eg, [1, 2] means the second item is twice as wide as the first;
- or None for a sensible default.
+ eg, [1, 2] means the second item is twice as wide as the first; or None
+ for a sensible default.
Returns:
Html: An Html object.
@@ -208,17 +208,16 @@ def _spaced(
A grid built with this function has a fixed number of items per row.
For more flexibility, use `hstack` and `vstack`.
- **Args.**
-
- - `items`: Items to arrange
- - `justify`: Justify items normally, left, right, or center.
- - `items_per_row`: Number of items to place in each row
- - `column_gap`: Minimum gap in rem between columns
- - `row_gap`: Minimum gap in rem between rows
-
- **Returns.**
+ Args:
+ items (Sequence[object]): Items to arrange
+ justify (Literal["left", "right", "center", "normal"]): Justify items normally,
+ left, right, or center.
+ items_per_row (Optional[int]): Number of items to place in each row
+ column_gap (float): Minimum gap in rem between columns
+ row_gap (float): Minimum gap in rem between rows
- - An `Html` object.
+ Returns:
+ Html: An `Html` object.
"""
items_per_row = len(items) if items_per_row is None else items_per_row
style = create_style(
diff --git a/marimo/_plugins/stateless/icon.py b/marimo/_plugins/stateless/icon.py
index 1406fb854b..17e566924f 100644
--- a/marimo/_plugins/stateless/icon.py
+++ b/marimo/_plugins/stateless/icon.py
@@ -22,8 +22,7 @@ def icon(
rotate: Optional[Literal["90deg", "180deg", "270deg"]] = None,
style: Optional[dict[str, Union[str, int, float, None]]] = None,
) -> Html:
- """
- Displays an icon. These icons are referenced by name from the
+ """Displays an icon. These icons are referenced by name from the
[Iconify](https://iconify.design/) library.
They are named in the format `icon-set:icon-name`, e.g.
@@ -34,29 +33,26 @@ def icon(
These can be used in buttons, tabs, and other UI elements.
- **Examples.**
-
- ```python
- mo.md(f"# {mo.icon('lucide:leaf')} Leaf")
-
- mo.ui.button(
- label=f"{mo.icon('lucide:rocket')} Submit",
- )
- ```
-
- **Args.**
-
- - `icon_name`: the name of the icon to display
- - `size`: the size of the icon in pixels
- - `color`: the color of the icon
- - `inline`: whether to display the icon inline or as a block element
- - `flip`: whether to flip the icon horizontally, vertically, or both
- - `rotate`: whether to rotate the icon 90, 180, or 270 degrees
- - `style`: a dictionary of CSS styles to apply to the icon
+ Examples:
+ ```python
+ mo.md(f"# {mo.icon('lucide:leaf')} Leaf")
- **Returns.**
-
- - An `Html` object.
+ mo.ui.button(
+ label=f"{mo.icon('lucide:rocket')} Submit",
+ )
+ ```
+
+ Args:
+ icon_name: the name of the icon to display
+ size: the size of the icon in pixels
+ color: the color of the icon
+ inline: whether to display the icon inline or as a block element
+ flip: whether to flip the icon horizontally, vertically, or both
+ rotate: whether to rotate the icon 90, 180, or 270 degrees
+ style: a dictionary of CSS styles to apply to the icon
+
+ Returns:
+ Html: An `Html` object.
"""
if style is None:
diff --git a/marimo/_plugins/stateless/pdf.py b/marimo/_plugins/stateless/pdf.py
index b06e81fc8a..0af3f3e965 100644
--- a/marimo/_plugins/stateless/pdf.py
+++ b/marimo/_plugins/stateless/pdf.py
@@ -26,32 +26,29 @@ def pdf(
This currently uses the native browser PDF viewer,
but may be replaced with a custom viewer.
- **Example.**
-
- ```python3
- mo.pdf(
- src="https://arxiv.org/pdf/2104.00282.pdf",
- width="100%",
- height="50vh",
- )
-
- with open("paper.pdf", "rb") as file:
- mo.pdf(src=file)
- ```
-
- **Args.**
+ Example:
+ ```python3
+ mo.pdf(
+ src="https://arxiv.org/pdf/2104.00282.pdf",
+ width="100%",
+ height="50vh",
+ )
- - `src`: the URL of the pdf or a file-like object
- - `initial_page`: the page to open the pdf to.
- only works if `src` is a URL
- - `width`: the width of the pdf
- - `height`: the height of the pdf. for a percentage
- of the user's viewport, use a string like `"50vh"`
- - `style`: a dictionary of CSS styles to apply to the pdf
+ with open("paper.pdf", "rb") as file:
+ mo.pdf(src=file)
+ ```
- **Returns.**
+ Args:
+ src: the URL of the pdf or a file-like object
+ initial_page: the page to open the pdf to.
+ only works if `src` is a URL
+ width: the width of the pdf
+ height: the height of the pdf. for a percentage
+ of the user's viewport, use a string like `"50vh"`
+ style: a dictionary of CSS styles to apply to the pdf
- `Html` object
+ Returns:
+ `Html` object
"""
resolved_src = src if isinstance(src, str) else mo_data.pdf(src.read()).url
if initial_page is not None and isinstance(src, str):
diff --git a/marimo/_plugins/stateless/tree.py b/marimo/_plugins/stateless/tree.py
index b5a540d962..f89c901f16 100644
--- a/marimo/_plugins/stateless/tree.py
+++ b/marimo/_plugins/stateless/tree.py
@@ -18,18 +18,17 @@ def tree(
) -> Html:
"""Render a nested structure of lists, tuples, or dicts as a tree.
- **Example.**
- ```python3
- mo.tree(["entry", "another entry", {"key": [0, 1, 2]}], label="A tree.")
- ```
- **Args.**
+ Example:
+ ```python3
+ mo.tree(["entry", "another entry", {"key": [0, 1, 2]}], label="A tree.")
+ ```
- - `items`: nested structure of lists, tuples, or dicts
- - `label`: optional text label for the tree
+ Args:
+ items: nested structure of lists, tuples, or dicts
+ label: optional text label for the tree
- **Returns.**
-
- `Html` object
+ Returns:
+ Html: `Html` object
"""
if not isinstance(items, (list, tuple, dict)):
raise ValueError(
diff --git a/marimo/_plugins/stateless/video.py b/marimo/_plugins/stateless/video.py
index b6b1395165..206303dd5b 100644
--- a/marimo/_plugins/stateless/video.py
+++ b/marimo/_plugins/stateless/video.py
@@ -24,30 +24,27 @@ def video(
) -> Html:
"""Render an video as HTML.
- **Example.**
-
- ```python3
- mo.video(
- src="https://v3.cdnpk.net/videvo_files/video/free/2013-08/large_watermarked/hd0992_preview.mp4",
- controls=False,
- )
- ```
-
- **Args.**
-
- - `src`: the URL of the video or a file-like object
- - `controls`: whether to show the controls
- - `muted`: whether to mute the video
- - `autoplay`: whether to autoplay the video.
- the video will only autoplay if `muted` is `True`
- - `loop`: whether to loop the video
- - `width`: the width of the video in pixels or a string with units
- - `height`: the height of the video in pixels or a string with units
- - `rounded`: whether to round the corners of the video
+ Example:
+ ```python3
+ mo.video(
+ src="https://v3.cdnpk.net/videvo_files/video/free/2013-08/large_watermarked/hd0992_preview.mp4",
+ controls=False,
+ )
+ ```
- **Returns.**
+ Args:
+ src: the URL of the video or a file-like object
+ controls: whether to show the controls
+ muted: whether to mute the video
+ autoplay: whether to autoplay the video.
+ the video will only autoplay if `muted` is `True`
+ loop: whether to loop the video
+ width: the width of the video in pixels or a string with units
+ height: the height of the video in pixels or a string with units
+ rounded: whether to round the corners of the video
- `Html` object
+ Returns:
+ `Html` object
"""
# Convert to bytes right away since can only be read once
if isinstance(src, io.BufferedReader):