Class: Docgenerator::Lists::ListEnvironment

Inherits:
Environments::Environment show all
Defined in:
lib/docgenerator/lists.rb

Overview

Generic class for list environments.

Used to define Itemize, Enumerate...

Direct Known Subclasses

Description, Enumerate, Itemize

Constant Summary

Constants inherited from Element

Element::SUPPORTED_TARGETS

Constants included from Docgenerator

ATTR_LANG, CSS_BORDER, CSS_COLORS, CSS_WIDTH, DOCGENERATOR_DEFAULT_LOGGER, DOCGENERATOR_LOGGER, ENDTAG, HTML_ATTR_ALIGN, HTML_ATTR_ALL, HTML_ATTR_CORE, HTML_ATTR_EVENTS, HTML_ATTR_I18N, HTML_ATTR_VALIGN, VERSION

Instance Attribute Summary

Attributes inherited from Element

#attr, #content, #log

Instance Method Summary collapse

Methods inherited from Environments::Environment

#to_context_environment, #to_latex_environment

Methods inherited from Element

#CR, #Cr, #[], add, add_attribute, add_attributes, add_context_output, add_creole_output, add_html_output, add_html_tag, add_id, add_latex_output, add_output, add_text_output, add_wiki_output, attributes, #cR, #content?, #cr, create, create_convert_to_code, #delete, #element_ids, element_ids, #empty?, get, get_attribute_list, has_no_content, #htmltag, #ids, inherited, #initialize, #insert, #insertafter, #insertbefore, #inspect, #inspect_creation_caller, #linebreak, overview, #prepare_tracing_info, #restrict_to, #texkeyval, #texoptional, #to_context, #to_html, #to_latex, #to_s, trace=

Methods included from Docgenerator

#set_option_defaults, set_option_defaults, trace_off, trace_on, trace_on?

Constructor Details

This class inherits a constructor from Docgenerator::Element

Instance Method Details

#<<(item) ⇒ Object

Only items are allowed to be added.

If an array is given, each item is added on it



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/docgenerator/lists.rb', line 13

def << ( item)
  if item.is_a?(Array)
    item.each{|it| self << it }
  else
    if self.class == Description
      #fixme: check sequence :dt/:dd
      if ! ( item.is_a?( Element.get(:dt) ) or item.is_a?( Element.get(:dd) ) )
        @log.warn("Add non-item to list (get #{item.inspect})") if @log.warn
      end
    elsif ! item.is_a?( Element.get(:item) )
      @log.warn("Add non-item to list (get #{item.inspect})") if @log.warn
    end
    @content << item
  end
end

#to_creole(options = {}) ⇒ Object



38
39
40
# File 'lib/docgenerator/lists.rb', line 38

def to_creole( options= {} )
  return "#{@content.to_doc(:wiki, options)}\n".gsub(/\n\n/, "\n")
end

#to_doc(target, options = {}) ⇒ Object

Add parent-information to options. This is used by the list elements to get the list type.



29
30
31
32
33
34
# File 'lib/docgenerator/lists.rb', line 29

def to_doc( target, options = {} )
  o = set_option_defaults(options)
  o[:log].debug("enter to_doc for #{self.inspect}") if o[:log].debug?
  options[:parent] = self
  super
end

#to_text(options = {}) ⇒ Object



41
42
43
# File 'lib/docgenerator/lists.rb', line 41

def to_text( options={} )
  return "#{@content.to_doc(:text,options)}\n".gsub(/\n\n/, "\n")
end

#to_wiki(options = {}) ⇒ Object



35
36
37
# File 'lib/docgenerator/lists.rb', line 35

def to_wiki( options= {} )
  return "#{@content.to_doc(:wiki, options)}\n".gsub(/\n\n/, "\n")
end