SlideShare a Scribd company logo
docstring !!
!1
docstring
• Python
2
def f(arg1):
""" """
pass
• @cocodrips
• 

→ 

→MLOps
• :

PyDataTokyo 

3
1. docstring
2. docstring
3. docstring
. DocString
docstring
• Python
5
def f(arg1):
""" """
pass
docstring
6
>>> help(f)
Help on function f:
f(arg1)
• docstring help 

docstring
• Jupyter Notebook ? 

help
7
Docstring
•
• 

• type 

IDE (IDE )
•
8
9
docstring
11
def func(arg1, arg2):
“”" 1
0
:param arg1: arg1
:type arg1: int #arg1
:param arg2: arg2
:type arg2: str #arg2
:rtype: bool #
:return:
"""
12
•
def func(arg1, arg2):
“”” ””"
13
• TypeHint
def func(arg1: int, arg2: str) -> bool:
"""
:param arg1: arg1
:param arg2: arg2
:return:
"""
14
• module(.py ) docstring -
"""
"""
• Class docstring
class Hello:
"""
"""
docstring
3
• ReStructuredText
• NumPy Style
• Google Style
15
ReStructuredText(reST)
16
def func(arg1, arg2):
"""
:param arg1: 1
:type arg1: 1
:param arg2: 2
:type arg2: 2
:return:
:rtype:
"""
X
def func(arg1: , arg2: ): ->
"""
:param arg1: 1
:param arg2: 2
:return:
"""
ReStructuredText - TypeHints
NumPy style
17
def func(arg1, arg2):
"""
Parameters
----------
arg1 : 1
1
arg2 : 2
2
Returns
-------
"""
• 

•
NumPy style - TypeHints
X
def func(arg1: , arg2: ) -> :
"""
Parameters
----------
arg1 :
1
arg2 :
2
Returns
-------
"""
Google Style
18
def func(arg1, arg2):
"""
Args:
arg1 ( 1 ): 1
arg2 ( 2 ): 2
Returns:
:
"""
19
• ReStructuredText
•
• NumPy Style
•
• Google Style
•
20
• ReStructuredText
•
• NumPy Style
•
• Google Style
•
TypeHints
21
• ReStructuredText
•
• NumPy Style
•
• Google Style
•
TypeHints
22
def func(arg1: , arg2: ): ->
"""
:param arg1: 1
:param arg2: 2
:return:
"""
ReStructuredText - TypeHints
PyCharm:
23
VS Code: autoDocsring
24
docstring
Sphinx
26
•知的で美しいドキュメント 

( )
•
^ω^
27
class Person:
""" """
def __init__(self, age: int, name: str):
self.age = age
self.name = name
def rest_doc_sample(age: int, name: str) -> Person:
"""Person
:param age:
:param name:
:return: Person
"""
# ...
return Person(age, name)
28
sample_package/simple_rest.py
$ pip install Sphinx sphinx-autodoc-typehints
# 依存ライブラリのインストール
$ python setup.py install
X
sphinx-apidoc import 



sphinx-apidoc
29
# 設定ファイルを作る & ドキュメントの雛形を生成
$ sphinx-apidoc -F -a -o ./doc ./sample_package
doc
├── Makefile
├── _build
├── _static
├── _templates
├── conf.py
├── index.rst
設定ファイル
• Extensionsに以下を追加
• sphinx_autodoc_typehints
• テーマを変更
• sphinx_rtd_theme
• Numpy/Google Styleを

採用する場合は拡張が必要
30
$ cd doc
$ make html
$ open _build/html/index.html
!31
…
• Quick Start
•
•
33


34
: DocString
DocString
• 

=> TypeHints + reST
• CI branch 

GitHub Pages
• docstring PR 

↑↑↑↑↑↑ ↑↑↑↑↑↑
36
DocString
• 

=> TypeHints + reST
• CI branch 

GitHub Pages
• docstring PR 

↑↑↑↑↑↑ ↑↑↑↑↑↑
37
doc-cov
Pull request
38
# CI内で以下を実行
$ doccov <package> -fmc --output csv > doccov.csv
$ doccov-report doccov.csv
Pull Request / Issue

39
$ pip install doc-cov

More Related Content

PDF
マイクロにしすぎた結果がこれだよ!
PPTX
DockerコンテナでGitを使う
PDF
例外設計における大罪
PDF
ドメイン駆動設計 本格入門
ODP
Guide To AGPL
PDF
PlaySQLAlchemy: SQLAlchemy入門
PDF
[DL輪読会]Learning Transferable Visual Models From Natural Language Supervision
PDF
Dockerからcontainerdへの移行
マイクロにしすぎた結果がこれだよ!
DockerコンテナでGitを使う
例外設計における大罪
ドメイン駆動設計 本格入門
Guide To AGPL
PlaySQLAlchemy: SQLAlchemy入門
[DL輪読会]Learning Transferable Visual Models From Natural Language Supervision
Dockerからcontainerdへの移行

What's hot (20)

PDF
オブジェクト指向できていますか?
PDF
ドメイン駆動設計のための Spring の上手な使い方
PDF
12 分くらいで知るLuaVM
PDF
コンテナの作り方「Dockerは裏方で何をしているのか?」
PDF
ドメイン駆動設計 ( DDD ) をやってみよう
PDF
Transformer メタサーベイ
PDF
イミュータブルデータモデルの極意
PDF
【BS13】チーム開発がこんなにも快適に!コーディングもデバッグも GitHub 上で。 GitHub Codespaces で叶えられるシームレスな開発
PPT
メタプログラミングって何だろう
PPTX
KeycloakでAPI認可に入門する
PDF
オブジェクト指向の設計と実装の学び方のコツ
PDF
異次元のグラフデータベースNeo4j
PDF
GPU と PYTHON と、それから最近の NVIDIA
PDF
GAN(と強化学習との関係)
PDF
深層学習フレームワークにおけるIntel CPU/富岳向け最適化法
PPTX
モノリスからマイクロサービスへの移行 ~ストラングラーパターンの検証~(Spring Fest 2020講演資料)
PPTX
世界一わかりやすいClean Architecture
PDF
ドメインオブジェクトの見つけ方・作り方・育て方
PDF
Kubernetesによる機械学習基盤への挑戦
PDF
ストリーム処理を支えるキューイングシステムの選び方
オブジェクト指向できていますか?
ドメイン駆動設計のための Spring の上手な使い方
12 分くらいで知るLuaVM
コンテナの作り方「Dockerは裏方で何をしているのか?」
ドメイン駆動設計 ( DDD ) をやってみよう
Transformer メタサーベイ
イミュータブルデータモデルの極意
【BS13】チーム開発がこんなにも快適に!コーディングもデバッグも GitHub 上で。 GitHub Codespaces で叶えられるシームレスな開発
メタプログラミングって何だろう
KeycloakでAPI認可に入門する
オブジェクト指向の設計と実装の学び方のコツ
異次元のグラフデータベースNeo4j
GPU と PYTHON と、それから最近の NVIDIA
GAN(と強化学習との関係)
深層学習フレームワークにおけるIntel CPU/富岳向け最適化法
モノリスからマイクロサービスへの移行 ~ストラングラーパターンの検証~(Spring Fest 2020講演資料)
世界一わかりやすいClean Architecture
ドメインオブジェクトの見つけ方・作り方・育て方
Kubernetesによる機械学習基盤への挑戦
ストリーム処理を支えるキューイングシステムの選び方
Ad

Similar to チームメイトのためにdocstringを書こう! pyconjp2019 (20)

PDF
Introduction to Go
PDF
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
PDF
Unleash your inner console cowboy
PDF
Intro to Python
PPTX
Perl basics for pentesters part 2
PPTX
TypeScript
PDF
Spark schema for free with David Szakallas
PDF
CPAN 模組二三事
PDF
Python高级编程(二)
PDF
Spark Schema For Free with David Szakallas
PPTX
Basic C++ 11/14 for Python Programmers
PDF
Compact ordered dict__k_lab_meeting_
PDF
Object.__class__.__dict__ - python object model and friends - with examples
PDF
Start Wrap Episode 11: A New Rope
PDF
Odessapy2013 - Graph databases and Python
KEY
Command Liner with Scala
PDF
Basic c++ 11/14 for python programmers
PPTX
Angular2 for Beginners
PDF
関数プログラマから見たPythonと機械学習
Introduction to Go
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
Unleash your inner console cowboy
Intro to Python
Perl basics for pentesters part 2
TypeScript
Spark schema for free with David Szakallas
CPAN 模組二三事
Python高级编程(二)
Spark Schema For Free with David Szakallas
Basic C++ 11/14 for Python Programmers
Compact ordered dict__k_lab_meeting_
Object.__class__.__dict__ - python object model and friends - with examples
Start Wrap Episode 11: A New Rope
Odessapy2013 - Graph databases and Python
Command Liner with Scala
Basic c++ 11/14 for python programmers
Angular2 for Beginners
関数プログラマから見たPythonと機械学習
Ad

More from cocodrips (10)

PDF
Python仮想環境構築の基礎と ツールの比較
PDF
スマホでDeepLearning実践入門(α版)
PDF
Docstringを書こう!
PDF
Python update in 2018 #ll2018jp
PPTX
C++と仲良くなるためのn問 ~ポインタ編~ #ladiescpp
PDF
Simple is better than complex. ~私がPythonを愛する理由~
PDF
ポインタ渡しと参照渡し
PDF
女性のためのC++コミュニティ Ladies++
PDF
強くなるためのプログラミング -プログラミングに関する様々なコンテストとそのはじめ方-#pyconjp
PDF
Pythonではじめる競技プログラミング
Python仮想環境構築の基礎と ツールの比較
スマホでDeepLearning実践入門(α版)
Docstringを書こう!
Python update in 2018 #ll2018jp
C++と仲良くなるためのn問 ~ポインタ編~ #ladiescpp
Simple is better than complex. ~私がPythonを愛する理由~
ポインタ渡しと参照渡し
女性のためのC++コミュニティ Ladies++
強くなるためのプログラミング -プログラミングに関する様々なコンテストとそのはじめ方-#pyconjp
Pythonではじめる競技プログラミング

Recently uploaded (20)

PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
DOCX
573137875-Attendance-Management-System-original
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Lecture Notes Electrical Wiring System Components
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
UNIT 4 Total Quality Management .pptx
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
Construction Project Organization Group 2.pptx
PDF
PPT on Performance Review to get promotions
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
573137875-Attendance-Management-System-original
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
CH1 Production IntroductoryConcepts.pptx
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Internet of Things (IOT) - A guide to understanding
CYBER-CRIMES AND SECURITY A guide to understanding
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Lecture Notes Electrical Wiring System Components
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
UNIT 4 Total Quality Management .pptx
Model Code of Practice - Construction Work - 21102022 .pdf
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Construction Project Organization Group 2.pptx
PPT on Performance Review to get promotions
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx

チームメイトのためにdocstringを書こう! pyconjp2019