Module: VivlioStarter::CLI::IndexCommands
- Defined in:
- lib/vivlio_starter/cli/index.rb,
lib/vivlio_starter/cli/index/term_line.rb,
lib/vivlio_starter/cli/index/term_spread.rb,
lib/vivlio_starter/cli/index/term_pattern.rb,
lib/vivlio_starter/cli/index/term_ranking.rb,
lib/vivlio_starter/cli/index/index_library.rb,
lib/vivlio_starter/cli/index/yomi_inferrer.rb,
lib/vivlio_starter/cli/index/main_reference.rb,
lib/vivlio_starter/cli/index/scoring_engine.rb,
lib/vivlio_starter/cli/index/yomi_overrides.rb,
lib/vivlio_starter/cli/index/heading_outline.rb,
lib/vivlio_starter/cli/index/hierarchical_index.rb,
lib/vivlio_starter/cli/index/code_block_stripper.rb,
lib/vivlio_starter/cli/index/index_match_scanner.rb,
lib/vivlio_starter/cli/index/index_plan_reporter.rb,
lib/vivlio_starter/cli/index/index_size_estimator.rb,
lib/vivlio_starter/cli/index/unified_page_builder.rb,
lib/vivlio_starter/cli/index/main_reference_suggester.rb,
lib/vivlio_starter/cli/index/index_candidate_extractor.rb
Overview
================================================================
Module: IndexCommands
索引機能のヘルパーメソッドを提供 CLI コマンド本体は samovar/index_command.rb で定義
Defined Under Namespace
Modules: CodeBlockStripper, TermPattern, YomiOverrides Classes: HeadingOutline, HierarchicalIndex, IndexCandidateExtractor, IndexLibrary, IndexMatchScanner, IndexPlanReporter, IndexSizeEstimator, MainReference, MainReferenceSuggester, ScoringEngine, TermLine, TermRanking, TermSpread, 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
40 41 42 43 |
# File 'lib/vivlio_starter/cli/index/index_match_scanner.rb', line 40 def self.() @post_build_messages ||= [] @post_build_messages << unless @post_build_messages.include?() end |
.emit_index_message(message, use_log_warn: true) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/vivlio_starter/cli/index/index_match_scanner.rb', line 55 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.sub(/\A🟡\s*/, '')) else Common.log_always(text) end end end |
.flush_post_build_messages ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/vivlio_starter/cli/index/index_match_scanner.rb', line 45 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
索引・用語集機能が有効かどうか
55 56 57 |
# File 'lib/vivlio_starter/cli/index.rb', line 55 def index_enabled? Common::CONFIG.index_glossary.enabled == true end |
.process_index_for_build!(chapters) ⇒ Object
ビルドパイプラインから呼び出される索引・用語集処理
46 47 48 49 50 51 52 |
# File 'lib/vivlio_starter/cli/index.rb', line 46 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
対象章を解決
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/vivlio_starter/cli/index.rb', line 61 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 |