From 1e444c44a561505e5e2be494886efd17517f8bb4 Mon Sep 17 00:00:00 2001 From: Tomas Capretto Date: Sun, 26 Jan 2025 11:25:09 -0300 Subject: [PATCH] Explicitly use numpy docstring style --- .github/workflows/publish_docs.yml | 1 - docsite/mkdocs.yml | 12 ++++----- flexitext/flexitext.py | 42 +++++++++++++++--------------- flexitext/textgrid.py | 10 +++---- 4 files changed, 32 insertions(+), 33 deletions(-) diff --git a/.github/workflows/publish_docs.yml b/.github/workflows/publish_docs.yml index 5305585..c60a189 100644 --- a/.github/workflows/publish_docs.yml +++ b/.github/workflows/publish_docs.yml @@ -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 diff --git a/docsite/mkdocs.yml b/docsite/mkdocs.yml index be21b8d..af36031 100644 --- a/docsite/mkdocs.yml +++ b/docsite/mkdocs.yml @@ -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 diff --git a/flexitext/flexitext.py b/flexitext/flexitext.py index 18c3223..f96b8a7 100644 --- a/flexitext/flexitext.py +++ b/flexitext/flexitext.py @@ -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. """ @@ -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: @@ -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) @@ -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) diff --git a/flexitext/textgrid.py b/flexitext/textgrid.py index 339b01e..3cf8e6f 100644 --- a/flexitext/textgrid.py +++ b/flexitext/textgrid.py @@ -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 @@ -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 = []