Class: RosettAi::Thor::Tasks::Documentation
- Inherits:
-
Thor
- Object
- Thor
- RosettAi::Thor::Tasks::Documentation
- Defined in:
- lib/rosett_ai/thor/tasks/documentation.rb
Overview
Documentation management tasks
Constant Summary collapse
- TYPE_COLORS =
Returns Terminal color codes for documentation types.
{ lib: :cyan, behaviour: :magenta, dependency: :yellow, reference: :blue }.freeze
Instance Method Summary collapse
-
#status ⇒ String
Return the current status.
-
#translate(source_file = nil) ⇒ void
Translate documentation to the target locale.
-
#update ⇒ void
Update to the latest version.
Instance Method Details
#status ⇒ String
Return the current status.
84 85 86 87 88 |
# File 'lib/rosett_ai/thor/tasks/documentation.rb', line 84 def status display_status_header display_doc_files display_configured_locales end |
#translate(source_file = nil) ⇒ void
This method returns an undefined value.
Translate documentation to the target locale.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/rosett_ai/thor/tasks/documentation.rb', line 117 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: [:from], to: [:to]) puts Rainbow(t('translate_done', path: result)).green end end |
#update ⇒ void
This method returns an undefined value.
Update to the latest version.
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rosett_ai/thor/tasks/documentation.rb', line 59 def update changes = scan_with_spinner return puts Paint[t('no_updates'), :yellow] if changes.empty? display_changes(changes) return if [: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 |