Class: YARD::CLI::I18n
- Inherits:
-
Yardoc
- Object
- Command
- YardoptsCommand
- Yardoc
- YARD::CLI::I18n
- Defined in:
- lib/yard/cli/i18n.rb
Overview
TODO:
Support msgminit and msgmerge features?
CLI command to support internationalization (a.k.a. i18n). I18n feature is based on gettext technology. This command generates .pot file from docstring and extra documentation.
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize ⇒ I18n
constructor
A new instance of I18n.
- #run(*args) ⇒ Object
Constructor Details
#initialize ⇒ I18n
Returns a new instance of I18n.
14 15 16 17 |
# File 'lib/yard/cli/i18n.rb', line 14 def initialize super @options.serializer.basepath = "po/yard.pot" end |
Instance Method Details
#description ⇒ Object
19 20 21 |
# File 'lib/yard/cli/i18n.rb', line 19 def description 'Generates .pot file from source code and extra documentation' end |
#run(*args) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/yard/cli/i18n.rb', line 23 def run(*args) if args.empty? || !args.first.nil? # fail early if arguments are not valid return unless parse_arguments(*args) end YARD.parse(files, excluded) serializer = .serializer pot_file_path = Pathname.new(serializer.basepath). pot_file_dir_path, pot_file_basename = pot_file_path.split relative_base_path = Pathname.pwd.relative_path_from(pot_file_dir_path) serializer.basepath = pot_file_dir_path.to_s serializer.serialize(pot_file_basename.to_s, generate_pot(relative_base_path.to_s)) true end |