Class: YARD::CLI::I18n
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
YARD::CLI::Yardoc
|
Defined in: | lib/yard/cli/i18n.rb |
Overview
Support msgminit and msgmerge features?
::YARD::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.
Constant Summary
YardoptsCommand
- Inherited
Class Method Summary
- .new ⇒ I18n constructor
Yardoc
- Inherited
.new | Creates a new instance of the commandline utility. |
YardoptsCommand
- Inherited
.new | Creates a new command that reads .yardopts. |
Command
- Inherited
.run | Helper method to run the utility on an instance. |
Instance Attribute Summary
Yardoc
- Inherited
#apis | Keep track of which APIs are to be shown. |
#assets, #excluded, #fail_on_warning, #files, #generate, #has_markup, | |
#hidden_apis | Keep track of which APIs are to be hidden. |
#hidden_tags, #list, #options, #save_yardoc, #statistics, #use_cache, | |
#visibilities | Keep track of which visibilities are to be shown. |
YardoptsCommand
- Inherited
#options_file | The options file name (defaults to |
#use_document_file, #use_yardopts_file |
Instance Method Summary
Yardoc
- Inherited
#all_objects | The list of all objects to process. |
#description, | |
#parse_arguments | Parses commandline arguments. |
#run | Runs the commandline utility, parsing arguments and generating output if set. |
#add_api_verifier | Adds verifier rule for APIs. |
#add_extra_files | Adds a set of extra documentation files to be processed. |
#add_tag, | |
#add_visibility_verifier | Adds verifier rule for visibilities. |
#apply_locale | Applies the specified locale to collected objects. |
#copy_assets | Copies any assets to the output directory. |
#extra_file_valid?, | |
#general_options | Adds general options. |
#optparse | Parses commandline options. |
#output_options | Adds output options. |
#parse_files | Parses the file arguments into Ruby files and extra files, which are separated by a '-' element. |
#print_list | Prints a list of all objects. |
#run_generate | Generates output for objects. |
#run_verifier | Runs a list of objects against the |
#tag_options | Adds tag options. |
#verify_markup_options | Verifies that the markup options are valid before parsing any code. |
YardoptsCommand
- Inherited
#parse_arguments | Parses commandline arguments. |
#parse_rdoc_document_file, #parse_yardopts, | |
#parse_yardopts_options | Parses out the yardopts/document options. |
#support_rdoc_document_file! | Reads a .document file in the directory to get source file globs. |
#yardopts | Parses the .yardopts file for default yard options. |
Command
- Inherited
Constructor Details
.new ⇒ I18n
# File 'lib/yard/cli/i18n.rb', line 14
def initialize super @options.serializer.basepath = "po/yard.pot" end
Instance Method Details
#description
# File 'lib/yard/cli/i18n.rb', line 19
def description 'Generates .pot file from source code and extra documentation' end
#general_options(opts) (private)
# File 'lib/yard/cli/i18n.rb', line 44
def (opts) opts. = "Usage: yard i18n [options] [source_files [- extra_files]]" opts.top.list.clear opts.separator "(if a list of source files is omitted, " opts.separator " {lib,app}/**/*.rb ext/**/*.{c,rb} is used.)" opts.separator "" opts.separator "Example: yard i18n -o yard.pot - FAQ LICENSE" opts.separator " The above example outputs .pot file for files in" opts.separator " lib/**/*.rb to yard.pot including the extra files" opts.separator " FAQ and LICENSE." opts.separator "" opts.separator "A base set of options can be specified by adding a .yardopts" opts.separator "file to your base path containing all extra options separated" opts.separator "by whitespace." super(opts) end
#generate_pot(relative_base_path) (private)
# File 'lib/yard/cli/i18n.rb', line 61
def generate_pot(relative_base_path) generator = YARD::I18n::PotGenerator.new(relative_base_path) objects = run_verifier(all_objects) generator.parse_objects(objects) generator.parse_files( .files || []) generator.generate end
#run(*args)
# 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