tomparse 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d31fbe2751c47dc99b8d422876a021a4859ed9a5776bf07e249a479e8f750c11
4
+ data.tar.gz: e31f7756139196449f39cf843f2fb9b1d442b36e8dc8d9d5ce03a7e9e7311d5a
5
+ SHA512:
6
+ metadata.gz: 7c8e733b07b53fd82fd9bdaa57f1974d505126ed4293a2c00cf82ecd0ec2efb881829ecaacda6eb29a2fdfac6d6fa980367242fe33df6d43c0ce43f3aa41b85b
7
+ data.tar.gz: 84abb656e4eb2a17a11f64fc21c3b16795e62951c01b9eaac825335f21bc4fdb0a4761a7f84201feaf060df2af86a68809aab4d9943cec28e2938df5f19621cc
data/HISTORY.md CHANGED
@@ -1,8 +1,35 @@
1
1
  # Release History
2
2
 
3
+ ## 0.5.0 / 2026-11-30
4
+
5
+ TomParse is brought up to date: it needs Ruby 3.1 or newer. This release
6
+ also carries the fixes made since 0.4.2, which were never published
7
+ (a 0.4.3 was prepared in 2015 but not released).
8
+
9
+ Changes:
10
+
11
+ * Fix parsing of options that run over more than one line. (Faraz Yashar)
12
+ * Fix a line break left in the description of an argument's option when
13
+ it ran over more than one line.
14
+ * Add `TomDoc#labels` as an alias of `#tags`.
15
+ * Add `TomParse::VERSION`.
16
+ * Fix typos in the documentation. (Chayoung You)
17
+ * Tests run on Spectrum, in CI on Ruby 3.1 to 4.0.
18
+
19
+
20
+ ## 0.4.2 / 2013-02-15
21
+
22
+ This release fixes description and argument parsing when
23
+ a visibility indicator is used.
24
+
25
+ Changes:
26
+
27
+ * Fix desc/arguments parsing given indicator.
28
+
29
+
3
30
  ## 0.4.1 / 2013-02-14
4
31
 
5
- This release fixes exmaple parsing.
32
+ This release fixes example parsing.
6
33
 
7
34
  Changes:
8
35
 
@@ -21,7 +48,7 @@ have to be all-caps. And lastly, the `Signature` section has been
21
48
  repurposed for describing variant *parameter signatures*, not dynamic
22
49
  methods. As such `signature_fields` has been deprecated. Yes, these
23
50
  are additions and some deviation from the original TomDoc spec, but
24
- when purely conceptual specs go into practice they have a tendency to
51
+ when purely conceptual specs go into practice they have a tendency to
25
52
  adapt to practical requirements.
26
53
 
27
54
  Changes:
data/README.md CHANGED
@@ -1,15 +1,8 @@
1
- # TomParse
1
+ # [TomParse](https://rubyworks.github.io/tomparse)
2
2
 
3
- [Website](http://github.com/rubyworks/tomparse) /
4
- [Report Issue](http://github.com/rubyworks/tomparse/issues) /
5
- [Source Code](http://github.com/rubyworks/tomparse) /
6
- [Gem Page](http://rubygems.org/gems/tomparse)
7
-
8
- [![Build Status](https://secure.travis-ci.org/rubyworks/tomparse.png)](http://travis-ci.org/rubyworks/tomparse)
9
- [![Gem Version](https://badge.fury.io/rb/tomparse.png)](http://badge.fury.io/rb/tomparse)
10
-
11
-
12
- ## Description
3
+ [![Version](https://img.shields.io/gem/v/tomparse.svg)](https://rubygems.org/gems/tomparse)
4
+ [![CI](https://github.com/rubyworks/tomparse/actions/workflows/ci.yml/badge.svg)](https://github.com/rubyworks/tomparse/actions/workflows/ci.yml)
5
+ [![Issues](https://img.shields.io/github/issues-raw/rubyworks/tomparse.svg)](https://github.com/rubyworks/tomparse/issues)
13
6
 
14
7
  TomParse is a TomDoc parser for Ruby. It provides no other functionality than
15
8
  to take a code comment and parse it in to a convenient object-oriented
@@ -17,13 +10,7 @@ structure in accordance with the TomDoc standard. See [TomDoc](https://github.co
17
10
  for more information about the TomDoc format.
18
11
 
19
12
 
20
- ## Instruction
21
-
22
- ### Installation
23
-
24
- TomParse is available as a Ruby gem.
25
-
26
- $ gem install tomparse
13
+ ## Instructions
27
14
 
28
15
  ### Usage
29
16
 
@@ -59,6 +46,19 @@ looks something like this:
59
46
  text * count
60
47
  end
61
48
 
49
+ ### Installation
50
+
51
+ TomParse is available as a Ruby gem.
52
+
53
+ $ gem install tomparse
54
+
55
+ TomParse needs Ruby 3.1 or newer.
56
+
57
+ Use with Bundler by adding to your Gemfile (gems.rb file in the future).
58
+
59
+ gem "tomparse"
60
+
61
+
62
62
  ## Extra Features
63
63
 
64
64
  Okay, we told a little white lie in the description. TomParse does take some
@@ -93,8 +93,8 @@ but there are times when its reads better to put them lower, such when using a
93
93
 
94
94
  Ruby 2.0 finally introduces *keyword arguments* to the language. TomDoc's current
95
95
  support of argument options, as a secondary argument list of a Hash argument,
96
- doesn't take keyoword arguments into good account. To remedy this TomParse provides
97
- and `Options` section, and it written just like one would an `Arguments` section.
96
+ doesn't take keyword arguments into good account. To remedy this TomParse provides
97
+ an `Options` section. It is written just like one would an `Arguments` section.
98
98
 
99
99
  ```ruby
100
100
  # Method to do fooey.
@@ -107,11 +107,11 @@ and `Options` section, and it written just like one would an `Arguments` section
107
107
  ...
108
108
  ```
109
109
 
110
- ### Tags
110
+ ### Labels
111
111
 
112
112
  One really nice new feature of TomParse is it's ability to recoginize sections
113
- starting with a capitalized word followed by a colon and a space, as special *tags*.
114
- Here is an example:
113
+ starting with a capitalized word followed by a colon and a space, as special
114
+ section *tags* or *labels* (call them what you will). Here is an example:
115
115
 
116
116
  ```ruby
117
117
  # Method to do something.
@@ -123,8 +123,8 @@ Here is an example:
123
123
  ...
124
124
  ```
125
125
 
126
- When this is parsed, rather then lumping the TODO line in with the description,
127
- the TomDoc instance will have a `tags` entry containing `['TODO', 'This is a todo note.']`.
126
+ When this is parsed, rather than lumping the TODO line in with the description,
127
+ the TomDoc instance will have a `tags`/`labels` entry containing `['TODO', 'This is a todo note.']`.
128
128
  It is important for consumer applications to recognize this. They can either just
129
129
  add the tags back into the description when generating documentation, or handle
130
130
  them separately. But tags don't have to occur right after the description. They
@@ -133,7 +133,7 @@ can occur any place in the documentation.
133
133
  ### Signatures
134
134
 
135
135
  TomParse does not support the Signature sections in exactly the same fashion as
136
- the TomDoc specification describes. Rather then define dynamic methods, signatures
136
+ the TomDoc specification describes. Rather than define dynamic methods, signatures
137
137
  are used to specify alternate argument patterns, one signature per line.
138
138
 
139
139
  ```ruby
@@ -156,7 +156,7 @@ Technically the Signatures section can still be used to designate a dynamic meth
156
156
  but as you can see by the above example, TomParse does not support the *field* list.
157
157
  If needed just use the arguments list for these as well.
158
158
 
159
- This choice was made, btw, because support for signatures as defined by the spec,
159
+ This choice was made because support for signatures as defined by the spec
160
160
  leads to very non-optimal code. It requires scanning every chunk of documentation
161
161
  for a `Signature` section in order to determine how to treat it. What is needed
162
162
  is a more universal syntax, that can be easily recognized by some clear identifier
@@ -166,12 +166,9 @@ with the more traditional concept of method signatures.
166
166
 
167
167
  ## Resources
168
168
 
169
- * [Website](http://rubyworks.github.com/tomparse)
170
- * [Source Code](http://github.com/rubyworks/tomparse) (Github)
171
- * [API Reference](http://rubydoc.info/gems/tomparse/frames")
172
- * [Mailiing List](http://groups.google.com/group/rubyworks-mailinglist)
173
- * [IRC Chat](http://chat.us.freenode.net/rubyworks)
174
- * [Upstream Repo](http://github.com/rubyworks/tomparse/tomparse.git)
169
+ * [Website](https://rubyworks.github.io/tomparse)
170
+ * [Source Code](https://github.com/rubyworks/tomparse)
171
+ * [API Reference](https://rubydoc.info/gems/tomparse)
175
172
 
176
173
 
177
174
  ## Authors
@@ -180,28 +177,18 @@ with the more traditional concept of method signatures.
180
177
  <li class="iauthor vcard">
181
178
  <span class="nickname">trans</span>
182
179
  <span>&lt;<a class="email" href="mailto:transfire@gmail.com">transfire@gmail.com</a>&gt;</span>
183
- <br/><a class="url" href="http://trans.gihub.com/">http://trans.github.com/</a>
180
+ <br/><a class="url" href="http://trans.github.com/">http://trans.github.com/</a>
184
181
  </li>
185
182
  </ul>
186
183
 
187
184
 
188
- ## Development
189
-
190
- ### Requirements
191
-
192
- * [Citron](http://rubyworks.github.com/citron) (testing)
193
- * [AE](http://rubyworks.github.com/ae) (testing)
194
- * [Fire](http://detroit.github.com/fire) (building)
195
- * [Detroit](http://detroit.github.com/detroit) (building)
196
-
197
-
198
185
  ## Copyright & License
199
186
 
200
187
  TomParse is copyrighted open-source software.
201
188
 
202
- Copyright (c) 2012 [Rubyworks](http://rubyworks.github.com). All rights reserved.
189
+ Copyright (c) 2012 [Rubyworks](https://github.com/rubyworks). All rights reserved.
203
190
 
204
- TomParse is distributable under the terms of the [BSD-2-Clause]((http://www.spdx.org/licenses/BSD-2-Clause) license.
191
+ TomParse is distributable under the terms of the [BSD-2-Clause](https://spdx.org/licenses/BSD-2-Clause) license.
205
192
 
206
193
  See LICENSE.txt for details.
207
194
 
@@ -2,6 +2,8 @@ module TomParse
2
2
 
3
3
  # Encapsulate a method argument.
4
4
  #
5
+ # TODO: Does not yet support default parameter.
6
+ #
5
7
  class Argument
6
8
 
7
9
  attr_accessor :name
@@ -24,7 +26,7 @@ module TomParse
24
26
  #
25
27
  # Returns Boolean.
26
28
  def optional?
27
- @description.downcase.include? 'optional'
29
+ @optional
28
30
  end
29
31
 
30
32
  # Parse arguments section. Arguments occur subsequent to
@@ -51,7 +53,7 @@ module TomParse
51
53
  indent = line.scan(/^\s*/)[0].to_s.size
52
54
 
53
55
  if last_indent && indent > last_indent
54
- opts.last.description << line.squeeze(" ")
56
+ opts.last.description << " " << line.strip.squeeze(" ")
55
57
  else
56
58
  param, d = line.split(" - ")
57
59
  opts << Option.new(param.strip, d.strip) if param && d
@@ -60,8 +62,25 @@ module TomParse
60
62
  last_indent = indent
61
63
  end
62
64
 
63
- @description = desc.join
64
- @options = opts
65
+ # Look for `(optional)` at end of description. If found, mark argument
66
+ # as @optional and remove from description.
67
+ #if md = /(\(optional\)\s*)(?:\[|\.\Z|\Z)/.match(desc.last)
68
+ # @optional = true
69
+ # desc.last[*md.offset(1)] = ''
70
+ #end
71
+
72
+ # Join the desc lines back together and ensure no extraneous whitespace.
73
+ text = desc.join.strip
74
+
75
+ # If the description contains the word "optional" the argument is taken
76
+ # to be optional. Note, I think this probably should be `(optional)` to
77
+ # prevent false positives, but the spec suggests otherwise.
78
+ if /\boptional\b/ =~ text
79
+ @optional = true
80
+ end
81
+
82
+ @description = text
83
+ @options = opts
65
84
  end
66
85
 
67
86
  end
@@ -81,7 +81,7 @@ module TomParse
81
81
  lines = raw.split("\n")
82
82
 
83
83
  # remove remark symbol
84
- if lines.all?{ |line| /^\s*#/ =~ line }
84
+ if lines.all?{ |line| /^\s*#/ =~ line }
85
85
  lines = lines.map do |line|
86
86
  line =~ /^(\s*#)/ ? line.sub($1, '') : nil
87
87
  end
@@ -192,7 +192,7 @@ module TomParse
192
192
  # Returns Array of signatures.
193
193
  def signatures
194
194
  parsed {
195
- @signatures
195
+ @signatures
196
196
  }
197
197
  end
198
198
 
@@ -272,7 +272,7 @@ module TomParse
272
272
  desc << sections.shift
273
273
  end
274
274
  sections = [desc.join("\n\n")] + sections
275
-
275
+
276
276
  @sections = sections.dup
277
277
 
278
278
  parse_description(sections.shift)
@@ -365,6 +365,8 @@ module TomParse
365
365
  end
366
366
 
367
367
  # Split the documentation up into proper sections.
368
+ # The method works by building up a list of linenos
369
+ # of where each section begins.
368
370
  #
369
371
  # Returns an array section strings. [Array<String>]
370
372
  def smart_split(doc)
@@ -378,12 +380,12 @@ module TomParse
378
380
 
379
381
  # Keep a copy of the lines for later use.
380
382
  doc_lines = lines.dup
381
-
383
+
384
+
382
385
  # The first line may have a `Public`/`Private`/`Deprecated` marker.
383
- # We need to remove that for the moment to properly check for
384
- # subsequent labeled sections.
385
- #first = lines.first.dup
386
- #lines.first.sub(/^[A-Z]\w+\:\s*/, '')
386
+ # So we just skip the first line.
387
+ lines.shift
388
+ index += 1
387
389
 
388
390
  # The description is always the first section, but it may have
389
391
  # multiple paragraphs. And the second section may be an arguments
@@ -398,7 +400,7 @@ module TomParse
398
400
  break
399
401
  end
400
402
  end
401
-
403
+
402
404
  # The rest of the the document should have identifiable section markers.
403
405
  while line = lines.shift
404
406
  index += 1
@@ -473,7 +475,7 @@ module TomParse
473
475
  end
474
476
  else
475
477
  @description = section.strip
476
- end
478
+ end
477
479
  end
478
480
 
479
481
  # Parse arguments section. Arguments occur subsequent to
@@ -521,7 +523,7 @@ module TomParse
521
523
  next if line.strip.empty?
522
524
  indent = line.scan(/^\s*/)[0].to_s.size
523
525
 
524
- if last_indent && indent > 0 && indent >= last_indent
526
+ if last_indent && indent > 0 && indent > last_indent
525
527
  opts.last.description << "\r\n" + line
526
528
  else
527
529
  param, desc = line.split(" - ")
@@ -659,7 +661,7 @@ module TomParse
659
661
  # Returns nothing.
660
662
  def parse_tag(section)
661
663
  md = /^([A-Z]\w+)\:\ /m.match(section)
662
-
664
+
663
665
  label = md[1]
664
666
  desc = md.post_match
665
667
 
@@ -0,0 +1,4 @@
1
+ module TomParse
2
+ # The version of TomParse.
3
+ VERSION = '0.5.0'
4
+ end
data/lib/tomparse.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module TomParse
2
+ require 'tomparse/version'
2
3
  require 'tomparse/parser'
3
4
  require 'tomparse/parse_error'
4
5
  require 'tomparse/argument'
@@ -131,7 +132,7 @@ module TomParse
131
132
  #
132
133
  # Returns Array of signatures.
133
134
  def signatures
134
- @parser.signatures
135
+ @parser.signatures
135
136
  end
136
137
 
137
138
  # Deprecated: A list of signature fields.
@@ -151,6 +152,9 @@ module TomParse
151
152
  @parser.tags
152
153
  end
153
154
 
155
+ # Alternate name for *tags*.
156
+ alias labels tags
157
+
154
158
  # Check if method is public.
155
159
  #
156
160
  # Returns true if method is public.
metadata CHANGED
@@ -1,129 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tomparse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
5
- prerelease:
4
+ version: 0.5.0
6
5
  platform: ruby
7
6
  authors:
8
- - trans
9
- autorequire:
7
+ - Trans
10
8
  bindir: bin
11
9
  cert_chain: []
12
- date: 2013-02-14 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
13
11
  dependencies:
14
12
  - !ruby/object:Gem::Dependency
15
- name: citron
13
+ name: rake
16
14
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
15
  requirements:
19
- - - ! '>='
16
+ - - ">="
20
17
  - !ruby/object:Gem::Version
21
- version: '0'
18
+ version: '13'
22
19
  type: :development
23
20
  prerelease: false
24
21
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
22
  requirements:
27
- - - ! '>='
23
+ - - ">="
28
24
  - !ruby/object:Gem::Version
29
- version: '0'
25
+ version: '13'
30
26
  - !ruby/object:Gem::Dependency
31
- name: ae
27
+ name: rubytest
32
28
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
29
  requirements:
35
- - - ! '>='
30
+ - - ">="
36
31
  - !ruby/object:Gem::Version
37
- version: '0'
32
+ version: 0.11.1
38
33
  type: :development
39
34
  prerelease: false
40
35
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
36
  requirements:
43
- - - ! '>='
37
+ - - ">="
44
38
  - !ruby/object:Gem::Version
45
- version: '0'
39
+ version: 0.11.1
46
40
  - !ruby/object:Gem::Dependency
47
- name: detroit
41
+ name: spectrum
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0.2'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0.2'
54
+ - !ruby/object:Gem::Dependency
55
+ name: ae
48
56
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
57
  requirements:
51
- - - ! '>='
58
+ - - ">="
52
59
  - !ruby/object:Gem::Version
53
- version: '0'
60
+ version: '1.9'
54
61
  type: :development
55
62
  prerelease: false
56
63
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
64
  requirements:
59
- - - ! '>='
65
+ - - ">="
60
66
  - !ruby/object:Gem::Version
61
- version: '0'
62
- description: ! 'TomParse provides no other functionality than to take a code comment
63
-
64
- and parse it in to a convenient object-oriented structure in accordance
65
-
66
- with TomDoc standard.'
67
+ version: '1.9'
68
+ description: TomParse provides no other functionality than to take a code comment
69
+ and parse it in to a convenient object-oriented structure in accordance with TomDoc
70
+ standard.
67
71
  email:
68
72
  - transfire@gmail.com
69
73
  executables: []
70
74
  extensions: []
71
- extra_rdoc_files:
72
- - LICENSE.txt
75
+ extra_rdoc_files: []
76
+ files:
73
77
  - HISTORY.md
78
+ - LICENSE.txt
74
79
  - README.md
75
- files:
76
- - .index
77
- - .yardopts
80
+ - lib/tomparse.rb
78
81
  - lib/tomparse/argument.rb
79
82
  - lib/tomparse/option.rb
80
83
  - lib/tomparse/parse_error.rb
81
84
  - lib/tomparse/parser.rb
82
- - lib/tomparse.rb
83
- - lib/tomparse.yml
84
- - test/helper.rb
85
- - test/test_description.rb
86
- - test/test_examples.rb
87
- - test/test_prefixes.rb
88
- - test/test_signatures.rb
89
- - test/test_tags.rb
90
- - test/test_tomdoc.rb
91
- - test/test_yields.rb
92
- - HISTORY.md
93
- - README.md
94
- - LICENSE.txt
95
- homepage: http://rubyworks.github.com/tomparse
85
+ - lib/tomparse/version.rb
86
+ homepage: https://github.com/rubyworks/tomparse
96
87
  licenses:
97
88
  - BSD-2-Clause
98
- post_install_message:
89
+ metadata:
90
+ source_code_uri: https://github.com/rubyworks/tomparse
91
+ bug_tracker_uri: https://github.com/rubyworks/tomparse/issues
92
+ changelog_uri: https://github.com/rubyworks/tomparse/blob/master/HISTORY.md
93
+ documentation_uri: https://rubydoc.info/gems/tomparse
99
94
  rdoc_options: []
100
95
  require_paths:
101
96
  - lib
102
97
  required_ruby_version: !ruby/object:Gem::Requirement
103
- none: false
104
98
  requirements:
105
- - - ! '>='
99
+ - - ">="
106
100
  - !ruby/object:Gem::Version
107
- version: '0'
101
+ version: '3.1'
108
102
  required_rubygems_version: !ruby/object:Gem::Requirement
109
- none: false
110
103
  requirements:
111
- - - ! '>='
104
+ - - ">="
112
105
  - !ruby/object:Gem::Version
113
106
  version: '0'
114
107
  requirements: []
115
- rubyforge_project:
116
- rubygems_version: 1.8.24
117
- signing_key:
118
- specification_version: 3
108
+ rubygems_version: 3.6.9
109
+ specification_version: 4
119
110
  summary: TomDoc parser for Ruby
120
- test_files:
121
- - test/test_description.rb
122
- - test/helper.rb
123
- - test/test_examples.rb
124
- - test/test_yields.rb
125
- - test/test_signatures.rb
126
- - test/test_tags.rb
127
- - test/test_tomdoc.rb
128
- - test/test_prefixes.rb
129
- has_rdoc:
111
+ test_files: []
data/.index DELETED
@@ -1,68 +0,0 @@
1
- ---
2
- revision: 2013
3
- type: ruby
4
- sources:
5
- - var
6
- - VERSION
7
- authors:
8
- - name: trans
9
- email: transfire@gmail.com
10
- organizations:
11
- - name: Rubyworks
12
- website: http://rubyworks.github.com
13
- requirements:
14
- - groups:
15
- - test
16
- development: true
17
- name: citron
18
- - groups:
19
- - test
20
- development: true
21
- name: ae
22
- - groups:
23
- - build
24
- development: true
25
- name: detroit
26
- conflicts: []
27
- alternatives: []
28
- resources:
29
- - type: home
30
- uri: http://rubyworks.github.com/tomparse
31
- label: Homepage
32
- - type: code
33
- uri: http://github.com/rubyworks/tomparse
34
- label: Source Code
35
- - type: api
36
- uri: http://rubydoc.info/gems/tomparse/frames
37
- label: API Guide
38
- - type: mail
39
- uri: http://groups.google.com/group/rubyworks-mailinglist
40
- label: Mailing List
41
- - type: chat
42
- uri: http://chat.us.freenode.net/rubyworks
43
- label: IRC Channel
44
- repositories:
45
- - name: upstream
46
- scm: git
47
- uri: http://github.com/rubyworks/tomparse/tomparse.git
48
- categories:
49
- - documentation
50
- copyrights:
51
- - holder: Rubyworks
52
- year: '2012'
53
- license: BSD-2-Clause
54
- customs: []
55
- paths:
56
- lib:
57
- - lib
58
- created: '2012-03-04'
59
- summary: TomDoc parser for Ruby
60
- title: TomParse
61
- name: tomparse
62
- description: ! 'TomParse provides no other functionality than to take a code comment
63
-
64
- and parse it in to a convenient object-oriented structure in accordance
65
-
66
- with TomDoc standard.'
67
- version: 0.4.1
68
- date: '2013-02-14'
data/.yardopts DELETED
@@ -1,8 +0,0 @@
1
- --title "TomParse"
2
- --readme README.md
3
- --plugin tomdoc
4
- --private
5
- lib/**/*.rb
6
- -
7
- *.md
8
- *.txt
data/lib/tomparse.yml DELETED
@@ -1,68 +0,0 @@
1
- ---
2
- revision: 2013
3
- type: ruby
4
- sources:
5
- - var
6
- - VERSION
7
- authors:
8
- - name: trans
9
- email: transfire@gmail.com
10
- organizations:
11
- - name: Rubyworks
12
- website: http://rubyworks.github.com
13
- requirements:
14
- - groups:
15
- - test
16
- development: true
17
- name: citron
18
- - groups:
19
- - test
20
- development: true
21
- name: ae
22
- - groups:
23
- - build
24
- development: true
25
- name: detroit
26
- conflicts: []
27
- alternatives: []
28
- resources:
29
- - type: home
30
- uri: http://rubyworks.github.com/tomparse
31
- label: Homepage
32
- - type: code
33
- uri: http://github.com/rubyworks/tomparse
34
- label: Source Code
35
- - type: api
36
- uri: http://rubydoc.info/gems/tomparse/frames
37
- label: API Guide
38
- - type: mail
39
- uri: http://groups.google.com/group/rubyworks-mailinglist
40
- label: Mailing List
41
- - type: chat
42
- uri: http://chat.us.freenode.net/rubyworks
43
- label: IRC Channel
44
- repositories:
45
- - name: upstream
46
- scm: git
47
- uri: http://github.com/rubyworks/tomparse/tomparse.git
48
- categories:
49
- - documentation
50
- copyrights:
51
- - holder: Rubyworks
52
- year: '2012'
53
- license: BSD-2-Clause
54
- customs: []
55
- paths:
56
- lib:
57
- - lib
58
- created: '2012-03-04'
59
- summary: TomDoc parser for Ruby
60
- title: TomParse
61
- name: tomparse
62
- description: ! 'TomParse provides no other functionality than to take a code comment
63
-
64
- and parse it in to a convenient object-oriented structure in accordance
65
-
66
- with TomDoc standard.'
67
- version: 0.4.1
68
- date: '2013-02-14'
data/test/helper.rb DELETED
@@ -1,13 +0,0 @@
1
- require 'citron'
2
- require 'ae'
3
-
4
- if ENV['coverage']
5
- require 'simplecov'
6
- SimpleCov.command_name 'tomparse'
7
- SimpleCov.start do
8
- coverage_dir 'log/coverage'
9
- end
10
- end
11
-
12
- require 'tomparse'
13
-
@@ -1,54 +0,0 @@
1
- require_relative 'helper'
2
-
3
- testcase "Description" do
4
-
5
- context "description only" do
6
- setup do
7
- @comment = TomParse::TomDoc.new %{
8
- # Has this initial paragraph.
9
- }
10
- end
11
-
12
- test "correctly handles description only" do
13
- @comment.description.assert == "Has this initial paragraph."
14
- end
15
- end
16
-
17
- context "simple description with other things" do
18
- setup do
19
- @comment = TomParse::TomDoc.new %{
20
- # Has this initial paragraph, that continues on to
21
- # a new line.
22
- #
23
- # Examples
24
- #
25
- # foo('bar')
26
- }
27
- end
28
-
29
- test "correctly handles description" do
30
- @comment.description.assert == "Has this initial paragraph, that continues on to\na new line."
31
- end
32
- end
33
-
34
- context "handles multiple paragraph descriptions" do
35
- setup do
36
- @comment = TomParse::TomDoc.new %{
37
- # Has an initial paragraph.
38
- #
39
- # Has another paragraph in the description.
40
- #
41
- # Examples
42
- #
43
- # def multiplex(str, length)
44
- # str * length
45
- # end
46
- }
47
- end
48
-
49
- test "correctly handles multiple paragraphs" do
50
- @comment.description.assert == "Has an initial paragraph.\n\nHas another paragraph in the description."
51
- end
52
- end
53
-
54
- end
@@ -1,124 +0,0 @@
1
- require_relative 'helper'
2
-
3
- testcase "Examples" do
4
-
5
- context "plural form one example" do
6
- setup do
7
- @comment = TomParse::TomDoc.new %{
8
- # Duplicate some text an abitrary number of times.
9
- #
10
- # Examples
11
- # multiplex('Tom', 4)
12
- # # => 'TomTomTomTom'
13
- #
14
- # Returns something or another.
15
- }
16
- end
17
-
18
- test "there is one examples" do
19
- @comment.examples.size.assert == 1
20
- end
21
-
22
- test "the example" do
23
- @comment.examples.first.assert == "multiplex('Tom', 4)\n# => 'TomTomTomTom'"
24
- end
25
- end
26
-
27
- context "plural form multiple examples" do
28
- setup do
29
- @comment = TomParse::TomDoc.new %{
30
- # Duplicate some text an abitrary number of times.
31
- #
32
- # Examples
33
- # multiplex('Tom', 4)
34
- # # => 'TomTomTomTom'
35
- #
36
- # multiplex('Bo', 2)
37
- # # => 'BoBo'
38
- #
39
- # Returns something or another.
40
- }
41
- end
42
-
43
- test "there are two examples" do
44
- @comment.examples.size.assert == 2
45
- end
46
-
47
- test "the first example" do
48
- @comment.examples.first.assert == "multiplex('Tom', 4)\n# => 'TomTomTomTom'"
49
- end
50
-
51
- test "the second example" do
52
- @comment.examples.last.assert == "multiplex('Bo', 2)\n# => 'BoBo'"
53
- end
54
- end
55
-
56
- context "singular form" do
57
- setup do
58
- @comment = TomParse::TomDoc.new %{
59
- # Duplicate some text an abitrary number of times.
60
- #
61
- # Example
62
- # answer = multiplex('Tom', 4)
63
- #
64
- # return answer
65
- #
66
- # Returns something or another.
67
- }
68
- end
69
-
70
- test "there is one example" do
71
- @comment.examples.size.assert == 1
72
- end
73
-
74
- test "the example" do
75
- @comment.examples.first.assert == "answer = multiplex('Tom', 4)\n\nreturn answer"
76
- end
77
- end
78
-
79
- context "multiple example clauses" do
80
- setup do
81
- @comment = TomParse::TomDoc.new %{
82
- # Duplicate some text an abitrary number of times.
83
- #
84
- # Examples
85
- # multiplex('Tom', 4)
86
- # # => 'TomTomTomTom'
87
- #
88
- # multiplex('Bo', 2)
89
- # # => 'BoBo'
90
- #
91
- # Example
92
- # answer = multiplex('Tom', 4)
93
- #
94
- # return answer
95
- #
96
- # Returns something or another.
97
- }
98
- end
99
-
100
- test "there are three examples" do
101
- @comment.examples.size.assert == 3
102
- end
103
- end
104
-
105
- context "handles whitespace in examples" do
106
- setup do
107
- @comment = TomParse::TomDoc.new %{
108
- # Duplicate some text an abitrary number of times.
109
- #
110
- # Examples
111
- #
112
- # def multiplex(str, length)
113
- # str * length
114
- # end
115
- }
116
- end
117
-
118
- test "correctly handles whitespace with examples" do
119
- eg = @comment.examples[0].to_s
120
- eg.assert == "def multiplex(str, length)\n str * length\nend"
121
- end
122
- end
123
-
124
- end
@@ -1,42 +0,0 @@
1
- require_relative 'helper'
2
-
3
- testcase "Prefixes" do
4
-
5
- context "Internal" do
6
-
7
- setup do
8
- @tomdoc = TomParse::TomDoc.new(<<-END)
9
- # Internal: Some example text.
10
- END
11
- end
12
-
13
- test "internal?" do
14
- @tomdoc.assert.internal?
15
- end
16
-
17
- test "description" do
18
- @tomdoc.description.assert == "Some example text."
19
- end
20
-
21
- end
22
-
23
- context "Public" do
24
-
25
- setup do
26
- @tomdoc = TomParse::TomDoc.new(<<-END)
27
- # Public: Some example text.
28
- END
29
- end
30
-
31
- test "public?" do
32
- @tomdoc.assert.public?
33
- end
34
-
35
- test "description" do
36
- @tomdoc.description.assert == "Some example text."
37
- end
38
-
39
- end
40
-
41
-
42
- end
@@ -1,55 +0,0 @@
1
- require_relative 'helper'
2
-
3
- testcase "Signatures" do
4
-
5
- context "singular term" do
6
-
7
- setup do
8
- @comment = TomParse::TomDoc.new %{
9
- # Duplicate some text an abitrary number of times.
10
- #
11
- # Signature
12
- #
13
- # find(name)
14
- # find(name=>pattern)
15
- #
16
- }
17
- end
18
-
19
- test "knows if the method has alternate signatures" do
20
- @comment.signatures.size.assert == 2
21
- @comment.signatures.first.assert == "find(name)"
22
- @comment.signatures.last.assert == "find(name=>pattern)"
23
- end
24
-
25
- end
26
-
27
- context "plural term" do
28
-
29
- setup do
30
- @comment = TomParse::TomDoc.new %{
31
- # Duplicate some text an abitrary number of times.
32
- #
33
- # Signatures
34
- #
35
- # find_by_<field>[_and_<field>...](args)
36
- #
37
- }
38
- end
39
-
40
- test "knows if the method has alternate signatures" do
41
- @comment.signatures.size.assert == 1
42
- @comment.signatures.first.assert == "find_by_<field>[_and_<field>...](args)"
43
- end
44
-
45
- end
46
-
47
- #test "knows the fields associated with signatures" do
48
- # @comment.signature_fields.size.assert == 1
49
- #
50
- # arg = @comment.signature_fields.first
51
- # arg.name.assert == :field
52
- # arg.description.assert == "A field name."
53
- #end
54
-
55
- end
data/test/test_tags.rb DELETED
@@ -1,40 +0,0 @@
1
- require_relative 'helper'
2
-
3
- testcase "Tags" do
4
-
5
- context "TODO" do
6
-
7
- setup do
8
- @tomdoc = TomParse::TomDoc.new(<<-END)
9
- # This is an example of tags.
10
- #
11
- # TODO: Something we have to do.
12
- END
13
- end
14
-
15
- test "tags has todo" do
16
- @tomdoc.tags.size.assert == 1
17
- @tomdoc.tags.assert.include? ['TODO', 'Something we have to do.']
18
- end
19
-
20
- end
21
-
22
- context "FOO" do
23
-
24
- setup do
25
- @tomdoc = TomParse::TomDoc.new(<<-END)
26
- # This is an example of tags.
27
- #
28
- # Foo: They can be anything really.
29
- END
30
- end
31
-
32
- test "tags has foo" do
33
- @tomdoc.tags.size.assert == 1
34
- @tomdoc.tags.assert.include? ['Foo', 'They can be anything really.']
35
- end
36
-
37
- end
38
-
39
-
40
- end
data/test/test_tomdoc.rb DELETED
@@ -1,217 +0,0 @@
1
- require_relative 'helper'
2
-
3
- testcase TomParse::TomDoc do
4
-
5
- context "general parsing" do
6
-
7
- setup do
8
- @comment = TomParse::TomDoc.new %{
9
- # Duplicate some text an abitrary number of times.
10
- #
11
- # text - The String to be duplicated.
12
- # count - The Integer number of times to
13
- # duplicate the text.
14
- # reverse - An optional Boolean indicating
15
- # whether to reverse the result text or not.
16
- # options - Options (default: {})
17
- # :insert_spaces - Whether to insert spaces
18
- # :upcase - Convert the string to upper case
19
- # blk - The block.
20
- #
21
- # Examples
22
- # multiplex('Tom', 4)
23
- # # => 'TomTomTomTom'
24
- #
25
- # multiplex('Bo', 2)
26
- # # => 'BoBo'
27
- #
28
- # multiplex('Chris', -1)
29
- # # => nil
30
- #
31
- # Returns the duplicated String when the count is > 1.
32
- # Returns the atomic mass of the element as a Float. The value is in
33
- # unified atomic mass units.
34
- # Returns nil when the count is < 1.
35
- # Raises ExpectedString if the first argument is not a String.
36
- # Raises ExpectedInteger if the second argument is not an Integer.
37
- }
38
- end
39
-
40
- test "parses a description" do
41
- @comment.description.assert == "Duplicate some text an abitrary number of times."
42
- end
43
-
44
- test "parses args" do
45
- @comment.args.size.assert == 5
46
- end
47
-
48
- test "know a hash arg's options" do
49
- @comment.args[3].options.size.assert == 2
50
- @comment.args[3].options.first.name.assert == :':insert_spaces'
51
- @comment.args[3].options[1].name.assert == :':upcase'
52
- @comment.args[3].options.first.description.assert == 'Whether to insert spaces'
53
- @comment.args[3].options[1].description.assert == 'Convert the string to upper case'
54
- end
55
-
56
- test "knows an arg's name" do
57
- @comment.args.first.name.assert == :text
58
- @comment.args[1].name.assert == :count
59
- @comment.args[2].name.assert == :reverse
60
- @comment.args[3].name.assert == :options
61
- end
62
-
63
- test "knows an arg's description" do
64
- @comment.args[1].description.assert == 'The Integer number of times to duplicate the text.'
65
-
66
- reverse = 'An optional Boolean indicating whether to reverse the'
67
- reverse << ' result text or not.'
68
- @comment.args[2].description.assert == reverse
69
- end
70
-
71
- test "knows an arg's optionality" do
72
- refute @comment.args.first.optional?
73
- assert @comment.args[2].optional?
74
- end
75
-
76
- test "knows how many examples there are" do
77
- @comment.examples.size.assert == 3
78
- end
79
-
80
- test "knows each example" do
81
- @comment.examples[1].to_s.assert == "multiplex('Bo', 2)\n# => 'BoBo'"
82
- end
83
-
84
- test "knows how many return examples there are" do
85
- @comment.returns.size.assert == 3
86
- end
87
-
88
- test "knows if the method raises anything" do
89
- @comment.raises.size.assert == 2
90
- end
91
-
92
- test "knows each return example" do
93
- rtn = @comment.returns.first.to_s
94
- rtn.assert == "Returns the duplicated String when the count is > 1."
95
-
96
- string = ''
97
- string << "Returns the atomic mass of the element as a Float. "
98
- string << "The value is in unified atomic mass units."
99
- @comment.returns[1].to_s.assert == string
100
-
101
- @comment.returns[2].to_s.assert == "Returns nil when the count is < 1."
102
- end
103
-
104
- end
105
-
106
- context "handles multiple paragraph descriptions" do
107
- setup do
108
- @comment = TomParse::TomDoc.new %{
109
- # Has an initial paragraph.
110
- #
111
- # Has another paragraph in the description.
112
- #
113
- # Examples
114
- #
115
- # def multiplex(str, length)
116
- # str * length
117
- # end
118
- }
119
- end
120
-
121
- test "correctly handles multiple paragraphs" do
122
- @comment.description.assert == "Has an initial paragraph.\n\nHas another paragraph in the description."
123
- end
124
- end
125
-
126
- context "handles whitespace in examples" do
127
- setup do
128
- @comment = TomParse::TomDoc.new %{
129
- # Duplicate some text an abitrary number of times.
130
- #
131
- # Examples
132
- #
133
- # def multiplex(str, length)
134
- # str * length
135
- # end
136
- }
137
- end
138
-
139
- test "correctly handles whitespace with examples" do
140
- eg = @comment.examples[0].to_s
141
- eg.assert == "def multiplex(str, length)\n str * length\nend"
142
- end
143
- end
144
-
145
- context "without arguments or examples" do
146
-
147
- setup do
148
- @comment = TomParse::TomDoc.new %{
149
- # Duplicate some text an abitrary number of times.
150
- #
151
- # Returns the duplicated String.
152
- }
153
- end
154
-
155
- test "knows what to do when there are no args" do
156
- @comment.args.size.assert == 0
157
- end
158
-
159
- test "knows what to do when there are no examples" do
160
- @comment.examples.size.assert == 0
161
- end
162
-
163
- test "knows what to do when there are no return examples" do
164
- @comment.examples.size.assert == 0
165
- end
166
-
167
- end
168
-
169
-
170
- context "invalid documentation" do
171
-
172
- setup do
173
- @comment = TomParse::TomDoc.new %{
174
- # Duplicate some text an abitrary number of times.
175
- #
176
- # Examples
177
- #
178
- # multiplex('Tom', 4)
179
- # # => 'TomTomTomTom'
180
- #
181
- # multiplex('Bo', 2)
182
- # # => 'BoBo'
183
- }
184
- end
185
-
186
- test "knows when TomDoc is invalid" do
187
- expect TomParse::ParseError do
188
- @comment.validate
189
- end
190
- end
191
-
192
- end
193
-
194
-
195
- context "without comment marker" do
196
-
197
- setup do
198
- @comment = TomParse::TomDoc.new %{
199
- Duplicate some text an abitrary number of times.
200
-
201
- Yields the Integer index of the iteration.
202
-
203
- Signature
204
-
205
- find_by_<field>[_and_<field>...](args)
206
-
207
- field - A field name.
208
- }
209
- end
210
-
211
- test "can handle comments without comment marker" do
212
- @comment.description.assert == "Duplicate some text an abitrary number of times."
213
- end
214
-
215
- end
216
-
217
- end
data/test/test_yields.rb DELETED
@@ -1,17 +0,0 @@
1
- require_relative 'helper'
2
-
3
- testcase "Yields" do
4
-
5
- setup do
6
- @comment = TomParse::TomDoc.new %{
7
- # Duplicate some text an abitrary number of times.
8
- #
9
- # Yields the Integer index of the iteration.
10
- }
11
- end
12
-
13
- test "knows what the method yields" do
14
- @comment.yields.assert == "Yields the Integer index of the iteration."
15
- end
16
-
17
- end