tapioca icon indicating copy to clipboard operation
tapioca copied to clipboard

Add ability to generate DSL RBIs for classes in a given file

Open ryanseys opened this issue 3 years ago • 2 comments

Would be nice to do something like:

$ tapioca dsl --file my_ruby_file.rb

And have it automatically generate the RBIs for the classes in the given ruby file.

My use case is it would be cool to automatically trigger regenerations of RBIs on save of a file, or set up a git commit hook to do this before committing staged files.

ryanseys avatar Feb 23 '22 23:02 ryanseys

@ryanseys Indeed, that would be a great feature but it would probably not be feasible via the command line interface. The problem is that Tapioca needs to boot the application and load it into memory so that it can then do runtime introspection for DSL patterns. This takes a considerable amount of time and starts being less useful as an interactive developer tool in the way you are asking for for that reason.

We have been thinking of adding an LSP (Language Server Protocol) layer to Tapioca which would make it run in the background as a daemon and talk to your editor via LSP. That way, upon file changes, it can reload the class (or rely on Rails reloading) to immediately discover what needs to be updated in RBI files. I think that should satisfy your ask, but there is some amount of work to be done until we get to that point.

Until then, if you know the class (or can parse it from the file you are working on effectively and statically yourself), then you can always use bin/tapioca dsl <NameOfClassOrModule> to (re)generete the RBI file for just that class/module. That also runs faster, since we don't have to eager load everything in the Rails app all upfront.

paracycle avatar Feb 24 '22 15:02 paracycle

Fixed via #968.

@paracycle - I think this can be marked as resolved.

jeffcarbs avatar Feb 27 '23 14:02 jeffcarbs