docscribe 1.6.0 → 1.6.2
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 +76 -193
- data/exe/docscribe-client +26 -7
- data/lib/docscribe/cli/config_builder.rb +37 -2
- data/lib/docscribe/cli/coverage.rb +5 -5
- data/lib/docscribe/cli/formatters/json.rb +74 -29
- data/lib/docscribe/cli/formatters/sarif.rb +20 -3
- data/lib/docscribe/cli/options.rb +17 -2
- data/lib/docscribe/cli/rbs_gen.rb +4 -4
- data/lib/docscribe/cli/run.rb +107 -24
- data/lib/docscribe/cli/update_types.rb +61 -17
- data/lib/docscribe/cli.rb +19 -13
- data/lib/docscribe/config/defaults.rb +1 -0
- data/lib/docscribe/config/rbs.rb +22 -1
- data/lib/docscribe/config/template.rb +3 -0
- data/lib/docscribe/config/validation.rb +19 -0
- data/lib/docscribe/config.rb +1 -0
- data/lib/docscribe/infer/behavior.rb +13 -13
- data/lib/docscribe/infer/params.rb +2 -2
- data/lib/docscribe/infer/raises.rb +5 -6
- data/lib/docscribe/infer/returns.rb +1612 -151
- data/lib/docscribe/infer.rb +7 -7
- data/lib/docscribe/inline_rewriter/doc_builder.rb +485 -102
- data/lib/docscribe/inline_rewriter.rb +263 -97
- data/lib/docscribe/plugin/registry.rb +1 -0
- data/lib/docscribe/server/base.rb +255 -0
- data/lib/docscribe/server/client.rb +95 -0
- data/lib/docscribe/server/daemon.rb +678 -0
- data/lib/docscribe/server/protocol.rb +50 -0
- data/lib/docscribe/server.rb +4 -835
- data/lib/docscribe/types/primitive.rb +160 -0
- data/lib/docscribe/types/sorbet/base_provider.rb +33 -1
- data/lib/docscribe/types/yard/formatter.rb +35 -6
- data/lib/docscribe/types/yard/parser.rb +25 -20
- data/lib/docscribe/types/yard/validator.rb +131 -0
- data/lib/docscribe/validator/generic_compatibility.rb +698 -0
- data/lib/docscribe/validator/type_mismatch_validator.rb +287 -0
- data/lib/docscribe/version.rb +1 -1
- metadata +12 -3
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'json'
|
|
4
|
+
require 'securerandom'
|
|
5
|
+
|
|
6
|
+
module Docscribe
|
|
7
|
+
module Server
|
|
8
|
+
# JSON-line protocol helpers.
|
|
9
|
+
module Protocol
|
|
10
|
+
module_function
|
|
11
|
+
|
|
12
|
+
# Build a JSON-RPC request hash.
|
|
13
|
+
#
|
|
14
|
+
# @note module_function: defines #build_request (visibility: private)
|
|
15
|
+
# @param [String] method method name
|
|
16
|
+
# @param [Hash<Symbol, T>] params request parameters
|
|
17
|
+
# @return [Hash<Symbol, String, Hash<Symbol, T>>]
|
|
18
|
+
def build_request(method, params = {})
|
|
19
|
+
{
|
|
20
|
+
jsonrpc: '2.0',
|
|
21
|
+
id: SecureRandom.hex(8),
|
|
22
|
+
method: method,
|
|
23
|
+
params: params
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Parse a single JSON-line response.
|
|
28
|
+
#
|
|
29
|
+
# @note module_function: defines #parse_response (visibility: private)
|
|
30
|
+
# @param [String] line raw JSON line
|
|
31
|
+
# @raise [JSON::ParserError]
|
|
32
|
+
# @return [Hash<String, Object>?]
|
|
33
|
+
# @return [nil] if JSON::ParserError
|
|
34
|
+
def parse_response(line)
|
|
35
|
+
JSON.parse(line)
|
|
36
|
+
rescue JSON::ParserError
|
|
37
|
+
nil
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Serialize a hash to a JSON line.
|
|
41
|
+
#
|
|
42
|
+
# @note module_function: defines #serialize (visibility: private)
|
|
43
|
+
# @param [Object] hash
|
|
44
|
+
# @return [String]
|
|
45
|
+
def serialize(hash)
|
|
46
|
+
"#{JSON.generate(hash)}\n"
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|