This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# | |
# rbs-inline のパーサを拡張し、def_delegator 文に対応させるハックのサンプル。 | |
# | |
# デフォルトでは -> untyped なメソッドが生成される。 | |
# 後置コメントを使うと返り値が指定できる。 | |
# | |
# 例: | |
# def_delegator :foo, :bar #: String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pbcopyd.rb - A pbcopy/pbpaste server | |
# | |
# Usage: | |
# ruby pbcopyd.rb [-d] [-h HOSTNAME] [-p PORT] | |
# | |
# pbcopy from remote: | |
# curl -X POST -d 'Hello, World!' http://host.docker.internal:12345 | |
# | |
# pbpaste to remote: | |
# curl -s http://host.docker.internal:12345 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'pathname' | |
require 'rbs' | |
require 'rbs/prototype/rb' | |
module RBS | |
module Prototype | |
class RB | |
alias process_orig process |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# | |
# RBS::Location を marshal 可能にする試み。 | |
# ダンプサイズを減らし、load 後のメモリ使用量を抑える目的で、RBS::Buffer はそのままダンプせず、 | |
# ロード時に .rbs ファイルを再読み込みするようにしている。 | |
# | |
# marhsal キャッシュ導入前: | |
# 3.80s, 3.58s, 3.65s | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# | |
# RBS loading optimizer | |
# | |
# Usage: require 'rbs_optimizer' in your .irbrc | |
# | |
require 'rbs' | |
require 'rbs/cli' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/rbs/prototype/rb.rb b/lib/rbs/prototype/rb.rb | |
index 646ed909..628e9878 100644 | |
--- a/lib/rbs/prototype/rb.rb | |
+++ b/lib/rbs/prototype/rb.rb | |
@@ -109,8 +109,26 @@ module RBS | |
# Give up detect super class e.g. `class Foo < Struct.new(:bar)` | |
nil | |
end | |
+ | |
+ const_to_name!(class_name).namespace.ascend.reject(&:empty?).reverse_each do |module_name| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/rbs/prototype/rb.rb b/lib/rbs/prototype/rb.rb | |
index 646ed909..3667d7dc 100644 | |
--- a/lib/rbs/prototype/rb.rb | |
+++ b/lib/rbs/prototype/rb.rb | |
@@ -5,11 +5,11 @@ module RBS | |
class RB | |
include Helpers | |
- Context = _ = Struct.new(:module_function, :singleton, :namespace, keyword_init: true) do | |
+ Context = _ = Struct.new(:module_function, :singleton, :namespace, :in_block, keyword_init: true) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/rbs/prototype/rb.rb b/lib/rbs/prototype/rb.rb | |
index 646ed909..cbbf4b80 100644 | |
--- a/lib/rbs/prototype/rb.rb | |
+++ b/lib/rbs/prototype/rb.rb | |
@@ -347,10 +347,33 @@ module RBS | |
end | |
when :ITER | |
- method_name = node.children.first.children.first | |
- case method_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# リテラルスタイルのアンカーを作る | |
# | |
# 使い方: | |
# * :codehref:`blah blah blah <http://path.to/anywhere>` | |
# * :codehref:`blah \`\`blah\`\` blah <http://path.to/anywhere>` | |
# | |
from docutils import nodes | |
from sphinx.util.docutils import ReferenceRole | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# リテラルスタイルのアンカーを作る | |
# | |
# 使い方: :codehref:`blah blah blah <http://path.to/anywhere>` | |
# | |
from docutils import nodes | |
from sphinx.util.docutils import ReferenceRole | |
class CodeHref(ReferenceRole): | |
def run(self): |
NewerOlder