Markdown 対応で追加されたコードに RBS 型定義を付ける#231
Merged
Merged
Conversation
rake sig(rbs subtract)が検出する型定義の不足を解消する:
- Markdown 対応で追加された 13 ファイル分の sig を新規作成
(mdparser, mdcompiler, markdown_to_rrd, rrd_to_markdown,
markdown_tree, markdown_bridge, markdown_orchestrator,
include_graph, include_pruner, entity_splitter, whole_file_gate,
capi_converter, doc_converter)
- 既存クラスに追加された markdown 系メンバーを既存 sig へ追記
(MethodDatabase#update_by_markdowntree・copy_doc_md、
TemplateScreen#markdown_source?・html_base、
UpdateCommand#prepare_markdowntree ほか、
StatichtmlCommand#create_search_index・SEARCH_JS_FILES)
- database_propkey へ 'source_format' を追加、Rouge の最小スタブを追加、
RDCompiler::option の :catalog を実装に合わせて省略可へ、
Location の line を Integer? へ(line 不明の Location があるため)
steep check をエラー 0・警告 0 にする(従来はエラー 471・警告 317):
- マッチ直後で非 nil が保証される $1 等の参照は
既存慣行の ($1 || raise) 形に揃える
- steep が推論できない空リテラルやブロック越し代入には
インライン型注釈(#: / @type var)を付ける
- File.write(Pathname, ...) → Pathname#write 等、
rbs core の型が受けない等価な呼び出しを書き換える
挙動の変更はない(テスト 17589 件 green・rbs validate / rake sig 通過)。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
znz
added a commit
that referenced
this pull request
Jul 11, 2026
#231 で sig/ が lib/ の全宣言をカバーし steep check がエラー0・警告0に なったので、退行を防ぐため CI に typecheck ジョブを追加する: - rake rbs:install(rbs_collection.lock.yaml で固定された collection を取得) - rake sig(rbs prototype → rbs subtract の残余ゼロ = sig 網羅の検査 + rbs validate) - steep check Ruby は最新安定版の 3.4 固定(バージョン網羅は build ジョブが担う)。 rbs / steep のバージョンは Gemfile.lock(rbs 3.10.3 / steep 1.9.4)で 再現される。 あわせて doctree と同様に、ドキュメント(doc/・README.md・ChangeLog) だけの変更では既存ジョブ含め CI を回さないようにする。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
解決したい問題
Markdown 移行(#189 以降)で追加されたコードに RBS 型定義が無く、
型検査の網羅性チェックである
rake sigが失敗する状態でした(
rbs subtractの残余が 18 ファイル分)。steep checkもエラー 471 件・警告 317 件を報告しており、そのほぼ全てが
markdown 対応の型付け漏れ由来でした(新規クラスの宣言欠落、
既存クラスに追加された markdown 系メソッドの sig 未追記、およびその波及)。
変更内容
sig の新規作成(13 ファイル)
markdown パイプラインの全クラスを既存 sig と同じ流儀
(ivar 宣言・
private対応・typeエイリアス・実型優先)で型付けしました:mdparser(MDParser / MDFunctionParser)、mdcompilermarkdown_to_rrd、rrd_to_markdown、capi_converter、doc_convertermarkdown_tree、markdown_bridge、markdown_orchestratorinclude_graph、include_pruner、entity_splitter、whole_file_gateuntypedは本当に動的な箇所(混在 arity のトークン列など)だけに限定し、理由をコメントで残しています。
既存 sig への追記・修正
MethodDatabase#update_by_markdowntree/#copy_doc_md、FunctionDatabase#update_by_markdowntree、TemplateScreen#markdown_source?/#html_base、UpdateCommand#prepare_markdowntreeほか、StatichtmlCommand#create_search_index/SEARCH_JS_FILESdatabase_propkeyに'source_format'を追加sig/rouge.rbsを追加(Rouge を導入して ruby 以外の言語のシンタックスハイライトに対応する #223 で導入したLexer.find/tag/lexとFormatters::HTML#formatのみ)RDCompiler::optionの:catalogを省略可へ(実装はフォールバック持ち)、LocationのlineをInteger?へ(行不明の Location が実在)、Entry#display_text/#description_textをオーバーロード化(
(String) -> String | (String?) -> String?)、searchpage_command.rbs の型名修飾漏れ(
argv→Subcommand::argv。これが原因で同ファイルの lib 側チェック自体が走っていませんでした)
lib 側(挙動の変更はありません)
$1等の参照・Array の Range スライスは、コードベース既存慣行の
($1 || raise)形に統一(rrdparser.rb に先例)(
#: Array[String]/# @type var)を追加#: 型注釈の直後に説明文が続いて注釈のパースが壊れていた既存 2 箇所を修復(説明文を前行コメントへ分離)
File.read/File.writeをPathname#read/#writeに書き換え(searchpage_command)検証
bundle exec rake sigbundle exec steep checkbundle exec rbs validateruby test/run_test.rb🤖 Generated with Claude Code