統合検索ページの module function 表示を ?. に統一しハイライトも修理する#281
Merged
Conversation
rurema#279 のコメント対応(2件)。vendored な search_ranker.js / search_controller.js / search_navigation.js は引き続き一切変更して いない(git diff で無改変を確認)。 1. /ja/search/ の統合インデックスで、同じ module function が版によって "Kernel.#open"(4.0 より前)と "Kernel?.open"(4.0 以降)の2行に 分かれて出ていた。SearchIndexGenerator.merge で match_name を持つ エントリの full_name の ".#" を "?." に畳んでからマージキーを 計算するようにし、現行表記の1行(版リストも合流)に統一する。 name/type/path/match_name は表記に依らず同一なので畳むだけで キーが一致する。match_name を持たない散文見出しは字面がページ 本文と一致していることに意味があるため畳まない。単一版ページ (search_init.js 経由)の表示はその版の表記のまま。 2. 修飾付きクエリ(File.open / Kernel.#open / Kernel?.open)は rurema#280 でヒットするようにはなったが、ハイライトされないままだった。 vendored の highlightMatch() は "." を "::" に書き換えた後の q.normalized を表示用 full_name と比較するため連続一致せず、 fuzzy fallback も最初の ":" で必ず脱落する。search_init.js / search_page.js に highlightMatch のラップを追加し、vendored が マークを付けられなかった場合のみ、parseQuery ラップが保存して いる q.original(生のクエリ)と表示文字列を ".#"/"?." 同一視で 突き合わせて連続一致をハイライトする。両表記とも2文字なので 畳んだ文字列のインデックスがそのまま表示文字列に流用できる。 従来ハイライトできていたクエリの挙動は不変(vendored の結果を 優先して返す)。 テスト: test_search_index_generator.rb(merge の畳み込み3件)、 test_searchpage_command.rb(実 DB 2版からの統合で ?. 1エントリに なること)、test/js/test_search.mjs(highlightMatch の両表記×両方向・ 部分一致・fuzzy 素通し・search_page.js の end-to-end・ラップ不能時の フォールバック)。全 Ruby テスト 17799 件・JS テスト・steep check green。 refs rurema#279 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.
概要
#279 のコメント対応2件です。vendored な Aliki 3本(
search_ranker.js/search_controller.js/search_navigation.js)は引き続き無改変です(git diffで確認済み)。1. /ja/search/ の表示を
?.に統一同じ module function が版によって
Kernel.#open(4.0 より前)とKernel?.open(4.0 以降)の2行に分かれて表示されていました。SearchIndexGenerator.mergeで、match_nameを持つエントリ(修飾付きメソッド)のfull_nameの.#を?.に畳んでからマージキーを計算するようにしました。name/type/path/match_nameは表記に依らず同一なので、full_nameを畳むだけで1エントリに合流し、バージョンリストも1行にまとまります(例:Kernel?.openの下に旧版〜4.1 が全部並ぶ)?.表記に揃えますmatch_nameを持たない散文見出し(字面に.#を含み得る)はページ本文の字面と一致していることに意味があるため畳みませんsearch_init.js)はその版の表記のまま(build_indexは不変更)。.#表記でのクエリは従来どおりmatch_name経由で両表記にヒットします2.
highlightMatch()の対応(search_init.js/search_page.js)#280 で修飾付きクエリはヒットするようになりましたが、ハイライトが付きませんでした。vendored の
highlightMatch()は.→::書き換え後のq.normalizedを表示用full_nameと比較するため連続一致せず、fuzzy fallback も最初の:で必ず脱落します。parseQuery/computeScoreと同じ feature-detect ラップをhighlightMatchにも追加しました:q.original(parseQuery ラップが保存している生のクエリ)と表示文字列を.#/?.同一視で突き合わせ、連続一致にハイライトマーカー(\u0001/\u0002、hlt()が<em>に変換)を挟む.#と?.はどちらも2文字なので、畳んだ文字列で求めたインデックスをそのまま表示文字列に流用できます(ズレなし)Kernel.#openのクエリでKernel?.openの行、またその逆)もハイライトされますテスト
test_search_index_generator.rb: merge の畳み込み(両表記合流・旧表記のみでも?.化・match_name無し見出しは畳まない)test_searchpage_command.rb: 実 DB 2版(3.3/4.0)からの統合でKernel?.at_exit1エントリ+出力にKernel.#非出現test/js/test_search.mjs:highlightMatchの両表記×両方向・部分一致・fuzzy 素通し・非一致時素通し、search_page.jsの end-to-end(.#クエリ →?.行が全体<em>ハイライト・最新版リンク+版リスト描画)、ラップ不能時のフォールバック(no-crash)steep checkいずれも greenbitclust searchpageを実行 →search_data.jsにKernel?.open(versions: 3.4/4.0)の1エントリのみで.#非出現refs #279
🤖 Generated with Claude Code