Class: RosettAi::Thor::Tasks::Documentation

Inherits:
Thor
  • Object
show all
Defined in:
lib/rosett_ai/thor/tasks/documentation.rb

Overview

Documentation management tasks

Constant Summary collapse

TYPE_COLORS =
{
  lib: :cyan, behaviour: :magenta, dependency: :yellow, reference: :blue
}.freeze

Instance Method Summary collapse

Instance Method Details

#statusObject



79
80
81
82
83
# File 'lib/rosett_ai/thor/tasks/documentation.rb', line 79

def status
  display_status_header
  display_doc_files
  display_configured_locales
end

#translate(source_file = nil) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/rosett_ai/thor/tasks/documentation.rb', line 110

def translate(source_file = nil)
  files = source_file ? [source_file] : Dir.glob(RosettAi.root.join('doc', '*.md'))

  translator = RosettAi::Documentation::Translator.new

  files.each do |file|
    unless File.exist?(file)
      puts Rainbow(t('translate_source_missing', path: file)).red
      next
    end

    result = translator.translate(file, from: options[:from], to: options[:to])
    puts Rainbow(t('translate_done', path: result)).green
  end
end

#updateObject



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rosett_ai/thor/tasks/documentation.rb', line 56

def update
  changes = scan_with_spinner
  return puts Paint[t('no_updates'), :yellow] if changes.empty?

  display_changes(changes)
  return if options[:dry_run]

  reference_changes, locale_changes = changes.partition { |change| change[:type] == :reference }
  reference_changes.each { |_change| compile_reference_document! }
  apply_changes_with_spinner(locale_changes) unless locale_changes.empty?
end