Module: Vivlio::Starter::CLI::IndexCommands
- Defined in:
- lib/vivlio/starter/cli/index.rb,
lib/vivlio/starter/cli/index/yomi_inferrer.rb,
lib/vivlio/starter/cli/index/scoring_engine.rb,
lib/vivlio/starter/cli/index/hierarchical_index.rb,
lib/vivlio/starter/cli/index/index_match_scanner.rb,
lib/vivlio/starter/cli/index/unified_page_builder.rb,
lib/vivlio/starter/cli/index/index_candidate_extractor.rb
Overview
Module: IndexCommands
索引機能のヘルパーメソッドを提供CLI コマンド本体は samovar/index_command.rb で定義
Defined Under Namespace
Classes: HierarchicalIndex, IndexCandidateExtractor, IndexMatchScanner, ScoringEngine, UnifiedPageBuilder, YomiInferrer
Constant Summary collapse
- INDEX_TERMS_MISSING_MESSAGE =
<<~MSG 索引語辞書(config/index_glossary_terms.yml)が見つかりませんでした ⚠️ 原稿に [用語|読み] という書き方で手動登録した語のみが索引に載ります ⚠️ 自動索引機能を有効にするには: vs index:auto -> vs index:apply MSG
Class Method Summary collapse
- .add_post_build_message(message) ⇒ Object
- .emit_index_message(message, use_log_warn: true) ⇒ Object
- .flush_post_build_messages ⇒ Object
-
.index_enabled? ⇒ Boolean
索引・用語集機能が有効かどうか(シンボルキー前提).
-
.process_index_for_build!(chapters) ⇒ Object
ビルドパイプラインから呼び出される索引・用語集処理.
-
.resolve_chapters(tokens) ⇒ Object
対象章を解決.
Class Method Details
.add_post_build_message(message) ⇒ Object
34 35 36 37 |
# File 'lib/vivlio/starter/cli/index/index_match_scanner.rb', line 34 def self.() @post_build_messages ||= [] @post_build_messages << unless @post_build_messages.include?() end |
.emit_index_message(message, use_log_warn: true) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/vivlio/starter/cli/index/index_match_scanner.rb', line 49 def self.(, use_log_warn: true) .each_line do |line| text = line.rstrip next if text.empty? if use_log_warn Common.log_warn(text) else Common.log_always(text) end end end |
.flush_post_build_messages ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/vivlio/starter/cli/index/index_match_scanner.rb', line 39 def self. return if @post_build_messages.nil? || @post_build_messages.empty? @post_build_messages.each do || (, use_log_warn: false) end @post_build_messages.clear end |
.index_enabled? ⇒ Boolean
索引・用語集機能が有効かどうか(シンボルキー前提)
56 57 58 |
# File 'lib/vivlio/starter/cli/index.rb', line 56 def index_enabled? Common::CONFIG.index_glossary&.enabled == true end |
.process_index_for_build!(chapters) ⇒ Object
ビルドパイプラインから呼び出される索引・用語集処理
47 48 49 50 51 52 53 |
# File 'lib/vivlio/starter/cli/index.rb', line 47 def process_index_for_build!(chapters) return unless index_enabled? require_relative 'index/unified_index_manager' manager = UnifiedIndexManager.new manager.build_index!(chapters) end |
.resolve_chapters(tokens) ⇒ Object
対象章を解決
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/vivlio/starter/cli/index.rb', line 62 def resolve_chapters(tokens) resolver = TokenResolver::Resolver.new entries = resolver.resolve(tokens) if entries.any? basenames = entries.select(&:valid?).map(&:basename) Common.log_info("引数から対象章を特定しました: #{basenames.join(', ')}") basenames else begin require_relative 'build/catalog_loader' chapters = Build::CatalogLoader.load_existing_basenames Common.log_info("catalog.yml から対象章を特定しました: #{chapters.size} 章") chapters rescue StandardError => e Common.log_warn("catalog.yml の読み込みに失敗したため、全 Markdown ファイルを対象にします: #{e.}") chapters = Dir.glob('*.md').map { |f| File.basename(f, '.md') }.sort Common.log_info("カレントディレクトリの全ファイルを対象にします: #{chapters.size} 章") chapters end end end |