Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detach RBI header comment from top-level node (when generating YARD docs) #1885

Merged
merged 2 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/tapioca/rbi_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ 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 }
Expand Down
14 changes: 14 additions & 0 deletions spec/tapioca/cli/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class Post
# This is an autogenerated file for dynamic methods in `Post`.
# Please instead update this file by running `bin/tapioca dsl Post`.


class Post
include SmartPropertiesGeneratedMethods

Expand Down Expand Up @@ -315,6 +316,7 @@ class Comment
# This is an autogenerated file for dynamic methods in `Post`.
# Please instead update this file by running `bin/tapioca dsl Post`.


class Post
include SmartPropertiesGeneratedMethods

Expand All @@ -335,6 +337,7 @@ def title=(title); end
# This is an autogenerated file for dynamic methods in `Namespace::Comment`.
# Please instead update this file by running `bin/tapioca dsl Namespace::Comment`.


class Namespace::Comment
include SmartPropertiesGeneratedMethods

Expand Down Expand Up @@ -400,6 +403,7 @@ class Role
# This is an autogenerated file for dynamic methods in `Foo::Role`.
# Please instead update this file by running `bin/tapioca dsl Foo::Role`.


class Foo::Role
include SmartPropertiesGeneratedMethods

Expand Down Expand Up @@ -454,6 +458,7 @@ class Comment
# This is an autogenerated file for dynamic methods in `Post`.
# Please instead update this file by running `bin/tapioca dsl Post`.


class Post
include SmartPropertiesGeneratedMethods

Expand Down Expand Up @@ -1049,6 +1054,7 @@ def self.gather_constants
# This is an autogenerated file for dynamic methods in `Post`.
# Please instead update this file by running `bin/tapioca dsl Post`.


class Post
include GeneratedBar
include GeneratedFoo
Expand Down Expand Up @@ -1142,6 +1148,7 @@ def self.gather_constants
# This is an autogenerated file for dynamic methods in `Job`.
# Please instead update this file by running `bin/tapioca dsl Job`.


class Job
class << self
sig { params(foo: T.untyped, bar: T.untyped).returns(String) }
Expand Down Expand Up @@ -1357,6 +1364,7 @@ class Post
# This is an autogenerated file for dynamic methods in `Post`.
# Please instead update this file by running `bin/tapioca dsl Post`.


class Post
include SmartPropertiesGeneratedMethods

Expand Down Expand Up @@ -1661,6 +1669,7 @@ class Post < ActiveRecord::Base
# This is an autogenerated file for dynamic methods in `Post`.
# Please instead update this file by running `bin/tapioca dsl Post`.


class Post
include StoreAccessors

Expand Down Expand Up @@ -1972,6 +1981,7 @@ def self.gather_constants
# This is an autogenerated file for dynamic methods in `Post`.
# Please instead update this file by running `bin/tapioca dsl Post`.


class Post
include GeneratedBar

Expand Down Expand Up @@ -2181,6 +2191,7 @@ def decorate
# This is an autogenerated file for dynamic methods in `CreditCard`.
# Please instead update this file by running `bin/tapioca dsl CreditCard`.


class CreditCard
sig { returns(String) }
def number; end
Expand Down Expand Up @@ -2333,6 +2344,7 @@ def decorate
# This is an autogenerated file for dynamic methods in `CreditCard`.
# Please instead update this file by running `bin/tapioca dsl CreditCard`.


class CreditCard
sig { returns(String) }
def number; end
Expand Down Expand Up @@ -2484,6 +2496,7 @@ class Post::Rack < Post
# This is an autogenerated file for dynamic methods in `Post::Rack`.
# Please instead update this file by running `bin/tapioca dsl Post::Rack`.


class Post::Rack
include SmartPropertiesGeneratedMethods

Expand All @@ -2504,6 +2517,7 @@ def title=(title); end
# This is an autogenerated file for dynamic methods in `Post::Rails`.
# Please instead update this file by running `bin/tapioca dsl Post::Rails`.


class Post::Rails
include SmartPropertiesGeneratedMethods

Expand Down
10 changes: 10 additions & 0 deletions spec/tapioca/cli/gem_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module Reopened
# This is an autogenerated file for types exported from the `foo` gem.
# Please instead update this file by running `bin/tapioca gem foo`.


module Foo
class << self
def foo(a = T.unsafe(nil), b: T.unsafe(nil), **opts); end
Expand Down Expand Up @@ -64,6 +65,7 @@ module Reopened
# This is an autogenerated file for types exported from the `bar` gem.
# Please instead update this file by running `bin/tapioca gem bar`.


module Bar
class << self
def bar(a = T.unsafe(nil), b: T.unsafe(nil), **opts); end
Expand Down Expand Up @@ -93,6 +95,7 @@ def fizz
# This is an autogenerated file for types exported from the `baz` gem.
# Please instead update this file by running `bin/tapioca gem baz`.


module Baz; end

class Baz::Test
Expand Down Expand Up @@ -350,6 +353,7 @@ def bar; end
# This is an autogenerated file for types exported from the `foo` gem.
# Please instead update this file by running `bin/tapioca gem foo`.


module Foo
def foo; end

Expand Down Expand Up @@ -835,6 +839,7 @@ class Secret; end
# This is an autogenerated file for types exported from the `foo` gem.
# Please instead update this file by running `bin/tapioca gem foo`.


# THIS IS AN EMPTY RBI FILE.
# see https://github.com/Shopify/tapioca#manually-requiring-parts-of-a-gem
RBI
Expand Down Expand Up @@ -959,6 +964,7 @@ class TaskLib
# This is an autogenerated file for types exported from the `fake_rake` gem.
# Please instead update this file by running `bin/tapioca gem fake_rake`.


module FakeRake; end
class FakeRake::TaskLib; end
RBI
Expand Down Expand Up @@ -1052,6 +1058,7 @@ def foo(a, b, c, d, e, f, g, h); end
# This is an autogenerated file for types exported from the `foo` gem.
# Please instead update this file by running `bin/tapioca gem foo`.


module Foo
sig { params(a: T.untyped, b: T.untyped, c: T.untyped, d: T.untyped, e: T.untyped, f: T.untyped, g: T.untyped).void }
def bar(a, b, c, d, e, f, g); end
Expand Down Expand Up @@ -1103,6 +1110,7 @@ def foo(a, b, c, d, e, f, g, h); end
# This is an autogenerated file for types exported from the `foo` gem.
# Please instead update this file by running `bin/tapioca gem foo`.


module Foo
sig do
params(
Expand Down Expand Up @@ -1249,6 +1257,7 @@ class Post
# This is an autogenerated file for types exported from the `foo` gem.
# Please instead update this file by running `bin/tapioca gem foo`.


module Foo; end

class Foo::Engine < ::Rails::Engine
Expand Down Expand Up @@ -1806,6 +1815,7 @@ class << self
# This is an autogenerated file for types exported from the `type_variable` gem.
# Please instead update this file by running `bin/tapioca gem type_variable`.


class ComplexGenericType
extend T::Generic

Expand Down
Loading