Class: Packnga::DocumentTask

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/packnga/document-task.rb

Overview

This class creates tasks for document. They generate YARD document or references.

Since:

  • 0.9.0

Instance Method Summary collapse

Constructor Details

#initialize(spec) {|_self| ... } ⇒ DocumentTask

Defines tasks to generate YARD documentation and to translate references.

Parameters:

  • spec (Gem::Specification)

    specification for your package

Yields:

  • (_self)

Yield Parameters:

Since:

  • 0.9.0



33
34
35
36
37
38
39
40
# File 'lib/packnga/document-task.rb', line 33

def initialize(spec)
  @spec = spec
  @yard_task = YARDTask.new(@spec)
  @reference_task = ReferenceTask.new(@spec)
  self.base_dir = "doc"
  yield(self) if block_given?
  define
end

Instance Method Details

#base_dir=(dir) ⇒ Object

Sets base directory for documents. Default value is “doc”.

Parameters:

  • dir (String)

    base direcory path

Since:

  • 0.9.0



44
45
46
47
48
# File 'lib/packnga/document-task.rb', line 44

def base_dir=(dir)
  dir = Pathname.new(dir)
  @yard_task.base_dir = dir
  @reference_task.base_dir = dir
end

#original_language=(language) ⇒ Object

Sets original language which you wrote document. Default value is “en” (as English). Specified value is used to define language for translation.

Parameters:

  • language (String)

    language you wrote document

See Also:

Since:

  • 0.9.6



58
59
60
# File 'lib/packnga/document-task.rb', line 58

def original_language=(language)
  @reference_task.original_language = language
end

#reference {|@reference_task| ... } ⇒ Object

Runs block to tasks for references.

Yields:

  • (@reference_task)

Since:

  • 0.9.0



116
117
118
# File 'lib/packnga/document-task.rb', line 116

def reference
  yield(@reference_task)
end

#translate_language=(language) ⇒ Object

Sets a translate language for document. This method receives String as language code.

If the language specified by #original_language= isn’t English, its default value is one. Otherwise, it is not specified.

Examples:

Specify Japanese.

DocumentTask.new(spec) do |task|
  task.translate_language = "ja"
end

Parameters:

  • language (String)

    target language code for translated document

See Also:

Since:

  • 0.9.7



83
84
85
# File 'lib/packnga/document-task.rb', line 83

def translate_language=(language)
  self.translate_languages = [language]
end

#translate_languages=(languages) ⇒ Object

Sets translate languages for document. This method receives Array of Strings as each language code.

If the language specified by #original_language= isn’t English, its default value is one. Otherwise, it is not specified.

Examples:

Sets Japanese and English.

DocumentTask.new(spec) do |task|
  task.translate_languages = ["ja", "en"]
end

Parameters:

  • languages (Array<String>)

    target language codes for translated document

See Also:

Since:

  • 0.9.6



106
107
108
# File 'lib/packnga/document-task.rb', line 106

def translate_languages=(languages)
  @reference_task.translate_languages = languages
end

#yard {|@yard_task| ... } ⇒ Object

Runs block to task for YARD documentation.

Yields:

  • (@yard_task)

Since:

  • 0.9.0



111
112
113
# File 'lib/packnga/document-task.rb', line 111

def yard
  yield(@yard_task)
end