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

Explicitly use numpy docstring style #22

Merged
merged 1 commit into from
Jan 26, 2025
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
1 change: 0 additions & 1 deletion .github/workflows/publish_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ jobs:
python --version
pip install mkdocs-material
pip install mkdocstrings[python]
pip install pytkdocs[numpy-style]
cd docsite
mkdocs gh-deploy --force
12 changes: 6 additions & 6 deletions docsite/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ markdown_extensions:
- pymdownx.highlight
- pymdownx.superfences
plugins:
- search
- mkdocstrings:
handlers:
python:
selection:
docstring_style: numpy # then add pytkdocs[numpy-style] dependency
- search
- mkdocstrings:
handlers:
python:
options:
docstring_style: numpy
42 changes: 21 additions & 21 deletions flexitext/flexitext.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class FlexiText:
Parameters
----------

texts: tuple or list of flexitext.Text instances
texts : tuple or list of flexitext.Text instances
These objects represent the text together with their styles.
"""

Expand All @@ -37,32 +37,32 @@ def plot(

Parameters
----------
x: float
x : float
The horizontal position to place the text. By default, this is in axes fraction
coordinates.
y: float
y : float
The vertical position to place the text. By default, this is in axes fraction
coordinates.
ha: str
ha : str
Horizontal alignment. Must be one of `'center'`, `'right'`, or `'left'`.
va: str
va : str
Horizontal alignment. Must be one of `'center'`, `'top'`, or `'bottom'`.
ma: str
ma : str
Alignment for multiline texts. The layout of the bounding box of all the lines is
determined by the `ha` and `va` properties. This property controls the alignment of the
text lines within that box.
mva: str
mva : str
Vertical alignment for text within multiline texts. Can be one of `"top"`, `"bottom"`,
`"left"`, `"right"`, `"center"`, or `"baseline"`. Defaults to `"baseline"`.
xycoords: str
xycoords : str
The coordinate system for `x` and `y`. Must be one of `'data'`, `'axes fraction'`, or
`'figure fraction'`.
ax: matplotlib.axes.Axes
ax : matplotlib.axes.Axes
Matplotlib `Axes`. The default value means the `Axes` is obtained with `plt.gca()`

Returns
-------
annotation_box: matplotlib.offsetbox.AnnotationBbox
annotation_box : matplotlib.offsetbox.AnnotationBbox
"""

if ax is None:
Expand Down Expand Up @@ -93,7 +93,7 @@ def plot(
return annotation_box

def _make_box_alignment(self, ha, va):
"""Convert ha and va to a touple of two numbers"""
"""Convert `ha` and `va` to a touple of two numbers"""
ha = self.HORIZONTAL_ALIGNMENT[ha]
va = self.VERTICAL_ALIGNMENT[va]
return (ha, va)
Expand All @@ -118,31 +118,31 @@ def flexitext(

Parameters
----------
x: float
x : float
The horizontal position to place the text. By default, this is in axes fraction
coordinates.
y: float
y : float
The vertical position to place the text. By default, this is in axes fraction
coordinates.
ha: str
ha : str
Horizontal alignment. Must be one of `'center'`, `'right'`, or `'left'`.
va: str
va : str
Horizontal alignment. Must be one of `'center'`, `'top'`, or `'bottom'`.
ma: str
ma : str
Alignment for multiline texts. The layout of the bounding box of all the lines is
determined by the `ha` and `va` properties. This property controls the alignment of the
text lines within that box.
mva: str
mva : str
Vertical alignment for text within multiline texts. Can be one of `"top"`, `"bottom"`,
`"left"`, `"right"`, `"center"`, or `"baseline"`. Defaults to `"baseline"`.
xycoords: str
xycoords : str
The coordinate system for `x` and `y`. Must be one of `'axes fraction'` or
`'figure fraction'`.
ax: matplotlib.axes.Axes
Matplotlib `Axes`. The default value means the `Axes` is obtained with `plt.gca()`
ax : matplotlib.axes.Axes
Matplotlib `Axes`. The default value means the `Axes` is obtained with `plt.gca()`.

Returns
-------
annotation_box: matplotlib.offsetbox.AnnotationBbox
annotation_box : matplotlib.offsetbox.AnnotationBbox
"""
return FlexiText(*make_texts(s)).plot(x, y, ha, va, ma, mva, xycoords, ax)
10 changes: 5 additions & 5 deletions flexitext/textgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def make_grid(texts):

Returns
-------
grid: list
grid : list
A nested list with `Text` instances.
"""
row_n = sum(text.string.count("\n") for text in texts) + 1
Expand All @@ -37,20 +37,20 @@ def make_text_grid(texts, ha="left", va="baseline"):

Parameters
----------
texts: tuple of flexitext.Text instances
texts : tuple of flexitext.Text instances
These objects represent the text together with their styles.
ha: str
ha : str
Horizontal alignment for multiline texts. This alignment is applied to the `VPacker`
instance. Can be one of `"top"`, `"bottom"`, `"left"`, `"right"`, `"center"`, or
`"baseline"`. Defaults to `"left"`
va: str
va : str
Vertical alignment for multiline texts within the text area. This alignment is applied
to `HPacker`. Can be one of `"top"`, `"bottom"`, `"left"`, `"right"`, `"center"`, or
`"baseline"`. Defaults to `"baseline"`.

Returns
-------
text_grid: VPacker
text_grid : VPacker
"""
grid = make_grid(texts)
childrens = []
Expand Down
Loading