ruby / ruby/rbs

Preprocessor support for stdlib RBSs

Open
#182 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
2.2k
Forks
256
Avg merge
6d 17h
Merged PRs (30d)
37

Description

Writing RBS files, especially for standard libraries, requires a lot of duplications. (Example: File.open, Pathname#open, Kernel#open, CSV.open, ...) They are sometimes essentially depending types of other methods.

We know the problem but also decided not to extend RBS syntax for this purpose, because most of the cases are standard libraries and we don't want to make the syntax much more complex.

The plan-B is using preprocessors!

Considerations:

  • Defining APIs (DSL) for describing types.
    • type_of("File.open").keywords.except(:encoding).merge(chdir: type("String")) ...???
  • The compilation to preprocessed files. (We want to ship the preprocessed version for production.)
    • We don't want to do rake precompile every time when developing.
  • Can it be public API for end users?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points. Start by reviewing the standard-library RBS definitions and the examples around File.open, Pathname#open, Kernel#open, and CSV.open. Define the preprocessor DSL, compilation workflow, and public API before implementation; done means duplicated signatures can be generated and preprocessed files can be shipped without requiring a development-time precompile step.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.