No description
Find a file
2026-06-14 14:32:46 -07:00
lib initial commit 2026-06-14 14:31:48 -07:00
rbi initial commit 2026-06-14 14:31:48 -07:00
.gitignore initial commit 2026-06-14 14:31:48 -07:00
dragonruby-rbi-stubs.gemspec initial commit 2026-06-14 14:31:48 -07:00
Gemfile initial commit 2026-06-14 14:31:48 -07:00
README.md clean up readme 2026-06-14 14:32:46 -07:00

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

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::ButtonState and GTK::Keyboard::KeyState are invented helper classes to give types to the key_down, key_held, and key_up sub-objects that DragonRuby returns dynamically. KeyState uses method_missing / T.untyped since keyboard key names are too numerous to enumerate exhaustively.
  • Global variables ($args, $gtk, etc.) are declared with T.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