diff options
author | Vinicius Stock <vinicius.stock@shopify.com> | 2023-10-19 11:17:23 -0400 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-10-27 13:45:52 +0000 |
commit | 544f64075bc42a2935624403201c78468e180d3d (patch) | |
tree | 083089e1fa5de8ba95075250b1bc33d359f39906 /prism | |
parent | a8af5d3808535b584b8c0a061f035f5468ba930c (diff) | |
download | ruby-544f64075bc42a2935624403201c78468e180d3d.tar.gz |
[ruby/prism] Add RBI and RBS templates for Prism
https://github.com/ruby/prism/commit/b62305ff3e
Co-authored-by: Stan Lo <st0012@users.noreply.github.com>
Diffstat (limited to 'prism')
-rwxr-xr-x | prism/templates/template.rb | 72 |
1 files changed, 44 insertions, 28 deletions
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 |