From 387cd96c3b8ba5e7343a53898870fddf6bfdb8e5 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Fri, 24 Jul 2026 15:24:55 +0900 Subject: [PATCH] =?UTF-8?q?meta=20description=20=E3=81=AE=20module=20funct?= =?UTF-8?q?ion=20=E5=8F=82=E7=85=A7=E3=82=82=204.0=20=E4=BB=A5=E9=99=8D?= =?UTF-8?q?=E3=81=AF=20=3F.=20=E3=81=A7=E8=A1=A8=E7=A4=BA=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Entry#description_text(meta description など、コンパイラを通さない表示 テキスト)は、[[m:Kernel.#mf]] のような参照からラベルを取り出す際に ".#" をそのまま出力していた。可視ページの参照は bitclust#282/#283 で DB バージョン 4.0 以降は "?." 表示に切り替わるが、この経路だけ ".#" の まま残っていた。 RDCompiler#display_spec と同じく NameUtils.display_typemark を使って、 バージョン 4.0 以降は ".#" を "?." に畳んで表示する。spec・URL・ アンカーキーなどの識別子は不変。 Co-Authored-By: Claude Opus 4.8 (1M context) --- lib/bitclust/entry.rb | 8 +++++++- test/test_methodentry.rb | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/lib/bitclust/entry.rb b/lib/bitclust/entry.rb index edc0375..07230ac 100644 --- a/lib/bitclust/entry.rb +++ b/lib/bitclust/entry.rb @@ -175,11 +175,17 @@ def display_text(text) def description_text(text) text = display_text(text) return text unless text + # module function の ".#" は表示専用なので、DB バージョンが 4.0 以降なら + # "?." で表示する(RDCompiler#display_spec と同じ #250/#282 の規則。 + # ここは可視ページを通さない meta description 用の経路なので、bracket_link + # と同じ変換を独立に適用する必要がある。spec・URL・アンカーキーは不変) + version = @db&.propget('version') text = text.split("\n").map(&:strip).join("\n") .gsub(/(\P{ascii})\n(?=\P{ascii})/) { $1 || raise } .tr("\n", ' ') text.gsub(BracketLink) {|link| - ((link[2..-3] || raise).split(':', 2).last || raise).rstrip + label = ((link[2..-3] || raise).split(':', 2).last || raise).rstrip + label.include?('.#') ? label.sub('.#', NameUtils.display_typemark('.#', version)) : label } end private :description_text diff --git a/test/test_methodentry.rb b/test/test_methodentry.rb index 2072d7a..6742226 100644 --- a/test/test_methodentry.rb +++ b/test/test_methodentry.rb @@ -148,6 +148,39 @@ def test_instance_method_and_special_variable_display_are_unaffected_by_version end end +# meta description(コンパイラを通さない表示テキスト)内の module function +# 参照 [[m:Kernel.#mf2]] のラベルも、可視ページの bracket_link と同様に +# DB バージョン 4.0 以降では "?." で表示する(bitclust#282/#283 の続き。 +# 従来この経路だけ ".#" のまま残っていた) +class TestMethodEntryDescriptionQdot < Test::Unit::TestCase + SRC = < version}) + db.get_method(BitClust::MethodSpec.parse('Kernel.#mf')).description + end + + def test_meta_description_keeps_dot_hash_before_4_0 + assert_equal('Kernel.#mf2 を参照してください。', description('3.4')) + end + + def test_meta_description_uses_question_dot_at_4_0 + assert_equal('Kernel?.mf2 を参照してください。', description('4.0')) + end +end + # メソッド名別の since/until (bitclust#132 P1)。 # # テストリスト: