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
rbs-inline 生成してみた
Search
Tomoya Chiba
May 31, 2024
Programming
1
290
rbs-inline 生成してみた
Tomoya Chiba
May 31, 2024
Tweet
Share
More Decks by Tomoya Chiba
See All by Tomoya Chiba
スポンサーブース用の ruby.wasm くじを vibe coding した話
tomoasleep
0
42
東京Ruby会議12ヘルパー楽しかった✌
tomoasleep
0
96
LiveShare で森羅万象を共同編集する(?)
tomoasleep
1
640
GitHub Actions による RSpec の時間を半分以上短縮した話
tomoasleep
2
1.3k
ts-morph と ast-grep でたくさんの TypeScript コードを書き換えた話
tomoasleep
4
3.8k
render 出来るオブジェクトの作り方
tomoasleep
0
230
Rails アプリを10年以上継続していくためのフロントエンドの底上げ
tomoasleep
3
940
Rails のブラウザテストを Playwright で動かすようにしたらデバッグが簡単になって捗った
tomoasleep
3
3k
Sorbetやっていき(たい)宣言
tomoasleep
0
430
Other Decks in Programming
See All in Programming
なんとなくわかった気になるブロックテーマ入門/contents.nagoya 2025 6.28
chiilog
1
270
iOS 26にアップデートすると実機でのHot Reloadができない?
umigishiaoi
0
130
今ならAmazon ECSのサービス間通信をどう選ぶか / Selection of ECS Interservice Communication 2025
tkikuc
21
4k
Webの外へ飛び出せ NativePHPが切り拓くPHPの未来
takuyakatsusa
2
560
VS Code Update for GitHub Copilot
74th
2
650
地方に住むエンジニアの残酷な現実とキャリア論
ichimichi
5
1.5k
Azure AI Foundryではじめてのマルチエージェントワークフロー
seosoft
0
170
Blazing Fast UI Development with Compose Hot Reload (droidcon New York 2025)
zsmb
1
290
AI コーディングエージェントの時代へ:JetBrains が描く開発の未来
masaruhr
1
160
設計やレビューに悩んでいるPHPerに贈る、クリーンなオブジェクト設計の指針たち
panda_program
6
2.1k
5つのアンチパターンから学ぶLT設計
narihara
1
170
RailsGirls IZUMO スポンサーLT
16bitidol
0
190
Featured
See All Featured
It's Worth the Effort
3n
185
28k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
A designer walks into a library…
pauljervisheath
207
24k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3.1k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
Optimizing for Happiness
mojombo
379
70k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
Building Adaptive Systems
keathley
43
2.7k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
107
19k
Embracing the Ebb and Flow
colly
86
4.7k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Transcript
Tomoya Chiba (@tomoasleep) rbs-inline 生成してみた 1
Tomoya Chiba Twitter: @nemunemu3desu その他: @tomoasleep Qiita 株式会社 シニアエンジニア 4
時間前に LT に申し込みました Ruby に型が欲しい派閥 型はコード中に書きたい派閥 自己紹介 2
rbs-inline が作られている 3
soutaro/rbs-inline: Inline RBS type declaration コメントとして RBS が書ける rbs-inline が作られている
4
soutaro/rbs-inline: Inline RBS type declaration コメントとして RBS が書ける rbs-inline が作られている
5
https://github.com/soutaro/rbs-inline/wiki/Syntax-guide 文法どんな感じか 6
https://github.com/soutaro/rbs-inline/wiki/Syntax-guide 文法どんな感じか 7
https://github.com/soutaro/rbs-inline/wiki/Syntax-guide 文法どんな感じか 8
https://github.com/soutaro/rbs-inline/wiki/Syntax-guide 文法どんな感じか 9
まだ Experimental & プロトタイプなので注意 10
Ruby 中で RBS を書きたかった ( 生成したかった) 民としては最高 表現力も高そう Experimental だけど試したい…
めちゃくちゃ良さそう 11
破壊的変更が入っても、(Prism で) 機械的に書き換えればいいのでは? Experimental でも試したい!! 12
(YARD から) rbs-inline を生成してみた 13
(YARD から) rbs-inline を生成してみた 14
https://github.com/tomoasleep/yard_to_rbs_inline (YARD から) rbs-inline を生成してみた 15
多分 okura さんが解説してくれてるはず マニュアル: https://ruby.github.io/prism/rb/index.html にマニュアルがある bs-inline は Prism で動いている
rbs-inline を読めば Prism も学べる!! Prism をどう学ぶか 16
require 'prism'; Prism.parse("def hoge(a); end") Prism 使い方 (1) - パース処理
17
require 'prism'; Prism.parse("def hoge(a); end").value.statements Prism 使い方 (1) - パース処理
18
Prism::Visitor を使うと AST の走査が出来る class MyVisitor < Prism::Visitor #:: (Prism::CallNode)
-> void def visit_call_node(node) # メソッド呼び出しの Node に出くわしたときの処理 end #:: (Prism::DefNode) -> void def visit_def_node(node) # メソッド呼び出しの Node に出くわしたときの処理 end end Prism 使い方 (2) - Visitor 19
1. Prism でこれらの Node を見る メソッド定義 attr_reader 2. Node 直前のコメントとメソッドのパラメータを抽出
3. YARD を (racc で) 頑張って parse 4. rbs-inline のコメントを直前行に追加 Prism で rbs-inline 出力どんな感じか 20
Parser は2 箇所だけ見れば OK メソッド呼び出し メソッド定義 コメントを手前の行に挿入するだけ ( この辺は文字列操作でやる) コメント自動生成は
( 実は) Parser 入門に向いてる (?) 21
RubyKaigi の発表も楽しみ! 22
rbs collection, rbs-inline と徐々に RBS エコシステムが整いつつある Prism を学べば experimental でも気兼ねなく試せる!!
パーサーを書いて快適な rbs-inline ライフを! RBS を書く環境がどんどん整ってきてる!! 23