Class: TomParse::TomDoc

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

Overview

Encapsulate parsed tomdoc documentation.

TODO: Currently uses lazy evaluation, eventually this should be removed and simply parsed all at once.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, parse_options = {}) ⇒ TomDoc

Public: Initialize a TomDoc object.

text - The raw text of a method or class/module comment.

Returns new TomDoc instance.



30
31
32
33
# File 'lib/tomparse.rb', line 30

def initialize(text, parse_options={})
  @parser = Parser.new(text, parse_options)
  @parser.parse
end

Instance Attribute Details

#raw ⇒ Object

Returns the value of attribute raw.



23
24
25
# File 'lib/tomparse.rb', line 23

def raw
  @raw
end

Class Method Details

.valid?(text) ⇒ Boolean

Validate given comment text.

Returns true if comment is valid, otherwise false.

Returns:

  • (Boolean)


45
46
47
# File 'lib/tomparse.rb', line 45

def self.valid?(text)
  new(text).valid?
end

Instance Method Details

#arguments ⇒ Object Also known as: args

Arguments list.

Returns list of arguments.



90
91
92
# File 'lib/tomparse.rb', line 90

def arguments
  @parser.arguments
end

#deprecated? ⇒ Boolean

Check if method is deprecated.

Returns true if method is deprecated.

Returns:

  • (Boolean)


175
176
177
# File 'lib/tomparse.rb', line 175

def deprecated?
  @parser.deprecated?
end

#description ⇒ Object

Description of method or class/module.

Returns description String.



83
84
85
# File 'lib/tomparse.rb', line 83

def description
  @parser.description
end

#examples ⇒ Object

List of use examples of a method or class/module.

Returns String of examples.



106
107
108
# File 'lib/tomparse.rb', line 106

def examples
  @parser.examples
end

#internal? ⇒ Boolean

Check if method is internal.

Returns true if method is internal.

Returns:

  • (Boolean)


168
169
170
# File 'lib/tomparse.rb', line 168

def internal?
  @parser.internal?
end

#options ⇒ Object Also known as: keyword_arguments

Keyword arguments, aka Options.

Returns list of options.



98
99
100
# File 'lib/tomparse.rb', line 98

def options
  @parser.options
end

#public? ⇒ Boolean

Check if method is public.

Returns true if method is public.

Returns:

  • (Boolean)


161
162
163
# File 'lib/tomparse.rb', line 161

def public?
  @parser.public?
end

#raises ⇒ Object

A list of errors a method might raise.

Returns Array of method raises descriptions.



127
128
129
# File 'lib/tomparse.rb', line 127

def raises
  @parser.raises
end

#returns ⇒ Object

The list of retrun values a method can return.

Returns Array of method return descriptions.



120
121
122
# File 'lib/tomparse.rb', line 120

def returns
  @parser.returns
end

#sections ⇒ Object

List of comment sections. These are divided simply on "\n\n".

Returns Array of comment sections.



76
77
78
# File 'lib/tomparse.rb', line 76

def sections
  @parser.sections
end

#signature_fields ⇒ Object

Deprecated: A list of signature fields.

TODO: Presently this will always return an empty list. It will either be removed or renamed in future version.

Returns Array of field definitions.



144
145
146
# File 'lib/tomparse.rb', line 144

def signature_fields
  @parser.signature_fields
end

#signatures ⇒ Object

A list of alternate method signatures.

Returns Array of signatures.



134
135
136
# File 'lib/tomparse.rb', line 134

def signatures
  @parser.signatures
end

#tags ⇒ Object Also known as: labels

List of tags.

Returns an associatve array of tags. [Array<Array>]



151
152
153
# File 'lib/tomparse.rb', line 151

def tags
  @parser.tags
end

#to_s ⇒ Object

Raw documentation text.

Returns String of raw documentation text.



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

def to_s
  @parser.raw
end

#tomdoc ⇒ Object

The raw comment text cleaned-up and ready for section parsing.

Returns cleaned-up comment String.



69
70
71
# File 'lib/tomparse.rb', line 69

def tomdoc
  return @parser.tomdoc
end

#valid? ⇒ Boolean

Validate raw comment.

Returns true if comment is valid, otherwise false.

Returns:

  • (Boolean)


52
53
54
# File 'lib/tomparse.rb', line 52

def valid?
  @parser.valid?
end

#validate ⇒ Object

Validate raw comment.

Returns true if comment is valid. Raises ParseError if comment is not valid.



60
61
62
# File 'lib/tomparse.rb', line 60

def validate
  @parser.validate
end

#yields ⇒ Object

Description of a methods yield procedure.

Returns String decription of yield procedure.



113
114
115
# File 'lib/tomparse.rb', line 113

def yields
  @parser.yields
end