SlideShare ist ein Scribd-Unternehmen logo
1 von 42
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

強化学習の基礎と深層強化学習(東京大学 松尾研究室 深層強化学習サマースクール講義資料)
強化学習の基礎と深層強化学習(東京大学 松尾研究室 深層強化学習サマースクール講義資料)強化学習の基礎と深層強化学習(東京大学 松尾研究室 深層強化学習サマースクール講義資料)
強化学習の基礎と深層強化学習(東京大学 松尾研究室 深層強化学習サマースクール講義資料)
Shota Imai
 

Was ist angesagt? (20)

分散学習のあれこれ~データパラレルからモデルパラレルまで~
分散学習のあれこれ~データパラレルからモデルパラレルまで~分散学習のあれこれ~データパラレルからモデルパラレルまで~
分散学習のあれこれ~データパラレルからモデルパラレルまで~
 
DDD x CQRS 更新系と参照系で異なるORMを併用して上手くいった話
DDD x CQRS   更新系と参照系で異なるORMを併用して上手くいった話DDD x CQRS   更新系と参照系で異なるORMを併用して上手くいった話
DDD x CQRS 更新系と参照系で異なるORMを併用して上手くいった話
 
「速」を落とさないコードレビュー
「速」を落とさないコードレビュー「速」を落とさないコードレビュー
「速」を落とさないコードレビュー
 
サイバーエージェントにおけるMLOpsに関する取り組み at PyDataTokyo 23
サイバーエージェントにおけるMLOpsに関する取り組み at PyDataTokyo 23サイバーエージェントにおけるMLOpsに関する取り組み at PyDataTokyo 23
サイバーエージェントにおけるMLOpsに関する取り組み at PyDataTokyo 23
 
例外設計における大罪
例外設計における大罪例外設計における大罪
例外設計における大罪
 
DockerコンテナでGitを使う
DockerコンテナでGitを使うDockerコンテナでGitを使う
DockerコンテナでGitを使う
 
画像処理ライブラリ OpenCV で 出来ること・出来ないこと
画像処理ライブラリ OpenCV で 出来ること・出来ないこと画像処理ライブラリ OpenCV で 出来ること・出来ないこと
画像処理ライブラリ OpenCV で 出来ること・出来ないこと
 
GitLab から GitLab に移行したときの思い出
GitLab から GitLab に移行したときの思い出GitLab から GitLab に移行したときの思い出
GitLab から GitLab に移行したときの思い出
 
SQLアンチパターン 幻の第26章「とりあえず削除フラグ」
SQLアンチパターン 幻の第26章「とりあえず削除フラグ」SQLアンチパターン 幻の第26章「とりあえず削除フラグ」
SQLアンチパターン 幻の第26章「とりあえず削除フラグ」
 
Docker Compose 徹底解説
Docker Compose 徹底解説Docker Compose 徹底解説
Docker Compose 徹底解説
 
Jetson活用セミナー ROS2自律走行実現に向けて
Jetson活用セミナー ROS2自律走行実現に向けてJetson活用セミナー ROS2自律走行実現に向けて
Jetson活用セミナー ROS2自律走行実現に向けて
 
gRPC入門
gRPC入門gRPC入門
gRPC入門
 
強化学習の基礎と深層強化学習(東京大学 松尾研究室 深層強化学習サマースクール講義資料)
強化学習の基礎と深層強化学習(東京大学 松尾研究室 深層強化学習サマースクール講義資料)強化学習の基礎と深層強化学習(東京大学 松尾研究室 深層強化学習サマースクール講義資料)
強化学習の基礎と深層強化学習(東京大学 松尾研究室 深層強化学習サマースクール講義資料)
 
Redisの特徴と活用方法について
Redisの特徴と活用方法についてRedisの特徴と活用方法について
Redisの特徴と活用方法について
 
nginx入門
nginx入門nginx入門
nginx入門
 
イミュータブルデータモデルの極意
イミュータブルデータモデルの極意イミュータブルデータモデルの極意
イミュータブルデータモデルの極意
 
できる!並列・並行プログラミング
できる!並列・並行プログラミングできる!並列・並行プログラミング
できる!並列・並行プログラミング
 
SAT/SMTソルバの仕組み
SAT/SMTソルバの仕組みSAT/SMTソルバの仕組み
SAT/SMTソルバの仕組み
 
Mavenの真実とウソ
Mavenの真実とウソMavenの真実とウソ
Mavenの真実とウソ
 
ROS を用いた自律移動ロボットのシステム構築
ROS を用いた自律移動ロボットのシステム構築ROS を用いた自律移動ロボットのシステム構築
ROS を用いた自律移動ロボットのシステム構築
 

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

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

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

Mehr von cocodrips

Mehr von cocodrips (10)

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

Kürzlich hochgeladen

Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 

Kürzlich hochgeladen (20)

Rums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfRums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdf
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptx
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Air Compressor reciprocating single stage
Air Compressor reciprocating single stageAir Compressor reciprocating single stage
Air Compressor reciprocating single stage
 

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