Sha256: fb238746d2e0b69eda5e968a759e2d0b52e6e54506a755d1a1de3feb295dad8e

Contents?: true

Size: 1.31 KB

Versions: 7

Compression:

Stored size: 1.31 KB

Contents

# typed: strict
# frozen_string_literal: true

module Tapioca
  class RBIFormatter < RBI::Formatter
    extend T::Sig

    sig do
      params(
        file: RBI::File,
        command: String,
        reason: T.nilable(String),
      ).void
    end
    def write_header!(file, command, reason: nil)
      file.comments << RBI::Comment.new("DO NOT EDIT MANUALLY")
      file.comments << RBI::Comment.new("This is an autogenerated file for #{reason}.") unless reason.nil?
      file.comments << RBI::Comment.new("Please instead update this file by running `#{command}`.")
      # Prevent the header from being attached to the top-level node when generating YARD docs
      file.comments << RBI::BlankLine.new
    end

    sig { params(file: RBI::File).void }
    def write_empty_body_comment!(file)
      file.comments << RBI::BlankLine.new unless file.comments.empty?
      file.comments << RBI::Comment.new("THIS IS AN EMPTY RBI FILE.")
      file.comments << RBI::Comment.new("see https://github.com/Shopify/tapioca#manually-requiring-parts-of-a-gem")
    end
  end

  DEFAULT_RBI_FORMATTER = T.let(
    RBIFormatter.new(
      add_sig_templates: false,
      group_nodes: true,
      max_line_length: nil,
      nest_singleton_methods: true,
      nest_non_public_members: true,
      sort_nodes: true,
    ),
    RBIFormatter,
  )
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tapioca-0.16.8 lib/tapioca/rbi_formatter.rb
tapioca-0.16.7 lib/tapioca/rbi_formatter.rb
tapioca-0.16.6 lib/tapioca/rbi_formatter.rb
tapioca-0.16.5 lib/tapioca/rbi_formatter.rb
tapioca-0.16.4 lib/tapioca/rbi_formatter.rb
tapioca-0.16.3 lib/tapioca/rbi_formatter.rb
tapioca-0.16.2 lib/tapioca/rbi_formatter.rb