Class: YARD::CLI::I18n

Inherits:
Yardoc show all
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.

Since:

  • 0.8.0

Constant Summary

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeI18n

Returns a new instance of I18n

Since:

  • 0.8.0



13
14
15
16
# File 'lib/yard/cli/i18n.rb', line 13

def initialize
  super
  @options.serializer.basepath = "po/yard.pot"
end

Instance Attribute Details

#apisArray<String> Originally defined in class Yardoc

Keep track of which APIs are to be shown

Returns:

Since:

  • 0.8.1

#assetsArray<String> Originally defined in class Yardoc

Returns a list of assets to copy after generation

Returns:

  • (Array<String>)

    a list of assets to copy after generation

Since:

  • 0.6.0

#excludedArray<String> Originally defined in class Yardoc

Returns list of excluded paths (regexp matches)

Returns:

  • (Array<String>)

    list of excluded paths (regexp matches)

Since:

  • 0.5.3

#filesArray<String> Originally defined in class Yardoc

Returns list of Ruby source files to process

Returns:

  • (Array<String>)

    list of Ruby source files to process

Since:

  • 0.2.1

#generateBoolean Originally defined in class Yardoc

Returns whether to generate output

Returns:

  • (Boolean)

    whether to generate output

Since:

  • 0.2.1

#has_markupBoolean Originally defined in class Yardoc

Returns whether markup option was specified

Returns:

  • (Boolean)

    whether markup option was specified

Since:

  • 0.7.0

#hidden_apisArray<String> Originally defined in class Yardoc

Keep track of which APIs are to be hidden

Returns:

Since:

  • 0.8.7

#hidden_tagsArray<Symbol> Originally defined in class Yardoc

Returns a list of tags to hide from templates

Returns:

  • (Array<Symbol>)

    a list of tags to hide from templates

Since:

  • 0.6.0

#listBoolean Originally defined in class Yardoc

Returns whether to print a list of objects

Returns:

  • (Boolean)

    whether to print a list of objects

Since:

  • 0.5.5

#optionsHash (readonly) Originally defined in class Yardoc

Returns the hash of options passed to the template.

Returns:

  • (Hash)

    the hash of options passed to the template.

See Also:

  • Templates::Engine#render

Since:

  • 0.2.1

#options_fileString Originally defined in class YardoptsCommand

The options file name (defaults to DEFAULT_YARDOPTS_FILE)

Returns:

  • (String)

    the filename to load extra options from

Since:

  • 0.8.3

#save_yardocBoolean Originally defined in class Yardoc

Returns whether objects should be serialized to .yardoc db

Returns:

  • (Boolean)

    whether objects should be serialized to .yardoc db

Since:

  • 0.2.1

#statisticsBoolean Originally defined in class Yardoc

Returns whether to print statistics after parsing

Returns:

  • (Boolean)

    whether to print statistics after parsing

Since:

  • 0.6.0

#use_cacheBoolean Originally defined in class Yardoc

Returns whether to use the existing yardoc db if the .yardoc already exists. Also makes use of file checksums to parse only changed files.

Returns:

  • (Boolean)

    whether to use the existing yardoc db if the .yardoc already exists. Also makes use of file checksums to parse only changed files.

Since:

  • 0.2.1

#use_document_fileBoolean Originally defined in class YardoptsCommand

Returns whether to parse options from .document

Returns:

  • (Boolean)

    whether to parse options from .document

Since:

  • 0.8.3

#use_yardopts_fileBoolean Originally defined in class YardoptsCommand

Returns whether to parse options from .yardopts

Returns:

  • (Boolean)

    whether to parse options from .yardopts

Since:

  • 0.8.3

#visibilitiesArray<Symbol> Originally defined in class Yardoc

Keep track of which visibilities are to be shown

Returns:

  • (Array<Symbol>)

    a list of visibilities

Since:

  • 0.5.6

Instance Method Details

#descriptionObject

Since:

  • 0.8.0



18
19
20
# File 'lib/yard/cli/i18n.rb', line 18

def description
  'Generates .pot file from source code and extra documentation'
end

#run(*args) ⇒ Object

Since:

  • 0.8.0



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/yard/cli/i18n.rb', line 22

def run(*args)
  if args.size == 0 || !args.first.nil?
    # fail early if arguments are not valid
    return unless parse_arguments(*args)
  end

  YARD.parse(files, excluded)

  serializer = options.serializer
  pot_file_path = Pathname.new(serializer.basepath).expand_path
  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