yard-tomdoc 0.5.0 → 0.6.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.
data/.index ADDED
@@ -0,0 +1,62 @@
1
+ ---
2
+ revision: 2013
3
+ type: ruby
4
+ sources:
5
+ - INDEX.yml
6
+ authors:
7
+ - name: Trans
8
+ email: transfire@gmail.com
9
+ - name: Loren Segal
10
+ organizations: []
11
+ requirements:
12
+ - name: yard
13
+ - version: 0.3.0+
14
+ name: tomparse
15
+ - name: rc
16
+ - groups:
17
+ - build
18
+ development: true
19
+ name: detroit
20
+ - groups:
21
+ - test
22
+ development: true
23
+ name: spectroscope
24
+ - groups:
25
+ - test
26
+ development: true
27
+ name: ae
28
+ conflicts: []
29
+ alternatives: []
30
+ resources:
31
+ - type: home
32
+ uri: http://rubyworks.github.com/yard-tomdoc
33
+ label: Homepage
34
+ - type: code
35
+ uri: http://github.com/rubyworks/yard-tomdoc
36
+ label: Source Code
37
+ - type: bugs
38
+ uri: http://github.com/rubyworks/yard-tomdoc/issues
39
+ label: Issue Tracker
40
+ - type: docs
41
+ uri: http://rubydoc.info/gems/yard-tomdoc/frames
42
+ label: Documentation
43
+ repositories: []
44
+ categories: []
45
+ copyrights:
46
+ - holder: Rubyworks
47
+ year: '2012'
48
+ license: MIT
49
+ - holder: Loren Segal
50
+ year: '2010'
51
+ license: MIT
52
+ customs: []
53
+ paths:
54
+ lib:
55
+ - lib
56
+ version: 0.6.0
57
+ name: yard-tomdoc
58
+ title: YARD TomDoc
59
+ summary: TomDoc for YARD
60
+ description: Use TomDoc documentation format with YARD.
61
+ webcvs: https://github.com/rubyworks/yard-tomdoc/tree/master
62
+ date: '2013-01-22'
data/.rubyrc ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ config 'rubytest' do |run|
4
+ require 'spectroscope'
5
+ require 'ae'
6
+
7
+ $:.unshift 'lib'
8
+ $:.unshift 'test'
9
+
10
+ run.files << 'test/**/test_*.rb'
11
+ end
12
+
13
+ config 'rubytest', :profile=>:cov do |run|
14
+ require 'spectroscope'
15
+ require 'ae'
16
+ require 'simplecov'
17
+
18
+ $:.unshift 'lib'
19
+ $:.unshift 'test'
20
+
21
+ run.files << 'test/**/test_*.rb'
22
+
23
+ dir = $properties.coverage_folder
24
+
25
+ SimpleCov.command_name 'Ruby Tests'
26
+
27
+ SimpleCov.start do
28
+ coverage_dir(dir || 'log/coverage')
29
+ #add_group "Label", "lib/qed/directory"
30
+ end
31
+ end
32
+
@@ -0,0 +1,9 @@
1
+ --title "YARD TomDoc"
2
+ --readme README.md
3
+ --protected
4
+ --private
5
+ --plugin tomdoc
6
+ lib
7
+ -
8
+ *.md
9
+ *.txt
data/HISTORY.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # RELEASE HISTORY
2
2
 
3
+ ## 0.6.0 / 2013-01-22
4
+
5
+ This new major release adds support for most YARD tags thanks to TomParse's
6
+ new support of tag markers. It also fixes a few annoying bugs, such a
7
+ options parsing and multi-line paragraph descriptions.
8
+
9
+ Changes:
10
+
11
+ * Add support for most YARD tags.
12
+ * Fix support for option hashes.
13
+ * Fix support for multi-paragraph descriptions.
14
+
15
+
3
16
  ## 0.5.0 / 2012-06-14
4
17
 
5
18
  Version 0.8.0 of YARD broke the yard-tomdoc plugin. After some discussion with
@@ -1,6 +1,4 @@
1
- YARD::TomDoc - Use TomDoc with YARD
2
-
3
- Copyright (c) 2010 Loren Segal, Thomas Sawyer (MIT License)
1
+ (MIT License)
4
2
 
5
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
4
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  [Issues](http://github.com/rubyworks/yard-tomdoc/issues)
6
6
 
7
7
  [![Build Status](https://secure.travis-ci.org/rubyworks/yard-tomdoc.png)](http://travis-ci.org/rubyworks/yard-tomdoc)
8
+ [![Gem Version](https://badge.fury.io/rb/yard-tomdoc.png)](http://badge.fury.io/rb/yard-tomdoc)
8
9
 
9
10
 
10
11
  ## Description
@@ -37,11 +38,18 @@ Before you use yard-tomdoc you should read about the differences between YARD
37
38
  and TomDoc syntax [here](http://gnuu.org/2010/05/12/whats-missing-from-tomdoc/).
38
39
 
39
40
 
41
+ ## Acknowledgements
42
+
43
+ Huge thanks to Loren Segal, the creator of YARD and the original author of this plugin.
44
+ Without his patient assistance and coding genius, this library would not have been possible.
45
+
46
+
40
47
  ## Licensing
41
48
 
42
- Copyright (c) 2010 Loren Segal, Thomas Sawyer
49
+ Yard::TomDoc is copyrighted open-source software.
43
50
 
44
- YARD::TomDoc is distributable in accordance with the ters of the **MIT** licsnse.
51
+ Copyright (c) 2010 Rubyworks. All rights reserved.
45
52
 
46
- See the `LICENSE.txt` file for details.
53
+ YARD::TomDoc can be modified and redistributed in accordance with the ters of the **MIT** licsnse.
47
54
 
55
+ See the `LICENSE.txt` file for details.
@@ -3,24 +3,11 @@ require 'tomparse'
3
3
  module YARD
4
4
 
5
5
  module TomDoc
6
- # Metadata from the project's `yard-tomdoc.yml` fle.
7
- #
8
- # Returns [Hash] of metadata.
9
- def self.metadata
10
- @metadata ||= (
11
- require 'yaml'
12
- YAML.load_file(File.dirname(__FILE__) + '/yard-tomdoc.yml')
13
- )
14
- end
6
+ # Distribution name of this program.
7
+ NAME = 'yard-tomdoc'
15
8
 
16
- # When a constant is missing, see if it is a metadata entry.
17
- #
18
- # name - [Symbol] constant name
19
- #
20
- # Returns metadata value.
21
- def self.const_missing(name)
22
- metadata[name.to_s.downcase] || super(name)
23
- end
9
+ # Tags supported by YARD that Tomparse can handle.
10
+ TAGS = %w{abstract attr attr_reader attr_writer attribute author deprecated note see since todo version}
24
11
 
25
12
  # Parse comments with TomDoc and then provide YARD with results.
26
13
  #
@@ -37,16 +24,16 @@ module YARD
37
24
  # TODO: how to figure-out class of argument ?
38
25
  tomdoc.arguments.each {|arg| yard.create_tag(:param, "#{arg.name} #{arg.description}") }
39
26
 
40
- if last_argument = tomdoc.arguments.last
41
- last_argument.options.each do |opt|
42
- yard.create_tag(:option, "#{last_argument.name} #{opt.description}")
27
+ tomdoc.arguments.each do |arg|
28
+ arg.options.each do |opt|
29
+ yard.create_tag(:option, "#{arg.name} #{opt.name} #{opt.description}")
43
30
  end
44
31
  end
45
32
 
46
33
  tomdoc.raises.each {|r| yard.create_tag(:raise, r.sub(/\ARaises\s+/, '')) }
47
34
 
48
35
  tomdoc.returns.each do |r|
49
- # TODO: improve how we figure out class of argument
36
+ # TODO: improve how we figure out class of argument
50
37
  if md = /\AReturns\s+([A-Z].*?)\s+/.match(r)
51
38
  klass = md[1]
52
39
  desc = md.post_match
@@ -64,8 +51,49 @@ module YARD
64
51
  yard.create_tag(:api, 'public') if tomdoc.public?
65
52
  yard.create_tag(:api, 'private') if tomdoc.internal?
66
53
 
54
+ tomdoc.tags.each do |label, desc|
55
+ if TAGS.include?(label.to_s)
56
+ yard.create_tag(label.to_sym, desc.to_s)
57
+ end
58
+ end
59
+
67
60
  tomdoc
68
61
  end
62
+
63
+ #
64
+ def self.const_missing(name)
65
+ metadata[name.to_s.downcase] || super(name)
66
+ end
67
+
68
+ # TODO: The #to_s on the gemspec return value is a bit too simplistic. But how to fix?
69
+ # The goal is reduce the value to a basic type (String, Hash, Array, Numeric).
70
+
71
+ # When a constant is missing, see if it is a metadata entry.
72
+ # Metadata comes from the RubyGem, and fallsback to project index file.
73
+ #
74
+ # name - [Symbol] constant name
75
+ #
76
+ # Returns metadata value.
77
+ def self.const_missing(const_name)
78
+ name = const_name.to_s.downcase
79
+ #begin
80
+ # Gem.loaded_specs[NAME].send(name).to_s
81
+ #rescue StandardError
82
+ index[name] || super(const_name)
83
+ #end
84
+ end
85
+
86
+ # Metadata from the `yard-tomdoc.yml` or `.index` file.
87
+ #
88
+ # Returns [Hash] of metadata.
89
+ def self.index
90
+ @index ||= (
91
+ require 'yaml'
92
+ dir = File.dirname(__FILE__)
93
+ file = Dir[File.join(dir, "{#{NAME}.yml,../.index}")].first
94
+ file ? YAML.load_file(file) : {}
95
+ )
96
+ end
69
97
  end
70
98
 
71
99
  if VERSION > '0.8'
@@ -75,5 +103,4 @@ module YARD
75
103
  else
76
104
  require 'yard-tomdoc/yard070'
77
105
  end
78
-
79
106
  end
@@ -1,59 +1,62 @@
1
1
  ---
2
- source:
3
- - Profile
2
+ revision: 2013
3
+ type: ruby
4
+ sources:
5
+ - INDEX.yml
4
6
  authors:
5
7
  - name: Trans
6
8
  email: transfire@gmail.com
7
9
  - name: Loren Segal
8
- copyrights:
9
- - holder: Rubyworks
10
- year: '2012'
11
- license: MIT
12
- - holder: Loren Segal
13
- year: '2010'
14
- license: MIT
10
+ organizations: []
15
11
  requirements:
16
12
  - name: yard
17
- - name: tomparse
13
+ - version: 0.3.0+
14
+ name: tomparse
18
15
  - name: rc
19
- - name: detroit
20
- groups:
16
+ - groups:
21
17
  - build
22
18
  development: true
23
- - name: spectroscope
24
- groups:
19
+ name: detroit
20
+ - groups:
25
21
  - test
26
22
  development: true
27
- - name: ae
28
- groups:
23
+ name: spectroscope
24
+ - groups:
29
25
  - test
30
26
  development: true
31
- dependencies: []
32
- alternatives: []
27
+ name: ae
33
28
  conflicts: []
34
- repositories: []
29
+ alternatives: []
35
30
  resources:
36
- - uri: http://rubyworks.github.com/yard-tomdoc
37
- label: Website
38
- type: home
39
- - uri: http://github.com/rubyworks/yard-tomdoc
31
+ - type: home
32
+ uri: http://rubyworks.github.com/yard-tomdoc
33
+ label: Homepage
34
+ - type: code
35
+ uri: http://github.com/rubyworks/yard-tomdoc
40
36
  label: Source Code
41
- type: code
42
- - uri: http://github.com/rubyworks/yard-tomdoc/issues
37
+ - type: bugs
38
+ uri: http://github.com/rubyworks/yard-tomdoc/issues
43
39
  label: Issue Tracker
44
- type: bugs
45
- - uri: http://rubydoc.info/gems/yard-tomdoc/frames
40
+ - type: docs
41
+ uri: http://rubydoc.info/gems/yard-tomdoc/frames
46
42
  label: Documentation
47
- type: docs
43
+ repositories: []
48
44
  categories: []
49
- extra: {}
50
- load_path:
51
- - lib
52
- revision: 0
45
+ copyrights:
46
+ - holder: Rubyworks
47
+ year: '2012'
48
+ license: MIT
49
+ - holder: Loren Segal
50
+ year: '2010'
51
+ license: MIT
52
+ customs: []
53
+ paths:
54
+ lib:
55
+ - lib
56
+ version: 0.6.0
53
57
  name: yard-tomdoc
54
58
  title: YARD TomDoc
55
- version: 0.5.0
56
59
  summary: TomDoc for YARD
57
60
  description: Use TomDoc documentation format with YARD.
58
61
  webcvs: https://github.com/rubyworks/yard-tomdoc/tree/master
59
- date: '2012-06-14'
62
+ date: '2013-01-22'
@@ -19,6 +19,9 @@ describe YARD::Docstring do
19
19
  #
20
20
  # text - The String to be duplicated.
21
21
  # count - The Integer number of times to duplicate the text.
22
+ # options - Options (default: {})
23
+ # :a - Option a
24
+ # :b - Option b
22
25
  #
23
26
  # Examples
24
27
  # multiplex('Tom', 4)
@@ -38,9 +41,21 @@ eof
38
41
 
39
42
  it "should fill param tags" do
40
43
  tags = @docstring.tags(:param)
41
- tags.size.assert == 2
44
+ tags.size.assert == 3
42
45
  tags[0].name.assert == 'text'
43
46
  tags[1].name.assert == 'count'
47
+ tags[2].name.assert == 'options'
48
+ end
49
+
50
+ it "should fill options tags" do
51
+ tags = @docstring.tags(:option)
52
+ tags.size.assert == 2
53
+ tags[0].name.assert == 'options'
54
+ tags[0].pair.name.assert == ':a'
55
+ tags[0].pair.text.assert == 'Option a'
56
+ tags[1].name.assert == 'options'
57
+ tags[1].pair.name.assert == ':b'
58
+ tags[1].pair.text.assert == 'Option b'
44
59
  end
45
60
 
46
61
  it "should fill examples tags" do
@@ -0,0 +1,101 @@
1
+ require 'helper.rb'
2
+
3
+ require "yard"
4
+ require "yard-tomdoc"
5
+
6
+ describe YARD::Docstring do
7
+
8
+ make_docstring = Proc.new do |comment|
9
+ if YARD::VERSION == '0.8.0'
10
+ YARD::DocstringParser.new.parse(comment, self).to_docstring
11
+ else
12
+ YARD::Docstring.new(comment)
13
+ end
14
+ end
15
+
16
+ before do
17
+ comment = <<-eof
18
+ # Duplicate some text an arbitrary number of times.
19
+ #
20
+ # text - The String to be duplicated.
21
+ # count - The Integer number of times to duplicate the text.
22
+ # options - Options (default: {})
23
+ # :a - Option a
24
+ # :b - Option b
25
+ #
26
+ # Examples
27
+ # multiplex('Tom', 4)
28
+ # # => 'TomTomTomTom'
29
+ #
30
+ # TODO: There something important to be done!
31
+ #
32
+ # Returns the duplicated String.
33
+ #
34
+ # Raises ArgumentError if something bad happened
35
+ eof
36
+
37
+ @docstring = make_docstring[comment]
38
+ end
39
+
40
+ it "should fill todo tags" do
41
+ tags = @docstring.tags(:todo)
42
+ tags.size.assert == 1
43
+ tags[0].text.assert == 'There something important to be done!'
44
+ end
45
+
46
+ it "should fill docstring with description" do
47
+ @docstring.assert == "Duplicate some text an arbitrary number of times."
48
+ end
49
+
50
+ it "should fill param tags" do
51
+ tags = @docstring.tags(:param)
52
+ tags.size.assert == 3
53
+ tags[0].name.assert == 'text'
54
+ tags[1].name.assert == 'count'
55
+ tags[2].name.assert == 'options'
56
+ end
57
+
58
+ it "should fill options tags" do
59
+ tags = @docstring.tags(:option)
60
+ tags.size.assert == 2
61
+ tags[0].name.assert == 'options'
62
+ tags[0].pair.name.assert == ':a'
63
+ tags[0].pair.text.assert == 'Option a'
64
+ tags[1].name.assert == 'options'
65
+ tags[1].pair.name.assert == ':b'
66
+ tags[1].pair.text.assert == 'Option b'
67
+ end
68
+
69
+ it "should fill examples tags" do
70
+ @docstring.tags(:example).size.assert == 1
71
+ @docstring.tag(:example).text.assert == "multiplex('Tom', 4)\n# => 'TomTomTomTom'"
72
+ end
73
+
74
+ it "should fill return tag" do
75
+ @docstring.tag(:return).text.assert == "the duplicated String."
76
+ end
77
+
78
+ it "should fill raise tag" do
79
+ @docstring.tag(:raise).text.assert == "ArgumentError if something bad happened"
80
+ end
81
+
82
+ describe "Internal description" do
83
+
84
+ it "should fill api private tag" do
85
+ docstring = make_docstring["# Internal: It will do a big things in future"]
86
+ docstring.tag(:api).text.assert == "private"
87
+ end
88
+
89
+ end
90
+
91
+ describe "Deprecated description" do
92
+
93
+ it "should fill deprecated tag" do
94
+ docstring = make_docstring["# Deprecated: Some description."]
95
+ docstring.tag(:deprecated).text.assert == "Do not use this in new code, and replace it when updating old code."
96
+ end
97
+
98
+ end
99
+
100
+ end
101
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard-tomdoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-06-14 00:00:00.000000000 Z
13
+ date: 2013-01-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: yard
17
- requirement: &22873120 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,21 +22,31 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *22873120
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
26
31
  - !ruby/object:Gem::Dependency
27
32
  name: tomparse
28
- requirement: &22872480 !ruby/object:Gem::Requirement
33
+ requirement: !ruby/object:Gem::Requirement
29
34
  none: false
30
35
  requirements:
31
36
  - - ! '>='
32
37
  - !ruby/object:Gem::Version
33
- version: '0'
38
+ version: 0.3.0
34
39
  type: :runtime
35
40
  prerelease: false
36
- version_requirements: *22872480
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: 0.3.0
37
47
  - !ruby/object:Gem::Dependency
38
48
  name: rc
39
- requirement: &22871820 !ruby/object:Gem::Requirement
49
+ requirement: !ruby/object:Gem::Requirement
40
50
  none: false
41
51
  requirements:
42
52
  - - ! '>='
@@ -44,10 +54,15 @@ dependencies:
44
54
  version: '0'
45
55
  type: :runtime
46
56
  prerelease: false
47
- version_requirements: *22871820
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
48
63
  - !ruby/object:Gem::Dependency
49
64
  name: detroit
50
- requirement: &22871280 !ruby/object:Gem::Requirement
65
+ requirement: !ruby/object:Gem::Requirement
51
66
  none: false
52
67
  requirements:
53
68
  - - ! '>='
@@ -55,10 +70,15 @@ dependencies:
55
70
  version: '0'
56
71
  type: :development
57
72
  prerelease: false
58
- version_requirements: *22871280
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
59
79
  - !ruby/object:Gem::Dependency
60
80
  name: spectroscope
61
- requirement: &22870680 !ruby/object:Gem::Requirement
81
+ requirement: !ruby/object:Gem::Requirement
62
82
  none: false
63
83
  requirements:
64
84
  - - ! '>='
@@ -66,10 +86,15 @@ dependencies:
66
86
  version: '0'
67
87
  type: :development
68
88
  prerelease: false
69
- version_requirements: *22870680
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
70
95
  - !ruby/object:Gem::Dependency
71
96
  name: ae
72
- requirement: &22870080 !ruby/object:Gem::Requirement
97
+ requirement: !ruby/object:Gem::Requirement
73
98
  none: false
74
99
  requirements:
75
100
  - - ! '>='
@@ -77,7 +102,12 @@ dependencies:
77
102
  version: '0'
78
103
  type: :development
79
104
  prerelease: false
80
- version_requirements: *22870080
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
81
111
  description: Use TomDoc documentation format with YARD.
82
112
  email:
83
113
  - transfire@gmail.com
@@ -88,6 +118,9 @@ extra_rdoc_files:
88
118
  - HISTORY.md
89
119
  - README.md
90
120
  files:
121
+ - .index
122
+ - .rubyrc
123
+ - .yardopts
91
124
  - lib/yard-tomdoc/yard070.rb
92
125
  - lib/yard-tomdoc/yard080.rb
93
126
  - lib/yard-tomdoc/yard081.rb
@@ -98,10 +131,10 @@ files:
98
131
  - test/system/sample/lib/hello_world.rb
99
132
  - test/system/test_yardoc.rb
100
133
  - test/unit/test_docstring.rb
101
- - LICENSE.txt
134
+ - test/unit/test_tags.rb
102
135
  - HISTORY.md
103
136
  - README.md
104
- - Config.rb
137
+ - LICENSE.txt
105
138
  homepage: http://rubyworks.github.com/yard-tomdoc
106
139
  licenses:
107
140
  - MIT
@@ -124,8 +157,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
157
  version: '0'
125
158
  requirements: []
126
159
  rubyforge_project:
127
- rubygems_version: 1.8.11
160
+ rubygems_version: 1.8.24
128
161
  signing_key:
129
162
  specification_version: 3
130
163
  summary: TomDoc for YARD
131
- test_files: []
164
+ test_files:
165
+ - test/system/test_yardoc.rb
166
+ - test/system/sample/lib/example.rb
167
+ - test/system/sample/lib/hello_world.rb
168
+ - test/helper.rb
169
+ - test/unit/test_docstring.rb
170
+ - test/unit/test_tags.rb
171
+ has_rdoc:
data/Config.rb DELETED
@@ -1,11 +0,0 @@
1
-
2
- config 'rubytest' do |run|
3
- require 'spectroscope'
4
- require 'ae'
5
-
6
- $:.unshift 'lib'
7
- $:.unshift 'test'
8
-
9
- run.files << 'test/**/test_*.rb'
10
- end
11
-