parlour icon indicating copy to clipboard operation
parlour copied to clipboard

Add a "flat" formatting option

Open AaronC81 opened this issue 6 years ago • 2 comments

@manhhung741 suggested this on the original Sord RFC for this project, and I think it's a good option to have. If this option is set, then generate this style:

module A
end

class A::B
end

Rather than this:

module A
  class B
  end
end

AaronC81 avatar Jul 06 '19 10:07 AaronC81

Bumping this - this is more than an option, this needs to be the new output format. RBI has serious trouble parsing the current format and being able to match constants.

dorner avatar Jul 21 '23 18:07 dorner

For example, this RBI output by Parlour:

module Deimos
  class BatchRecordList
    sig { params(records: T::Array[BatchRecord]).void }
    def initialize(records); end
    end
end

module Deimos
  class BatchRecord
  end
end

RBI will complain that it can't find BatchRecord even though it shares the same parent module, because when Tapioca reads the rbi files of the gems, it flattens them into the A::B format. This makes this nested lookup flat out not work.

In other words, when Sord outputs this code, everything looks fine, but when processed by Tapioca in a downstream project it starts failing.

dorner avatar Jul 21 '23 18:07 dorner