Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Autodoc
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
heavenshell
March 13, 2014
Programming
220
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Autodoc
Py-Autodoc
heavenshell
March 13, 2014
More Decks by heavenshell
See All by heavenshell
2014-10-21-osakapy
heavenshell
0
370
Other Decks in Programming
See All in Programming
型解析で実現する Go の言語内 DSL / Conference に Go! タイムテーブルの歩き方 for Gophers
mazrean
0
130
From 6 People Classroom Meetup to 100 People Regional Conference / FOSS4G Hiroshima 2026
furukawayasuto
0
110
変化を抱擁するドキュメントの作り方 - ビジネスルール駆動開発がもたらす、コードとの新しい関係
ioki
2
110
Deep dive into the select statement (GopherCon UK)
jespino
0
170
不幸な GC
chencmd
0
880
PyO3 で既存 Python 評価器を Rust core 化する ー wasm-bindgen でブラウザにも配るための設計
kdash
1
390
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
990
30年振りにコンパイラの定数整数除算を改善した
herumi
9
4.4k
KotlinConf Extended South Korea 2026 Keynote
l2hyunwoo
0
130
初心者DevRelとして参加者だった私が、DevRel Talks!#2に登壇するまでにしてきたこと
sokohirai
0
330
AIに既存システムを理解させる技術 ~レガシーを見捨てないハーネスエンジニアリング入門~
ochtum
0
210
Flow は今どうなっているか
mizdra
PRO
0
920
Featured
See All Featured
So, you think you're a good person
axbom
PRO
2
2.1k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
560
Building a Scalable Design System with Sketch
lauravandoore
463
34k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
500
Are puppies a ranking factor?
jonoalderson
2
3.9k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
Automating Front-end Workflow
addyosmani
1369
210k
Un-Boring Meetings
codingconduct
0
410
Speed Design
sergeychernyshev
33
2.1k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Statistics for Hackers
jakevdp
799
230k
Transcript
Autodoc ʹ͍ͭͯ େࡕ Python Ϣʔβͷू·Γ 2014/03 2014.03.13 @heavenshell 143݄14༵ۚ
͓·͑ɺ୭Α Software engineer, Programmer py-qiita, py-jokk, vim-pydocstring, vim-jsdoc, vim- connpass,
etc — Python, Vim, Vimperator PHP, Perl, Java, JavaScript ͖ͳ Python ͷඪ४ؔ print() ͱ dir() 143݄14༵ۚ
My contribution 143݄14༵ۚ
My contribution 143݄14༵ۚ
My contribution 143݄14༵ۚ
My contribution 143݄14༵ۚ
My best pull request @2013 143݄14༵ۚ
143݄14༵ۚ
143݄14༵ۚ
143݄14༵ۚ
orz 143݄14༵ۚ
Autodoc 143݄14༵ۚ
143݄14༵ۚ
ࠓճ Sphinx ͷAutodoc ͞Μ Ͱͳ͘ผͷ Autodoc ͞Μ 143݄14༵ۚ
143݄14༵ۚ
143݄14༵ۚ
3BDLBQQMJDBUJPOͰ࣮͞Εͨ"1*ʹରͯ͠ɺ 34QFDͰॻ͔ΕͨςετΛݩʹ"1*υΩϡϝϯτΛੜ ͢ΔͷɻςετΛ࣮ߦ͢Δͱɺςετதʹൃߦ ͨ͠ϦΫΤετϨεϙϯεɺͦͷςετʹ͚ΒΕ ͨϝοηʔδΛݩʹɺྑ͍ײ͡ʹใΛ·ͱΊɺ .BSLEPXOܗࣜͰ"1*υΩϡϝϯτΛهͨ͠ϑΝΠϧ Λੜͯ͘͠ΕΔɻྫ͑(JU)VCͰ.BSLEPXOϑ ΝΠϧΛదʹඳըͯ͘͠ΕΔͷͰɺԼਤͷΑ͏ʹ (JU)VC্Ͱ؆୯ʹυΩϡϝϯτΛӾཡग़དྷΔΑ͏ʹ ͳΔɻ
http://r7kamura.github.io/2013/12/01/autodoc.html 143݄14༵ۚ
ࠓ࢈ۀ RSpec Ͱ API αʔόʹରͯ͠ςετΛॻ͘ ϦΫΤετͱϨεϙϯεͷ༰Λ Markdown Ͱग़ྗ ςετ͔ΒυΩϡϝϯτੜͯ͘͠Εͯศར 143݄14༵ۚ
ࣗಈతʹυΩϡϝϯτΛੜͰ͖ΔͷૉΒ͍͠ ςετΛ࣮ߦ͢ΔͱυΩϡϝϯτ͕ੜ͞ΕΔͷϝϯ ςφϯείετ͕͍ ࣮ࡏ͢Δ API ʹର࣮ͯ͠ߦ͢ΔͷͰɺੜ͖ͨυΩϡϝ ϯτ υΩϡϝϯτΛࣗಈੜ͞ΕΔϝϦοτ Python Ϣʔβ
ʔྑͬͯ͘Δ 143݄14༵ۚ
ଞݴޠʹΑΔ࣮ 143݄14༵ۚ
Test::JsonAPI::Autodoc http://moznion.hatenadiary.com/entry/ 2013/11/02/232144 143݄14༵ۚ
ॻ͖ํͪΐͬͱҟͳΔ͚ Ͳςετ͔ΒυΩϡϝϯτ Λग़ྗ͢Δͷಉ͡ 143݄14༵ۚ
Py-Autodoc http://github.com/heavenshell/py-autodoc 143݄14༵ۚ
ରԠͯ͠ΔςετFW Unittest py.test nose ֬ೝͯ͠ͳ͍͚Ͳଟಈ͘ 143݄14༵ۚ
from unittest import TestCase from webtest import TestApp from autodoc
import autodoc from tests.app import create_app class TestUnittest(TestCase): def setUp(self): app = create_app self.client = TestApp(app) @classmethod @autodoc.generate('var/test_unittest.rst') def tearDownClass(cls): pass @autodoc.describe('POST /foo/bar') def test_foo_bar(self): """ POST /foo/bar """ param = {'id': 1, 'message': 'foo'} res = self.client.post_json('/foo/bar', params=param) self.assertEqual(res.status_code, 200) return res 143݄14༵ۚ
from unittest import TestCase from webtest import TestApp from autodoc
import autodoc from tests.app import create_app class TestUnittest(TestCase): def setUp(self): app = create_app self.client = TestApp(app) @classmethod @autodoc.generate('var/test_unittest.rst') def tearDownClass(cls): pass @autodoc.describe('POST /foo/bar') def test_foo_bar(self): """ POST /foo/bar """ param = {'id': 1, 'message': 'foo'} res = self.client.post_json('/foo/bar', params=param) self.assertEqual(res.status_code, 200) return res 143݄14༵ۚ
from unittest import TestCase from webtest import TestApp from autodoc
import autodoc from tests.app import create_app class TestUnittest(TestCase): def setUp(self): app = create_app self.client = TestApp(app) @classmethod @autodoc.generate('var/test_unittest.rst') def tearDownClass(cls): pass @autodoc.describe('POST /foo/bar') def test_foo_bar(self): """ POST /foo/bar """ param = {'id': 1, 'message': 'foo'} res = self.client.post_json('/foo/bar', params=param) self.assertEqual(res.status_code, 200) return res 143݄14༵ۚ
from unittest import TestCase from webtest import TestApp from autodoc
import autodoc from tests.app import create_app class TestUnittest(TestCase): def setUp(self): app = create_app self.client = TestApp(app) @classmethod @autodoc.generate('var/test_unittest.rst') def tearDownClass(cls): pass @autodoc.describe('POST /foo/bar') def test_foo_bar(self): """ POST /foo/bar """ param = {'id': 1, 'message': 'foo'} res = self.client.post_json('/foo/bar', params=param) self.assertEqual(res.status_code, 200) return res 143݄14༵ۚ
143݄14༵ۚ
import sys import pytest from webtest import TestApp from autodoc
import autodoc @autodoc.generate('var/test_pytest.md', template='templates/markdown.md') def teardown_module(module): pass @autodoc.describe('GET /') def test_index(): app = TestApp(create_app) res = app.get('/') assert res.status_code == 200 return res 143݄14༵ۚ
import sys import pytest from webtest import TestApp from autodoc
import autodoc @autodoc.generate('var/test_pytest.md', template='templates/markdown.md') def teardown_module(module): pass @autodoc.describe('GET /') def test_index(): app = TestApp(create_app) res = app.get('/') assert res.status_code == 200 return res 143݄14༵ۚ
import sys import pytest from webtest import TestApp from autodoc
import autodoc @autodoc.generate('var/test_pytest.md', template='templates/markdown.md') def teardown_module(module): pass @autodoc.describe('GET /') def test_index(): app = TestApp(create_app) res = app.get('/') assert res.status_code == 200 return res 143݄14༵ۚ
import sys import pytest from webtest import TestApp from autodoc
import autodoc @autodoc.generate('var/test_pytest.md', template='templates/markdown.md') def teardown_module(module): pass @autodoc.describe('GET /') def test_index(): app = TestApp(create_app) res = app.get('/') assert res.status_code == 200 return res 143݄14༵ۚ
143݄14༵ۚ
ςετΫϥΠΞϯτʹ WebTest Λ༻ͯ͠Δ @autodoc.describe ͰυΩϡϝϯτΛग़ྗ͢Δϝιο υ/ؔΛఆٛ͢Δ @autodoc.generete ͰσίϨʔτͨ͠ϝιου/ؔ ͕࣮ߦ͞ΕͨλΠϛϯάͰυΩϡϝϯτΛग़ྗ 143݄14༵ۚ
υΩϡϝϯτΛੜ͢ΔλΠϛϯάςετϝιο υ/ؔ͝ͱʹ͢Εɺϝιου/ؔ୯ҐͰυΩϡϝ ϯτΛग़ྗͰ͖Δ tearDownClass Έ͍ͨͷ߹ɺ࣮ߦͨ͠શͯͷϝιο υΛ 1 ϑΝΠϧʹग़ྗ͢Δ reStracturedText
ʹରԠ͍ͯ͠Δ 143݄14༵ۚ
ςϯϓϨʔτࣗͰ࡞Մೳ ͨͩ͠String.template ΛͬͯΔͨΊࣗ༝͕͍ Ruby ඪ४Ͱ ERB Λ࣋ͬͯΔͷ͕ત·͍͠ Python ϏϧτΠϯͰ͏গ͠ߴػೳͳςϯϓϨ ʔτΤϯδϯཉ͍͠
143݄14༵ۚ
࣮γϯϓϧ(ʹͨͭ͠Γ) @autodoc.describe Ͱ return ͨ͠ response ΦϒδΣ ΫτΛύʔεͯ͠Ϧετʹ֨ೲ @autodoc.generate ͕࣮ߦͨ͠ΒϦετͷதΛϑΝΠ
ϧʹग़ྗ 143݄14༵ۚ
੍ ඞͣςετϝιου/ؔͰ WebTest ͷϨεϙϯεΛ Ԡ͢Δඞཁ͋Γ Ruby ͷ autodoc Rack-Test
Λ͏ͱ last_response ͔ΒϨεϙϯεΛऔಘͯ͠Δ͚ͲɺWebTest ʹͦΜͳ ͷແ͍ͷͰ return ͯ͠ड͚औΔ༷ Flask(ͱ͍͏͔Werkzueg)ͷςετΫϥΠΞϯτର Ԡ͠Α͏͔ͱࢥ͚ͬͨͲɺResponse ʹ Request Φϒ δΣΫτ͕֨ೲ͞Εͯͳ͍ͷͰμϝͩͬͨ 143݄14༵ۚ
·ͱΊ Autodoc ࡞ͬͨ ςετΛ࣮ߦ͢ΔͱυΩϡϝϯτΛੜͯ͘͠ΕΔͷ ศར σίϨʔλͬͯศར Web API ΛԠ͢ΔϞοΫαʔόͱΈ߹ΘͤΕ υΩϡϝϯτΛઌʹ࡞ΔࣄՄೳ
͜Ε͍͔ͭ·͍ͨͨ͠ 143݄14༵ۚ
Thank you! Any Questions? 143݄14༵ۚ