From fab9f70f3863daf282a245e41b7bd82295882be6 Mon Sep 17 00:00:00 2001 From: ydah Date: Fri, 27 Dec 2024 16:37:18 +0900 Subject: [PATCH 1/3] Add rbs-inline task to Rakefile and update default task --- Rakefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 1e4bf8bd..aeb814b8 100644 --- a/Rakefile +++ b/Rakefile @@ -20,4 +20,9 @@ task :steep do sh "bundle exec steep check" end -task default: %i[spec steep] +desc "Run rbs-inline" +task :rbs_inline do + sh "bundle exec rbs-inline --output lib/" +end + +task default: %i[spec rbs_inline steep] From fa4d1915ad9cab2e66f419dfa2bbd9740a1f9e46 Mon Sep 17 00:00:00 2001 From: ydah Date: Fri, 27 Dec 2024 17:15:52 +0900 Subject: [PATCH 2/3] Add rbs-inline command to CI workflow and check for uncommitted changes --- .github/workflows/test.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3f18c22c..eda3f246 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -137,6 +137,15 @@ jobs: bundler-cache: true - run: bundle install - run: bundle exec rbs collection install + - run: bundle exec rbs-inline --output lib/ + - name: Check for uncommitted changes + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Uncommitted changes detected after running rbs-inline." + echo "Please run 'bundle rake rbs_inline' and commit the changes generated by rbs-inline." >&2 + exit 1 + fi + shell: bash - run: bundle exec steep check test-ruby: runs-on: ubuntu-20.04 From 08209430436245f3a4b7a96ec094b8ecb691e04d Mon Sep 17 00:00:00 2001 From: ydah Date: Fri, 27 Dec 2024 17:27:52 +0900 Subject: [PATCH 3/3] Update README to include section on writing type signatures with rbs-inline --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index c4f5bf7c..45feb957 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Lrama is LALR (1) parser generator written by Ruby. The first goal of this proje - [Supported Ruby version](#supported-ruby-version) - [Development](#development) - [How to generate parser.rb](#how-to-generate-parserrb) + - [How to Write a Type Signature](#how-to-write-a-type-signature) - [Test](#test) - [Call-stack Profiling Lrama](#call-stack-profiling-lrama) - [1. Create parse.tmp.y in ruby/ruby](#1-create-parsetmpy-in-rubyruby) @@ -118,6 +119,14 @@ $ bundle exec rake build:parser `parser.rb` is generated from `parser.y` by Racc. Run the rake command when you update `parser.y` then commit changes of both files. +### How to Write a Type Signature + +We use [Steep](https://github.com/soutaro/steep) for type checking and [rbs-inline](https://github.com/soutaro/rbs-inline) for type declarations. + +Currently, type signatures are declared in the [sig/lrama](https://github.com/ruby/lrama/blob/master/sig/lrama) directory. However, these files will be replaced with `rbs-inline`. This means type signatures should be written directly in the source code. + +For guidance on writing type signatures, refer to the [Syntax Guide](https://github.com/soutaro/rbs-inline/wiki/Syntax-guide) in the rbs-inline documentation. + ### Test Running tests: