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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
S3 を使うアプリケーションをローカル完結で動かすことに全力を注いでみた / Running S3 Apps Offline
contour_gara
0
480
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
680
「人を評価する AI」の設計と実装
ryoyanara
0
200
リアルな遅延を測る仕様
kota_yata
1
100
改善しないと、タスクが回らない。 “てんこ盛りポジション” を引き継いだ情シスの、入社3ヶ月の業務改善録
krm963
0
260
AIが無かった頃の素敵な出会いの話
codmoninc
1
430
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
210
OpenSpecのproposalにbrainstormingを持たせてみた
tigertora7571
1
230
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
570
仕様書を書く前にハーネスを作る - Agent Native開発は「探索を速く、判定を固く」
gotalab555
4
1.6k
Flow は今どうなっているか
mizdra
PRO
0
480
変わらないものが、変わるものを決める — 意図駆動開発 × イベントソーシング × イミュータブル | What Doesn't Change Decides What Can — IDD × Event Sourcing × Immutability
tomohisa
0
1.7k
Featured
See All Featured
A better future with KSS
kneath
240
18k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
The untapped power of vector embeddings
frankvandijk
2
1.8k
Balancing Empowerment & Direction
lara
6
1.2k
GraphQLとの向き合い方2022年版
quramy
50
15k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.2k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Testing 201, or: Great Expectations
jmmastey
46
8.2k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
710
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.4k
How STYLIGHT went responsive
nonsquared
100
6.2k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
480
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༵ۚ