Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
rbs-inline 生成してみた
Search
Tomoya Chiba
May 31, 2024
Programming
450
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
rbs-inline 生成してみた
Tomoya Chiba
May 31, 2024
Transcript
23 slides
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
More Decks by Tomoya Chiba
See All by Tomoya Chiba
Qiitaアーキテクチャの15年史:モノリスRailsから巨大化するサービスの技術負債をどう解消するか
tomoasleep
1
18k
スポンサーブース用の ruby.wasm くじを vibe coding した話
tomoasleep
0
240
東京Ruby会議12ヘルパー楽しかった✌
tomoasleep
0
210
LiveShare で森羅万象を共同編集する(?)
tomoasleep
1
1.1k
GitHub Actions による RSpec の時間を半分以上短縮した話
tomoasleep
2
1.7k
ts-morph と ast-grep でたくさんの TypeScript コードを書き換えた話
tomoasleep
4
4.4k
render 出来るオブジェクトの作り方
tomoasleep
0
350
Rails アプリを10年以上継続していくためのフロントエンドの底上げ
tomoasleep
3
1.2k
Rails のブラウザテストを Playwright で動かすようにしたらデバッグが簡単になって捗った
tomoasleep
4
3.3k
Other Decks in Programming
See All in Programming
선언형 햅틱 라이브러리 진동을 소개합니다
l2hyunwoo
1
310
Seven New Principles of Software Engineering
yegor256
0
490
LLM 101: Exploring LLMs, Starting with Tokens.
dalinaum
0
110
自作Discord音声botをLambda MicroVMsに移行した話 / Migrating My Discord Voice Bot to Lambda MicroVMs
akihisaikeda
1
320
Spec-Driven Development - Why Vaadin Is the Perfect Fit
simas
PRO
0
250
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
380
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
1.7k
Next.js: The final boss of Web Performance
guaca
0
400
SODA - FACT BOOK(JP)
sodainc
1
40k
Secure Your Coding Agent Like It’s Malware (v1.5) 🇬🇧 @Code.talks 2026
richargh
0
150
[Kotlin Fest 2026] eBPF Tracing for Kotlin
takehaya
0
130
Getting Started with Vibe Coding
miccheng
0
220
Featured
See All Featured
The Limits of Empathy - UXLibs8
cassininazir
2
780
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1.1k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
980
Unsuck your backbone
ammeep
672
58k
Believing is Seeing
oripsolob
1
280
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
760
How to make the Groovebox
asonas
2
2.6k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
570
Navigating Weather and Climate Data
rabernat
0
590
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.9k