Class: TomParse::TomDoc

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

Overview

TODO:

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

Encapsulate parsed tomdoc documentation.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initialize a TomDoc object.

Parameters:

  • text

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



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

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

Instance Attribute Details

#rawObject

Returns the value of attribute raw.



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

def raw
  @raw
end

Class Method Details

.valid?(text) ⇒ Boolean

Validate given comment text.

Returns:

  • (Boolean)

    true if comment is valid, otherwise false.



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

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

Instance Method Details

#argumentsObject Also known as: args

Arguments list.

Returns:

  • list of arguments.



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

def arguments
  @parser.arguments
end

#deprecated?Boolean

Check if method is deprecated.

Returns:

  • (Boolean)

    true if method is deprecated.



171
172
173
# File 'lib/tomparse.rb', line 171

def deprecated?
  @parser.deprecated?
end

#descriptionObject

Description of method or class/module.

Returns:

  • description String.



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

def description
  @parser.description
end

#examplesString

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

Returns:

  • (String)

    of examples.



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

def examples
  @parser.examples
end

#internal?Boolean

Check if method is internal.

Returns:

  • (Boolean)

    true if method is internal.



164
165
166
# File 'lib/tomparse.rb', line 164

def internal?
  @parser.internal?
end

#optionsObject Also known as: keyword_arguments

Keyword arguments, aka Options.

Returns:

  • list of options.



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

def options
  @parser.options
end

#public?Boolean

Check if method is public.

Returns:

  • (Boolean)

    true if method is public.



157
158
159
# File 'lib/tomparse.rb', line 157

def public?
  @parser.public?
end

#raisesArray

A list of errors a method might raise.

Returns:

  • (Array)

    of method raises descriptions.



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

def raises
  @parser.raises
end

#returnsArray

The list of retrun values a method can return.

Returns:

  • (Array)

    of method return descriptions.



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

def returns
  @parser.returns
end

#sectionsArray

List of comment sections. These are divided simply on “nn”.

Returns:

  • (Array)

    of comment sections.



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

def sections
  @parser.sections
end

#signature_fieldsArray

Deprecated.

Do not use this in new code, and replace it when updating old code.

TODO:

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

A list of signature fields.

Returns:

  • (Array)

    of field definitions.



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

def signature_fields
  @parser.signature_fields
end

#signaturesArray

A list of alternate method signatures.

Returns:

  • (Array)

    of signatures.



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

def signatures
  @parser.signatures 
end

#tagsArray<Array<String>>

List of tags.

Returns:

  • (Array<Array<String>>)

    Returns an associatve array of tags.



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

def tags
  @parser.tags
end

#to_sString

Raw documentation text.

Returns:

  • (String)

    of raw documentation text.



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

def to_s
  @parser.raw
end

#tomdocObject

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

Returns:

  • cleaned-up comment String.



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

def tomdoc
  return @parser.tomdoc
end

#valid?Boolean

Validate raw comment.

Returns:

  • (Boolean)

    true if comment is valid, otherwise false.



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

def valid?
  @parser.valid?
end

#validateObject

Validate raw comment.

Returns:

  • true if comment is valid.

Raises:

  • ParseError if comment is not valid.



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

def validate
  @parser.validate
end

#yieldsString

Description of a methods yield procedure.

Returns:

  • (String)

    decription of yield procedure.



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

def yields
  @parser.yields
end