Class: DataMetaDom::Doc

Inherits:
Object
  • Object
show all
Defined in:
lib/dataMetaDom/docs.rb

Overview

Documentation tag

For command line details either check the new method’s source or the README.rdoc file, the usage section.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, text) ⇒ Doc

Creates an instance for the given target and given text.



41
42
43
44
45
46
# File 'lib/dataMetaDom/docs.rb', line 41

def initialize(target, text)
    @target = target.to_sym
    #noinspection RubyArgCount
    raise "Unsupported docs target #@target" unless DOC_TARGETS.member?(@target)
    @text = text
end

Instance Attribute Details

#targetObject (readonly)

Documentation target such as PLAIN_DOC_TARGET or JAVA_DOC_TARGET or whatever is added in the future. May stick with plaintext unless it becomes easy to write in a common markup format and generate specific doc format from it.

Can be one of the following:

  • PLAIN_DOC_TARGET - plain

  • JAVA_DOC_TARGET - java



31
32
33
# File 'lib/dataMetaDom/docs.rb', line 31

def target
  @target
end

#textObject

The text of the documentation.



36
37
38
# File 'lib/dataMetaDom/docs.rb', line 36

def text
  @text
end

Class Method Details

.parse(source, params) ⇒ Object

Parses the documentation from the given source, returns an instance of Doc.

  • Parameters:

    • source - an instance of SourceFile

    • params - an array, first member is the target.



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/dataMetaDom/docs.rb', line 55

def self.parse(source, params)
    text = ''
    while (line = source.nextLine(true))
        case line
            when /^\s*#{END_KW}\s*$/
                retVal = Doc.new params[0], text
                return retVal
            else
                text << line
        end # case
    end # while line
    raise "Parsing a doc: missing end keyword, source=#{source}"
end

Instance Method Details

#to_sObject

Textual for the instance



70
# File 'lib/dataMetaDom/docs.rb', line 70

def to_s; "Doc-#{target}\n#{text}" end