Sha256: f2080d38943f0d4f42ca94d1e9fd6facea8fe0f3aeb20caf38e0569aab87d69b

Contents?: true

Size: 1.69 KB

Versions: 4

Compression:

Stored size: 1.69 KB

Contents

== Constant Documentation

=== Class/Module Constant

Given a file +lib/example.rb+ containing a documented constant in a class
(or module):

    class ExampleClass
      # This constant is documented.
      ExampleConstant = "example"
    end

Running the script through shomen command line interface, regardless of which
underlying parser is used, should produce a data structure conforming to the
Shomen standard data format having the following characteristics.

The data structure should have four entries.

  @shomen.keys.size  #=> 4

  @shomen.keys.assert.include?('(metadata)')
  @shomen.keys.assert.include?('ExampleClass')
  @shomen.keys.assert.include?('ExampleClass::ExampleConstant')
  @shomen.keys.assert.include?('/lib/example.rb')

We want to inspect the constant entry itself, so we will assign the entry
to a variable to ease readability.

  constant = @shomen['ExampleClass::ExampleConstant']

The `ExampleConstant` entry should have a "bang" type of `constant`.

  constant['!']          #=> 'constant'

It should have a name of `ExampleConstant`.

  constant['name']       #=> 'ExampleConstant'

While the namespace should be `ExampleClass`.

  constant['namespace']  #=> 'ExampleClass'

The full `path` field will be the same as the name for the same reason.

  constant['path']       #=> 'ExampleClass::ExampleConstant'

The `comment` field will as given in the script.

  constant['comment']    #=> "This constant is documented."

And the `files` field should list only `lib/example.rb`.

  constant['files']      #=> ['/lib/example.rb']

Lastly, the `value` field should contain the value the literal representation
of the value to which the constant is set.

  constant['value']      #=> '"example"'

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
shomen-yard-0.1.0 spec/04_constant.rdoc
shomen-rdoc-0.1.0 spec/04_constant.rdoc
shomen-0.1.1 spec/04_constant.rdoc
shomen-0.1.0 spec/04_constant.rdoc