Skip to content

Commit

Permalink
Create a new "Writing Annotations" section in the README
Browse files Browse the repository at this point in the history
Add information about `@missing_method` and `@shim` to that section
  • Loading branch information
egiurleo committed Nov 14, 2024
1 parent c7491c9 commit 7bdf40e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ If you're copying this into your own `index.json`, make sure you strip out the c

See the index [validation schema](schema.json) for more details.

### Writing Annotations

#### Missing methods and shims

It is possible to allow necessary shims for non-existing runtime definitions by using comment tags:

* `@missing_method` to indicate that a method is delegated to another receiver using `method_missing`
* `@shim` to indicate that a definition doesn't actually exist at runtime but is needed to allow type checking

### Pulling annotations

To pull relevant gem annotations into your project, run Tapioca's [`annotations` command](https://github.com/Shopify/tapioca#pulling-rbi-annotations-from-remote-sources) inside your project:
Expand Down Expand Up @@ -84,11 +93,6 @@ For each gem the test works as follows:
2. Tries to `const_get` each constant defined in the RBI file
3. Tries to call `instance_method` for each method and attribute accessor (or `method` for singleton methods) in the RBI file

It is possible to allow necessary shims for non-existing runtime definitions by using comment tags:

* `@missing_method` to indicate that a method is delegated to another receiver using `method_missing`
* `@shim` to indicate that a definition doesn't actually exist at runtime but is needed to allow type checking

### Static checks

Ensure the constants (constants, classes, modules) and properties (methods, attribute accessors) exist are not duplicated from Tapioca generated RBIs and do not create type errors when running Sorbet.
Expand Down

0 comments on commit 7bdf40e

Please sign in to comment.