summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/prism/prism.gemspec2
-rwxr-xr-xprism/templates/template.rb72
2 files changed, 46 insertions, 28 deletions
diff --git a/lib/prism/prism.gemspec b/lib/prism/prism.gemspec
index faabc22de9..64a694b66c 100644
--- a/lib/prism/prism.gemspec
+++ b/lib/prism/prism.gemspec
@@ -107,6 +107,8 @@ Gem::Specification.new do |spec|
"src/util/pm_strpbrk.c",
"src/prism.c",
"prism.gemspec",
+ "sig/prism.rbs",
+ "rbi/prism.rbi"
]
spec.extensions = ["ext/prism/extconf.rb"]
diff --git a/prism/templates/template.rb b/prism/templates/template.rb
index 4435333900..e55f92111c 100755
--- a/prism/templates/template.rb
+++ b/prism/templates/template.rb
@@ -290,33 +290,47 @@ module Prism
template = File.expand_path("../#{filepath}", __dir__)
erb = read_template(template)
-
- non_ruby_heading = <<~HEADING
- /******************************************************************************/
- /* This file is generated by the templates/template.rb script and should not */
- /* be modified manually. See */
- /* #{filepath + " " * (74 - filepath.size) } */
- /* if you are looking to modify the */
- /* template */
- /******************************************************************************/
- HEADING
-
- ruby_heading = <<~HEADING
- # frozen_string_literal: true
- =begin
- This file is generated by the templates/template.rb script and should not be
- modified manually. See #{filepath}
- if you are looking to modify the template
- =end
-
- HEADING
-
- heading =
- if File.extname(filepath.gsub(".erb", "")) == ".rb"
- ruby_heading
- else
- non_ruby_heading
- end
+ extension = File.extname(filepath.gsub(".erb", ""))
+
+ heading = case extension
+ when ".rb"
+ <<~HEADING
+ # frozen_string_literal: true
+ =begin
+ This file is generated by the templates/template.rb script and should not be
+ modified manually. See #{filepath}
+ if you are looking to modify the template
+ =end
+
+ HEADING
+ when ".rbs"
+ <<~HEADING
+ # This file is generated by the templates/template.rb script and should not be
+ # modified manually. See #{filepath}
+ # if you are looking to modify the template
+
+ HEADING
+ when ".rbi"
+ <<~HEADING
+ # typed: true
+
+ =begin
+ This file is generated by the templates/template.rb script and should not be
+ modified manually. See #{filepath}
+ if you are looking to modify the template
+ =end
+ HEADING
+ else
+ <<~HEADING
+ /******************************************************************************/
+ /* This file is generated by the templates/template.rb script and should not */
+ /* be modified manually. See */
+ /* #{filepath + " " * (74 - filepath.size) } */
+ /* if you are looking to modify the */
+ /* template */
+ /******************************************************************************/
+ HEADING
+ end
write_to ||= File.expand_path("../#{name}", __dir__)
contents = heading + erb.result_with_hash(locals)
@@ -376,7 +390,9 @@ module Prism
"src/node.c",
"src/prettyprint.c",
"src/serialize.c",
- "src/token_type.c"
+ "src/token_type.c",
+ "rbi/prism.rbi",
+ "sig/prism.rbs",
]
end