Class: TaskJuggler::RichTextFunctionExample

Inherits:
RichTextFunctionHandler show all
Defined in:
lib/taskjuggler/RichText/FunctionExample.rb

Overview

This class is a specialized RichTextFunctionHandler that turns references to TJP example code in the test/TestSuite/Syntax/Correct directory into embedded example code. It currently only supports HTML.

Instance Attribute Summary

Attributes inherited from RichTextFunctionHandler

#blockFunction, #function

Instance Method Summary collapse

Methods included from MessageHandler

#critical, #debug, #error, #fatal, #info, #warning

Constructor Details

#initializeRichTextFunctionExample

Returns a new instance of RichTextFunctionExample.



25
26
27
28
# File 'lib/taskjuggler/RichText/FunctionExample.rb', line 25

def initialize
  super('example')
  @blockFunction = true
end

Instance Method Details

#to_html(args) ⇒ Object

Return a XMLElement tree that represents the example file as HTML code.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/taskjuggler/RichText/FunctionExample.rb', line 36

def to_html(args)
  unless (file = args['file'])
    raise "'file' argument missing"
  end
  tag = args['tag']

  example = TjpExample.new
  fileName = File.join(AppConfig.dataDirs('test')[0], 'TestSuite',
                       'Syntax', 'Correct', "#{file}.tjp")
  example.open(fileName)
  frame = XMLElement.new('div', 'class' => 'codeframe')
  frame << (pre = XMLElement.new('pre', 'class' => 'code'))
  unless (text = example.to_s(tag))
    raise "There is no tag '#{tag}' in file " +
        "#{fileName}."
  end
  pre << XMLText.new(text)
  frame
end

#to_s(args) ⇒ Object

Not supported for this function



31
32
33
# File 'lib/taskjuggler/RichText/FunctionExample.rb', line 31

def to_s(args)
  ''
end

#to_tagged(args) ⇒ Object

Not supported for this function.



57
58
59
# File 'lib/taskjuggler/RichText/FunctionExample.rb', line 57

def to_tagged(args)
  nil
end