sorbet_view 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +139 -0
- data/lib/sorbet_view/version.rb +1 -1
- data/sorbet_view.gemspec +2 -2
- metadata +9 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2019d3e1be947510db7affa9e59bb2762029b5fbef59aecc0ac8d9bbd3f669ca
|
|
4
|
+
data.tar.gz: f52c75816d4d3afe3e6fe693d3e3764679667be85675b23c8768bd5e5b22a45d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4d70e4367cec565f2f599fa91cdc144882f975203c735836bb5c446776b62e6a44063a53fa2b14086c4269d3c1562aa7ade61bda670d422f438e4ad5ece278b3
|
|
7
|
+
data.tar.gz: 814785d6a2872e1e250926bdf7d37d4a55cbcfa8a55ca71bfd3cd7b68150293a3703685bf9285c4b9b326678b60c5a33afe4b53ab6be98f253c854cecbb40ff9
|
data/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# SorbetView
|
|
2
|
+
|
|
3
|
+
Sorbet type-checking for Rails view templates (ERB). Extracts Ruby code from templates, generates typed Ruby files, and provides LSP support for editor integration.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Type-check Ruby code inside ERB templates with [Sorbet](https://sorbet.org/)
|
|
8
|
+
- LSP proxy server for hover, completion, go-to-definition in `.erb` files
|
|
9
|
+
- ViewComponent `erb_template` heredoc support
|
|
10
|
+
- Source mapping between templates and generated Ruby for accurate error reporting
|
|
11
|
+
- Tapioca DSL compiler for helper method RBI generation
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
Add to your Gemfile:
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
gem 'sorbet_view'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Then run:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
bundle install
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Setup
|
|
28
|
+
|
|
29
|
+
Generate a config file:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
bundle exec sv init
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
This creates `.sorbet_view.yml`:
|
|
36
|
+
|
|
37
|
+
```yaml
|
|
38
|
+
input_dirs:
|
|
39
|
+
- app/views
|
|
40
|
+
|
|
41
|
+
exclude_paths: []
|
|
42
|
+
|
|
43
|
+
output_dir: sorbet/templates
|
|
44
|
+
|
|
45
|
+
extra_includes: []
|
|
46
|
+
|
|
47
|
+
skip_missing_locals: true
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Configuration Options
|
|
51
|
+
|
|
52
|
+
| Option | Default | Description |
|
|
53
|
+
|--------|---------|-------------|
|
|
54
|
+
| `input_dirs` | `['app/views']` | Directories to scan for `.erb` templates |
|
|
55
|
+
| `exclude_paths` | `[]` | Paths to exclude from scanning |
|
|
56
|
+
| `output_dir` | `'sorbet/templates'` | Where generated Ruby files are written |
|
|
57
|
+
| `extra_includes` | `[]` | Additional modules to include in generated classes |
|
|
58
|
+
| `extra_body` | `''` | Additional code to include in generated classes |
|
|
59
|
+
| `skip_missing_locals` | `true` | Skip partials without `locals:` declaration |
|
|
60
|
+
| `sorbet_path` | `'srb'` | Path to the Sorbet binary |
|
|
61
|
+
| `typed_level` | `'true'` | Sorbet `typed` level for generated files |
|
|
62
|
+
| `component_dirs` | `[]` | Directories to scan for ViewComponent files |
|
|
63
|
+
|
|
64
|
+
## Usage
|
|
65
|
+
|
|
66
|
+
### Compile templates
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
bundle exec sv compile
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Compile and type-check
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
bundle exec sv tc
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Pass extra arguments to Sorbet after `--`:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
bundle exec sv tc -- --error-url-base=https://srb.help/
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### LSP server
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
bundle exec sv lsp
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Used by the [VSCode extension](vscode/) for editor integration.
|
|
91
|
+
|
|
92
|
+
### Clean generated files
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
bundle exec sv clean
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Declaring locals in partials
|
|
99
|
+
|
|
100
|
+
Use magic comments to declare partial locals and their types:
|
|
101
|
+
|
|
102
|
+
```erb
|
|
103
|
+
<%# locals: (user:, admin: false) %>
|
|
104
|
+
<%# locals_sig: sig { params(user: User, admin: T::Boolean).void } %>
|
|
105
|
+
|
|
106
|
+
<h1><%= user.name %></h1>
|
|
107
|
+
<% if admin %>
|
|
108
|
+
<p>Admin</p>
|
|
109
|
+
<% end %>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## ViewComponent support
|
|
113
|
+
|
|
114
|
+
Add `component_dirs` to your config:
|
|
115
|
+
|
|
116
|
+
```yaml
|
|
117
|
+
component_dirs:
|
|
118
|
+
- app/components
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Components using `erb_template` heredocs are automatically detected and compiled.
|
|
122
|
+
|
|
123
|
+
## Tapioca integration
|
|
124
|
+
|
|
125
|
+
SorbetView includes a Tapioca DSL compiler that generates RBI files for controller helper methods. Run:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
bundle exec tapioca dsl
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Requirements
|
|
132
|
+
|
|
133
|
+
- Ruby >= 3.2
|
|
134
|
+
- [Sorbet](https://sorbet.org/)
|
|
135
|
+
- [herb](https://herb-tools.dev/) (for fast ERB parsing)
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
MIT License. See [LICENSE](LICENSE) for details.
|
data/lib/sorbet_view/version.rb
CHANGED
data/sorbet_view.gemspec
CHANGED
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
|
8
8
|
spec.authors = ['kazuma']
|
|
9
9
|
spec.summary = 'Sorbet type-checking for Rails view templates'
|
|
10
10
|
spec.description = 'Extracts Ruby code from view templates (ERB, etc.) for Sorbet type-checking, with LSP support'
|
|
11
|
-
spec.homepage = 'https://github.com/
|
|
11
|
+
spec.homepage = 'https://github.com/kazzix14/sorbet_view'
|
|
12
12
|
spec.license = 'MIT'
|
|
13
13
|
spec.required_ruby_version = '>= 3.2'
|
|
14
14
|
|
|
@@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
|
|
|
30
30
|
spec.add_dependency 'listen', '~> 3.0'
|
|
31
31
|
spec.add_dependency 'psych'
|
|
32
32
|
spec.add_dependency 'sorbet-runtime'
|
|
33
|
-
spec.add_dependency 'srb_lens'
|
|
33
|
+
spec.add_dependency 'srb_lens', '~> 0.2.0'
|
|
34
34
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sorbet_view
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- kazuma
|
|
@@ -69,16 +69,16 @@ dependencies:
|
|
|
69
69
|
name: srb_lens
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements:
|
|
72
|
-
- - "
|
|
72
|
+
- - "~>"
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
|
-
version:
|
|
74
|
+
version: 0.2.0
|
|
75
75
|
type: :runtime
|
|
76
76
|
prerelease: false
|
|
77
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
78
78
|
requirements:
|
|
79
|
-
- - "
|
|
79
|
+
- - "~>"
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
|
-
version:
|
|
81
|
+
version: 0.2.0
|
|
82
82
|
description: Extracts Ruby code from view templates (ERB, etc.) for Sorbet type-checking,
|
|
83
83
|
with LSP support
|
|
84
84
|
executables:
|
|
@@ -87,6 +87,7 @@ extensions: []
|
|
|
87
87
|
extra_rdoc_files: []
|
|
88
88
|
files:
|
|
89
89
|
- LICENSE
|
|
90
|
+
- README.md
|
|
90
91
|
- Rakefile
|
|
91
92
|
- exe/sv
|
|
92
93
|
- lib/sorbet_view.rb
|
|
@@ -124,13 +125,13 @@ files:
|
|
|
124
125
|
- vscode/package.json
|
|
125
126
|
- vscode/src/extension.ts
|
|
126
127
|
- vscode/tsconfig.json
|
|
127
|
-
homepage: https://github.com/
|
|
128
|
+
homepage: https://github.com/kazzix14/sorbet_view
|
|
128
129
|
licenses:
|
|
129
130
|
- MIT
|
|
130
131
|
metadata:
|
|
131
132
|
rubygems_mfa_required: 'true'
|
|
132
|
-
homepage_uri: https://github.com/
|
|
133
|
-
source_code_uri: https://github.com/
|
|
133
|
+
homepage_uri: https://github.com/kazzix14/sorbet_view
|
|
134
|
+
source_code_uri: https://github.com/kazzix14/sorbet_view
|
|
134
135
|
rdoc_options: []
|
|
135
136
|
require_paths:
|
|
136
137
|
- lib
|