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

Combine gem and annotations commands #1613

Closed
wants to merge 7 commits into from

Conversation

bitwise-aiden
Copy link
Contributor

@bitwise-aiden bitwise-aiden commented Aug 17, 2023

Motivation

Closes: #1516

In an effort to simplify the UX of Tapioca, we want to combine the annotation and gem commands so that RBIs for gems are generated using source annotations as the base.

Implementation

This implementation deprecates the old annotation command, raising an error if run. The logic for that command has been altered and moved inside the AbstractGem command to be used by the sync and generate codepaths.

A few issues have spawned off of this one around how to cache annotations between requests, but for the time being the core logic from annotation for fetching files locally/http has been kept intact. This extra work gates our ability to get the sha for the annotation file, so for now we won't be updating with a version of annotations, just the location they were sourced from.

Along with the command options from annotation, --exclude-annotation [gem, ...] and --annotations (and subsequently --no-annotations) have been added to control when annotations are used as a base.

Tests

Moved annotation tests into gem, updating for file layout, etc. Added some new tests for extra command args like --exclude-annotation

lib/tapioca/cli.rb Outdated Show resolved Hide resolved
lib/tapioca/cli.rb Show resolved Hide resolved
lib/tapioca/cli.rb Outdated Show resolved Hide resolved
lib/tapioca/commands/abstract_gem.rb Outdated Show resolved Hide resolved
lib/tapioca/commands/abstract_gem.rb Outdated Show resolved Hide resolved
lib/tapioca/commands/abstract_gem.rb Outdated Show resolved Hide resolved
lib/tapioca/commands/annotations.rb Outdated Show resolved Hide resolved
lib/tapioca/commands/gem_generate.rb Outdated Show resolved Hide resolved
@bitwise-aiden bitwise-aiden force-pushed the bitwise-aiden/poc-combine-cmds branch 3 times, most recently from 4e3a527 to dc399b6 Compare September 5, 2023 20:37
@bitwise-aiden bitwise-aiden marked this pull request as ready for review September 5, 2023 20:38
@bitwise-aiden bitwise-aiden requested a review from a team as a code owner September 5, 2023 20:38
@bitwise-aiden
Copy link
Contributor Author

The AbstractGem code relating to files and net code will be abstracted out of the class once we have decided how to appropriately cache annotation sources.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
lib/tapioca/cli.rb Show resolved Hide resolved
lib/tapioca/cli.rb Outdated Show resolved Hide resolved
lib/tapioca/commands/abstract_gem.rb Show resolved Hide resolved
file.root = RBI::Rewriters::Merge.merge_trees(
file.root,
annotation,
keep: RBI::Rewriters::Merge::Keep::LEFT,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if that should be a CLI option?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having difficulty coming up with how we communicate this option. Would the possibilities be annotation or rbi as the base?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spec/tapioca/cli/gem_spec.rb Outdated Show resolved Hide resolved
@bitwise-aiden bitwise-aiden force-pushed the bitwise-aiden/poc-combine-cmds branch 2 times, most recently from b595f83 to b2accb8 Compare September 7, 2023 21:32
lib/tapioca/cli.rb Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@bitwise-aiden
Copy link
Contributor Author

This is being put on pause while I'm away on pat leave.

The current state is that this is nearing completion and had some cursory tests against a large codebase.
We'd like to try and figure out caching / validation of which annotations go into generating the RBIs, or at least have a plan before shipping this.

  Usage:
    gem -h/--help
    gem -v/--version
    gem command [arguments...] [options...]

  Examples:
    gem install rake
    gem list --local
    gem build package.gemspec
    gem push package-0.0.1.gem
    gem help install

  Further help:
    gem help commands            list all 'gem' commands
    gem help examples            show some examples of usage
    gem help gem_dependencies    gem dependencies file guide
    gem help platforms           gem platforms guide
    gem help <COMMAND>           show help on COMMAND
                                   (e.g. 'gem help install')
    gem server                   present a web page at
                                 http://localhost:8808/
                                 with info about installed gems
  Further information:
    https://guides.rubygems.org command to use annotation logic as base
@bitwise-aiden
Copy link
Contributor Author

Closing as this is likely very stale.

@bitwise-aiden bitwise-aiden deleted the bitwise-aiden/poc-combine-cmds branch January 23, 2024 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Merge gem annotations with gem RBIs to simplify user experience
4 participants