- Ruby 100%
| lib | ||
| rbi | ||
| .gitignore | ||
| dragonruby-rbi-stubs.gemspec | ||
| Gemfile | ||
| README.md | ||
dragonruby-rbi-stubs
Sorbet RBI type stubs for the DragonRuby Game Toolkit.
Overview
DragonRuby runs on MRuby and doesn't ship with type information. This gem provides Sorbet RBI stub files covering DragonRuby's full runtime API, so you can get type checking, autocomplete, and inline documentation in editors that support Sorbet (VS Code with Sorbet extension, RubyMine, etc.) while developing your game with standard Ruby tooling.
Installation
Add to your project's Gemfile:
group :development do
gem "dragonruby-rbi-stubs"
end
Then run:
bundle install
Setup
Option 1 — Sorbet config (recommended)
Add the gem's rbi/ directory to your sorbet/config file:
--dir
.
--dir
<%= `bundle exec ruby -e "require 'dragonruby-rbi-stubs'; print DragonrubyRbiStubs.rbi_path"` %>
Or hard-code the resolved path by running this once and pasting the output:
bundle exec ruby -e "require 'dragonruby-rbi-stubs'; puts DragonrubyRbiStubs.rbi_path"
Option 2 — Copy stubs into your project
Copy the rbi/ directory from the gem directly into sorbet/rbi/dragonruby/ if you prefer to vendor the stubs:
cp -r $(bundle exec ruby -e "require 'dragonruby-rbi-stubs'; print DragonrubyRbiStubs.rbi_path") sorbet/rbi/dragonruby
Notes
- These stubs target DragonRuby Standard and Pro editions. A small number of methods (e.g.
dlopen) are Pro-only at runtime, but are included here unconditionally. GTK::Controller::ButtonStateandGTK::Keyboard::KeyStateare invented helper classes to give types to thekey_down,key_held, andkey_upsub-objects that DragonRuby returns dynamically.KeyStateusesmethod_missing/T.untypedsince keyboard key names are too numerous to enumerate exhaustively.- Global variables (
$args,$gtk, etc.) are declared withT.let(T.unsafe(nil), Type)so Sorbet knows their types without enforcing initialization. - The stubs were generated from dragonruby-yard-doc.
Contributing
Pull requests are welcome. The source of truth for method signatures is the YARD documentation in dragonruby-yard-doc. When adding or correcting a stub, please keep the Sorbet type as precise as the YARD @return / @param tags allow.
License
MIT