自分のためのdocstring書き方メモ
こちらの記事をdocstringの書き方の参考にしているのですが、一覧でバッと見たいので自分のためまとめました。
[Python]可読性を上げるための、docstringの書き方を学ぶ(NumPyスタイル)
class Cls: """ This is description of this class. Attributes ---------- a : int 1st attribute. b : str 2nd attribute. c : dict 3rd attribute. d : list of int 4th attribute. """ def __init__(self, a, b, c, d): self.a = a self.b = b self.c = c self.d = d def f(self, e, f=0.0, g=None): """ This is description of this method. Parameters ---------- e : array-like 1st parameter. f : float, default 0.0 2nd parameter. g : int or None, default None 3rd parameter. Returns ------- out1 : list of float 1st return. out2 : str 2nd return. Examples -------- >>> c.f([*range(4)], g=0) [0.0, 0.0, 0.0, 0.0], '0123' Note ---- "array-like" is list, dict, ndarray, ... Raise ----- ValueError Raises ValueError if array-like is int. See Also -------- outside_method : This is outside method. """ return [(_e+1)*g for _e in e], ''.join(map(str, e))