Class: DataMetaDom::Doc
- Inherits:
-
Object
- Object
- DataMetaDom::Doc
- 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
-
#target ⇒ Object
readonly
Documentation target such as PLAIN_DOC_TARGET or JAVA_DOC_TARGET or whatever is added in the future.
-
#text ⇒ Object
The text of the documentation.
Class Method Summary collapse
-
.parse(source, params) ⇒ Object
Parses the documentation from the given source, returns an instance of Doc.
Instance Method Summary collapse
-
#initialize(target, text) ⇒ Doc
constructor
Creates an instance for the given target and given text.
-
#to_s ⇒ Object
Textual for the instance.
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
#target ⇒ Object (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 |
#text ⇒ Object
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_s ⇒ Object
Textual for the instance
70 |
# File 'lib/dataMetaDom/docs.rb', line 70 def to_s; "Doc-#{target}\n#{text}" end |