Code Monkey home page Code Monkey logo

Comments (2)

connorshea avatar connorshea commented on July 26, 2024

I tried doing this, and boy that is a lot more complex than I anticipated. Right now, it uses a RouteInspector that's technically supposed to be a private API, and it abuses some formatting tricks to output an RBI. I couldn't find a good (public API) way to consistently, programatically get all the routes available in a Rails app, unfortunately. :/

from sorbet-rails.

hdoan741 avatar hdoan741 commented on July 26, 2024

I don't think you need to find a different way to get routes. The route inspector will call the formatter for each route that it has. The RouteRbiFormatter can assume the methods are called correctly. Essentially @buffer can be replaced with a Parlour::RbiGenerator and every time a section is called, we insert new methods to the generator. When result is called, outout the generated rbi.

This is the code in rails source code that I modeled after
https://github.com/rails/rails/blob/0196551e6039ca864d1eee1e01819fcae12c1dc9/actionpack/lib/action_dispatch/routing/inspector.rb#L234

from sorbet-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.