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
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
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
140
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.8k
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
290
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
7
1.8k
スマートグラスで並列バイブコーディング
hyshu
0
280
TAKTでAI駆動開発の品質を設計する
j5ik2o
7
1.7k
act1-costs.pdf
sumedhbala
0
170
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
0
340
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
SREは、MCPとSRE Agentをこう使え!
kazumax55
0
150
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
音楽のための関数型プログラミング言語mimiumにおける多段階計算の活用
tomoyanonymous
1
280
Featured
See All Featured
Music & Morning Musume
bryan
47
7.3k
Why Our Code Smells
bkeepers
PRO
340
58k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
230
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.3k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.7k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
410
Git: the NoSQL Database
bkeepers
PRO
432
67k
A better future with KSS
kneath
240
18k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
260
Abbi's Birthday
coloredviolet
3
8.5k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
3.7k
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༵ۚ