LoginSignup
14
12

More than 3 years have passed since last update.

VSCodeプラグインを活用してdocstringを簡単に書こう

Posted at

やりたいこと

Pythonにdocstringをできるだけ簡単に記述したい。
※VSCodeを使用することを前提にしています。

環境

VSCode: 1.53.2
Python Docstring Generator: 0.5.4

プラグインの設定

Python Docstring Generatorのインストール

VSCodeのExtensionsで"docstring"を検索すると上位に出てくるので選択してインストール。
スクリーンショット 2021-02-24 0.41.17.png

docstring設定の変更(必要に応じて)

⌘+,(windowsの場合はctrl+,)を押下して設定画面を開くと、Python Docstring Generatorの設定を変更できます。
デフォルトはGoogleフォーマットです。

使い方

docstringを挿入する箇所(classやdefの次の行)に、”””を入力しEnterを押すだけで自動で挿入されます。

docstring_make.gif

注意
methodのdocstring(ファイルの先頭)はインデントされてしまうバグ有り。

終わりに

Python Docstring Generatorを使用するとPythonファイルへのdocstringの記述がとても簡単になります。
docstringの書き方は参考ページの内容がわかりやすいと思います。


参考ページ

GoogleスタイルのPython Docstringの入門
Pythonのdocstringの書き方
[Python]可読性を上げるための、docstringの書き方を学ぶ(NumPyスタイル)Python Docstring Generator

14
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
12