yard-tomdoc 0.4.0 → 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.
- data/Config.rb +11 -0
- data/HISTORY.md +20 -1
- data/README.md +11 -0
- data/lib/yard-tomdoc.rb +26 -18
- data/lib/yard-tomdoc.yml +17 -6
- data/lib/yard-tomdoc/yard070.rb +13 -0
- data/lib/yard-tomdoc/yard080.rb +32 -0
- data/lib/yard-tomdoc/yard081.rb +25 -0
- data/test/unit/test_docstring.rb +33 -3
- metadata +27 -12
data/Config.rb
ADDED
data/HISTORY.md
CHANGED
@@ -1,6 +1,25 @@
|
|
1
1
|
# RELEASE HISTORY
|
2
2
|
|
3
|
-
## 0.
|
3
|
+
## 0.5.0 / 2012-06-14
|
4
|
+
|
5
|
+
Version 0.8.0 of YARD broke the yard-tomdoc plugin. After some discussion with
|
6
|
+
Loren Segal, the developer of YARD, he decided that a new API was needed for
|
7
|
+
plugins like yard-tomdoc. So YARD 0.8.1 was born. This release takes advantage
|
8
|
+
of the new API. If you are using the latest and greatest version of YARD, you
|
9
|
+
need to upgrade to yard-tomdoc 0.5+ too.
|
10
|
+
|
11
|
+
Changes:
|
12
|
+
|
13
|
+
* Improved support for YARD 0.8.1+.
|
14
|
+
* Support multiple versions of YARD in a nice way.
|
15
|
+
* Use @api private tag instead of @private for Internal status.
|
16
|
+
* Add support for YARD version 0.8+.
|
17
|
+
* Fixes for Internal and Deprecated marks.
|
18
|
+
* Fix error for 'Deprecated' description
|
19
|
+
* Fix Issue #3, Error for 'Internal' description.
|
20
|
+
|
21
|
+
|
22
|
+
## 0.4.0 / 2012-03-04
|
4
23
|
|
5
24
|
This major release now uses tomparse gem for parsing TomDoc,
|
6
25
|
instead of the tomdoc gem. This library only handles parsing
|
data/README.md
CHANGED
@@ -20,6 +20,17 @@ Since `yard-tomdoc` is a standard YARD plugin, utilize it with yard's
|
|
20
20
|
$ yard --plugin yard-tomdoc [...]
|
21
21
|
|
22
22
|
|
23
|
+
## Documentation
|
24
|
+
|
25
|
+
### API
|
26
|
+
|
27
|
+
* Shomen -
|
28
|
+
[Rebecca](http://rubyworks.github.com/rebecca?doc=http://rubyworks.github.com/yard-tomdoc/docs/current.json) /
|
29
|
+
[Hypervisor](http://rubyworks.github.com/hypervisor?doc=http://rubyworks.github.com/yard-tomdoc/docs/current.json) /
|
30
|
+
[Rubyfaux](http://rubyworks.github.com/rubyfaux?doc=http://rubyworks.github.com/yard-tomdoc/docs/current.json)
|
31
|
+
* YARD - [RubyDoc.info](http://rubydoc.info/gems/yard-tomdoc/frames)
|
32
|
+
|
33
|
+
|
23
34
|
## Limitations
|
24
35
|
|
25
36
|
Before you use yard-tomdoc you should read about the differences between YARD
|
data/lib/yard-tomdoc.rb
CHANGED
@@ -21,51 +21,59 @@ module YARD
|
|
21
21
|
def self.const_missing(name)
|
22
22
|
metadata[name.to_s.downcase] || super(name)
|
23
23
|
end
|
24
|
-
end
|
25
24
|
|
26
|
-
class Docstring
|
27
25
|
# Parse comments with TomDoc and then provide YARD with results.
|
28
26
|
#
|
29
|
-
#
|
27
|
+
# yard - [Docstring,DocstringParser] instance of yard object
|
28
|
+
# comment - [String] comment string
|
30
29
|
#
|
31
|
-
# Returns [
|
32
|
-
def
|
33
|
-
comment = [comments].flatten.join("\n")
|
34
|
-
|
30
|
+
# Returns [TomDoc] instance of TomDoc
|
31
|
+
def self.yard_parse(yard, comment)
|
35
32
|
tomdoc = TomParse.parse(comment)
|
36
33
|
|
37
|
-
|
34
|
+
# TODO: TomParse should make the `strip` unecessary
|
35
|
+
tomdoc.examples.each {|ex| yard.create_tag(:example, "\n" + ex.strip) }
|
38
36
|
|
39
|
-
|
37
|
+
# TODO: how to figure-out class of argument ?
|
38
|
+
tomdoc.arguments.each {|arg| yard.create_tag(:param, "#{arg.name} #{arg.description}") }
|
40
39
|
|
41
40
|
if last_argument = tomdoc.arguments.last
|
42
41
|
last_argument.options.each do |opt|
|
43
|
-
create_tag(:option, "#{last_argument.name} #{opt.description}")
|
42
|
+
yard.create_tag(:option, "#{last_argument.name} #{opt.description}")
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
47
|
-
tomdoc.raises.each {|r| create_tag(:raise, r.sub(/\ARaises\s+/, '')) }
|
46
|
+
tomdoc.raises.each {|r| yard.create_tag(:raise, r.sub(/\ARaises\s+/, '')) }
|
48
47
|
|
49
48
|
tomdoc.returns.each do |r|
|
49
|
+
# TODO: improve how we figure out class of argument
|
50
50
|
if md = /\AReturns\s+([A-Z].*?)\s+/.match(r)
|
51
51
|
klass = md[1]
|
52
52
|
desc = md.post_match
|
53
|
-
create_tag(:return, "[#{klass}] #{desc}")
|
53
|
+
yard.create_tag(:return, "[#{klass}] #{desc}")
|
54
54
|
else
|
55
55
|
desc = r.sub(/\AReturns\s+/, '')
|
56
|
-
create_tag(:return, desc)
|
56
|
+
yard.create_tag(:return, desc)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
create_tag(:yield, tomdoc.yields) if tomdoc.yields
|
60
|
+
yard.create_tag(:yield, tomdoc.yields) if tomdoc.yields
|
61
61
|
|
62
|
-
create_tag(:deprecated) if tomdoc.deprecated?
|
62
|
+
yard.create_tag(:deprecated, 'Do not use this in new code, and replace it when updating old code.') if tomdoc.deprecated?
|
63
63
|
|
64
|
-
create_tag(:
|
64
|
+
yard.create_tag(:api, 'public') if tomdoc.public?
|
65
|
+
yard.create_tag(:api, 'private') if tomdoc.internal?
|
65
66
|
|
66
|
-
|
67
|
-
tomdoc.description.to_s
|
67
|
+
tomdoc
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
if VERSION > '0.8'
|
72
|
+
require 'yard-tomdoc/yard081'
|
73
|
+
elsif VERSION == '0.8'
|
74
|
+
require 'yard-tomdoc/yard080'
|
75
|
+
else
|
76
|
+
require 'yard-tomdoc/yard070'
|
77
|
+
end
|
78
|
+
|
71
79
|
end
|
data/lib/yard-tomdoc.yml
CHANGED
@@ -15,6 +15,7 @@ copyrights:
|
|
15
15
|
requirements:
|
16
16
|
- name: yard
|
17
17
|
- name: tomparse
|
18
|
+
- name: rc
|
18
19
|
- name: detroit
|
19
20
|
groups:
|
20
21
|
- build
|
@@ -32,17 +33,27 @@ alternatives: []
|
|
32
33
|
conflicts: []
|
33
34
|
repositories: []
|
34
35
|
resources:
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
- uri: http://rubyworks.github.com/yard-tomdoc
|
37
|
+
label: Website
|
38
|
+
type: home
|
39
|
+
- uri: http://github.com/rubyworks/yard-tomdoc
|
40
|
+
label: Source Code
|
41
|
+
type: code
|
42
|
+
- uri: http://github.com/rubyworks/yard-tomdoc/issues
|
43
|
+
label: Issue Tracker
|
44
|
+
type: bugs
|
45
|
+
- uri: http://rubydoc.info/gems/yard-tomdoc/frames
|
46
|
+
label: Documentation
|
47
|
+
type: docs
|
48
|
+
categories: []
|
39
49
|
extra: {}
|
40
50
|
load_path:
|
41
51
|
- lib
|
42
52
|
revision: 0
|
43
53
|
name: yard-tomdoc
|
44
54
|
title: YARD TomDoc
|
45
|
-
version: 0.
|
55
|
+
version: 0.5.0
|
46
56
|
summary: TomDoc for YARD
|
47
57
|
description: Use TomDoc documentation format with YARD.
|
48
|
-
|
58
|
+
webcvs: https://github.com/rubyworks/yard-tomdoc/tree/master
|
59
|
+
date: '2012-06-14'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module YARD
|
2
|
+
|
3
|
+
class DocstringParser
|
4
|
+
def parse(content, object = nil, handler = nil)
|
5
|
+
@object = object
|
6
|
+
@handler = handler
|
7
|
+
@raw_text = content
|
8
|
+
|
9
|
+
if object
|
10
|
+
text = parse_tomdoc(content)
|
11
|
+
else
|
12
|
+
text = parse_content(content)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Remove trailing/leading whitespace / newlines
|
16
|
+
@text = text.gsub(/\A[\r\n\s]+|[\r\n\s]+\Z/, '')
|
17
|
+
call_directives_after_parse
|
18
|
+
call_after_parse_callbacks
|
19
|
+
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
def parse_tomdoc(content)
|
25
|
+
tomdoc = TomDoc.yard_parse(self, content)
|
26
|
+
tomdoc.description.to_s
|
27
|
+
end
|
28
|
+
|
29
|
+
public :create_tag
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module YARD
|
2
|
+
|
3
|
+
# Plugin parser for parsing TomDoc formatted comments.
|
4
|
+
#
|
5
|
+
class TomDocParser < DocstringParser
|
6
|
+
|
7
|
+
#
|
8
|
+
def parse_content(content)
|
9
|
+
# TODO: move TomDoc.yard_parse code to here when old versions are no longer supported
|
10
|
+
tomdoc = TomDoc.yard_parse(self, content)
|
11
|
+
text = tomdoc.description.to_s
|
12
|
+
|
13
|
+
# Remove trailing/leading whitespace / newlines
|
14
|
+
@text = text.gsub(/\A[\r\n\s]+|[\r\n\s]+\Z/, '')
|
15
|
+
end
|
16
|
+
|
17
|
+
public :create_tag
|
18
|
+
end
|
19
|
+
|
20
|
+
# Set the parser as default when parsing
|
21
|
+
YARD::Docstring.default_parser = TomDocParser
|
22
|
+
|
23
|
+
# TODO: what about reset callbacks ?
|
24
|
+
end
|
25
|
+
|
data/test/unit/test_docstring.rb
CHANGED
@@ -5,8 +5,16 @@ require "yard-tomdoc"
|
|
5
5
|
|
6
6
|
describe YARD::Docstring do
|
7
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
|
+
|
8
16
|
before do
|
9
|
-
|
17
|
+
comment = <<-eof
|
10
18
|
# Duplicate some text an arbitrary number of times.
|
11
19
|
#
|
12
20
|
# text - The String to be duplicated.
|
@@ -20,6 +28,8 @@ describe YARD::Docstring do
|
|
20
28
|
#
|
21
29
|
# Raises ArgumentError if something bad happened
|
22
30
|
eof
|
31
|
+
|
32
|
+
@docstring = make_docstring[comment]
|
23
33
|
end
|
24
34
|
|
25
35
|
it "should fill docstring with description" do
|
@@ -32,10 +42,10 @@ eof
|
|
32
42
|
tags[0].name.assert == 'text'
|
33
43
|
tags[1].name.assert == 'count'
|
34
44
|
end
|
35
|
-
|
45
|
+
|
36
46
|
it "should fill examples tags" do
|
37
47
|
@docstring.tags(:example).size.assert == 1
|
38
|
-
@docstring.tag(:example).text.assert == "multiplex('Tom', 4)\n
|
48
|
+
@docstring.tag(:example).text.assert == "multiplex('Tom', 4)\n# => 'TomTomTomTom'"
|
39
49
|
end
|
40
50
|
|
41
51
|
it "should fill return tag" do
|
@@ -45,4 +55,24 @@ eof
|
|
45
55
|
it "should fill raise tag" do
|
46
56
|
@docstring.tag(:raise).text.assert == "ArgumentError if something bad happened"
|
47
57
|
end
|
58
|
+
|
59
|
+
describe "Internal description" do
|
60
|
+
|
61
|
+
it "should fill api private tag" do
|
62
|
+
docstring = make_docstring["# Internal: It will do a big things in future"]
|
63
|
+
docstring.tag(:api).text.assert == "private"
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "Deprecated description" do
|
69
|
+
|
70
|
+
it "should fill deprecated tag" do
|
71
|
+
docstring = make_docstring["# Deprecated: Some description."]
|
72
|
+
docstring.tag(:deprecated).text.assert == "Do not use this in new code, and replace it when updating old code."
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
48
77
|
end
|
78
|
+
|
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.
|
4
|
+
version: 0.5.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-
|
13
|
+
date: 2012-06-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: yard
|
17
|
-
requirement: &
|
17
|
+
requirement: &22873120 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *22873120
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: tomparse
|
28
|
-
requirement: &
|
28
|
+
requirement: &22872480 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,21 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *22872480
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rc
|
39
|
+
requirement: &22871820 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
type: :runtime
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *22871820
|
37
48
|
- !ruby/object:Gem::Dependency
|
38
49
|
name: detroit
|
39
|
-
requirement: &
|
50
|
+
requirement: &22871280 !ruby/object:Gem::Requirement
|
40
51
|
none: false
|
41
52
|
requirements:
|
42
53
|
- - ! '>='
|
@@ -44,10 +55,10 @@ dependencies:
|
|
44
55
|
version: '0'
|
45
56
|
type: :development
|
46
57
|
prerelease: false
|
47
|
-
version_requirements: *
|
58
|
+
version_requirements: *22871280
|
48
59
|
- !ruby/object:Gem::Dependency
|
49
60
|
name: spectroscope
|
50
|
-
requirement: &
|
61
|
+
requirement: &22870680 !ruby/object:Gem::Requirement
|
51
62
|
none: false
|
52
63
|
requirements:
|
53
64
|
- - ! '>='
|
@@ -55,10 +66,10 @@ dependencies:
|
|
55
66
|
version: '0'
|
56
67
|
type: :development
|
57
68
|
prerelease: false
|
58
|
-
version_requirements: *
|
69
|
+
version_requirements: *22870680
|
59
70
|
- !ruby/object:Gem::Dependency
|
60
71
|
name: ae
|
61
|
-
requirement: &
|
72
|
+
requirement: &22870080 !ruby/object:Gem::Requirement
|
62
73
|
none: false
|
63
74
|
requirements:
|
64
75
|
- - ! '>='
|
@@ -66,7 +77,7 @@ dependencies:
|
|
66
77
|
version: '0'
|
67
78
|
type: :development
|
68
79
|
prerelease: false
|
69
|
-
version_requirements: *
|
80
|
+
version_requirements: *22870080
|
70
81
|
description: Use TomDoc documentation format with YARD.
|
71
82
|
email:
|
72
83
|
- transfire@gmail.com
|
@@ -77,6 +88,9 @@ extra_rdoc_files:
|
|
77
88
|
- HISTORY.md
|
78
89
|
- README.md
|
79
90
|
files:
|
91
|
+
- lib/yard-tomdoc/yard070.rb
|
92
|
+
- lib/yard-tomdoc/yard080.rb
|
93
|
+
- lib/yard-tomdoc/yard081.rb
|
80
94
|
- lib/yard-tomdoc.rb
|
81
95
|
- lib/yard-tomdoc.yml
|
82
96
|
- test/helper.rb
|
@@ -87,6 +101,7 @@ files:
|
|
87
101
|
- LICENSE.txt
|
88
102
|
- HISTORY.md
|
89
103
|
- README.md
|
104
|
+
- Config.rb
|
90
105
|
homepage: http://rubyworks.github.com/yard-tomdoc
|
91
106
|
licenses:
|
92
107
|
- MIT
|