yard 0.8.5.1 → 0.8.5.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of yard might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf3ea6675e5ee7add306f00af42399d73f1c2999
4
- data.tar.gz: 19dd59d2ba28a0e61274bd2421d044ae1a88f9c5
3
+ metadata.gz: 286e9bb0543c0d2d846d703abf038d42c0d08948
4
+ data.tar.gz: 1935aea9fce12ae0d560f0c2f4b65240aa688fac
5
5
  SHA512:
6
- metadata.gz: be2aafaf48c04c81d39a40d4b644094772d38be3d57d50452dca692a19f5cdd1b4c0ce488e85ad9d1e49fa52b4a300449d9283765ed82ce39d75aff34dee62d6
7
- data.tar.gz: 8263fee8b7c196c91e1c700042e120056418d4c23dc1c3da9b01435c9e47d40622ddc636213e4852db1d4545de99d4e951937c465e97c2a2108d316c3469abea
6
+ metadata.gz: 425fa8cdc965cd68b71230050e1d5c5741b9339218aeedfc4027b20ba2d15484ba1771c61b4bc0a6663b5c1b009d941644b6be323d9dd8e5a13314464bcd0a8e
7
+ data.tar.gz: 811d9eae07e7ded34d64e42858f2d9ddd2fad45847636c832f90f326a157fd0933000ce5168f9a6de97224084936c936e7adfbe8339ecdd6af75d9f09a0f5fdb
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- YARD: Yay! A Ruby Documentation Tool
2
- ====================================
1
+ # YARD: Yay! A Ruby Documentation Tool
3
2
 
4
3
  **Homepage**: [http://yardoc.org](http://yardoc.org)
5
4
  **IRC**: [irc.freenode.net / #yard](irc://irc.freenode.net/yard)
@@ -8,11 +7,10 @@ YARD: Yay! A Ruby Documentation Tool
8
7
  **Contributors**: See Contributors section below
9
8
  **Copyright**: 2007-2013
10
9
  **License**: MIT License
11
- **Latest Version**: 0.8.5.1
12
- **Release Date**: February 25th 2013
10
+ **Latest Version**: 0.8.5.2
11
+ **Release Date**: February 26th 2013
13
12
 
14
- Synopsis
15
- --------
13
+ ## Synopsis
16
14
 
17
15
  YARD is a documentation generation tool for the Ruby programming language.
18
16
  It enables the user to generate consistent, usable documentation that can be
@@ -21,8 +19,7 @@ custom Ruby constructs such as custom class level definitions. Below is a
21
19
  summary of some of YARD's notable features.
22
20
 
23
21
 
24
- Feature List
25
- ------------
22
+ ## Feature List
26
23
 
27
24
  **1. RDoc/SimpleMarkup Formatting Compatibility**: YARD is made to be compatible
28
25
  with RDoc formatting. In fact, YARD does no processing on RDoc documentation
@@ -286,6 +283,9 @@ More options can be seen by typing `yard graph --help`, but here is an example:
286
283
 
287
284
  ## Changelog
288
285
 
286
+ - **February.26.13**: 0.8.5.2 release
287
+ - Support new keyword argument syntax in method signatures (Ruby 2.x)
288
+
289
289
  - **February.25.13**: 0.8.5.1 release
290
290
  - Fix `yard diff` of gem files with RubyGems 2.x
291
291
 
data/lib/yard.rb CHANGED
@@ -46,6 +46,9 @@ module YARD
46
46
 
47
47
  # @return [Boolean] whether YARD is being run in Ruby 1.9 mode
48
48
  def self.ruby19?; @ruby19 ||= (RUBY_VERSION >= "1.9.1") end
49
+
50
+ # @return [Boolean] whether YARD is being run in Ruby 2.0
51
+ def self.ruby2?; @ruby2 ||= (RUBY_VERSION >= '2.0.0') end
49
52
  end
50
53
 
51
54
  # Keep track of Ruby version for compatibility code
@@ -75,6 +75,7 @@ class YARD::Handlers::Ruby::MethodHandler < YARD::Handlers::Ruby::Base
75
75
  params += args.required_params.map {|a| [a.source, nil] } if args.required_params
76
76
  params += args.optional_params.map {|a| [a[0].source, a[1].source] } if args.optional_params
77
77
  params << ["*" + args.splat_param.source, nil] if args.splat_param
78
+ params << ["**" + args.keyword_param.source, nil] if args.keyword_param
78
79
  params += args.required_end_params.map {|a| [a.source, nil] } if args.required_end_params
79
80
  params << ["&" + args.block_param.source, nil] if args.block_param
80
81
  params
@@ -381,12 +381,13 @@ module YARD
381
381
  def splat_param; self[2] ? self[2][0] : nil end
382
382
  def block_param; self[-1] ? self[-1][0] : nil end
383
383
  def optional_params
384
- optional = self[1]
385
- if self[-2] && self[-2][0] && self[-2][0].type == :default_arg
386
- optional += self[-2]
384
+ optional = self[1] || []
385
+ if self[-3] && self[-3][0] && self[-3][0].type == :default_arg
386
+ optional += self[-3]
387
387
  end
388
- optional
388
+ optional.empty? ? nil : optional
389
389
  end
390
+ def keyword_param; YARD.ruby2? ? self[-2] : nil end
390
391
  end
391
392
 
392
393
  class MethodCallNode < AstNode
@@ -14,7 +14,9 @@ module YARD
14
14
  end
15
15
 
16
16
  unless params.empty?
17
- args = params.map {|n, v| v ? "#{n} = #{v}" : n.to_s }.join(", ")
17
+ args = params.map do |n, v|
18
+ v ? "#{n}#{n[-1,1] == ':' ? '' : ' ='} #{v}" : n.to_s
19
+ end.join(", ")
18
20
  h("(#{args})")
19
21
  else
20
22
  ""
data/lib/yard/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module YARD
2
- VERSION = "0.8.5.1"
2
+ VERSION = "0.8.5.2"
3
3
  end
@@ -217,7 +217,6 @@ eof
217
217
  end
218
218
 
219
219
  it "should search for .gem file" do
220
- iomock = mock(:io)
221
220
  File.should_receive(:directory?).with('gem1/.yardoc').and_return(false)
222
221
  File.should_receive(:directory?).with('gem2.gem/.yardoc').and_return(false)
223
222
  File.should_receive(:directory?).with('gem1').and_return(false)
@@ -226,16 +225,15 @@ eof
226
225
  File.should_receive(:exist?).with('gem1.gem').and_return(true)
227
226
  File.should_receive(:exist?).with('gem2.gem').and_return(true)
228
227
  File.should_receive(:exist?).any_number_of_times
229
- File.should_receive(:open).with('gem1.gem', 'rb').and_yield(iomock)
228
+ File.should_receive(:open).with('gem1.gem', 'rb')
230
229
  File.should_receive(:open).with('gem2.gem', 'rb')
231
- FileUtils.should_receive(:mkdir_p)
232
- Gem::Package.should_receive(:open).with(iomock)
233
- FileUtils.should_receive(:rm_rf)
230
+ FileUtils.stub(:mkdir_p)
231
+ Gem::Package.stub(:open)
232
+ FileUtils.stub(:rm_rf)
234
233
  @diff.run('gem1', 'gem2.gem')
235
234
  end
236
235
 
237
236
  it "should search for .gem file on rubygems.org" do
238
- iomock = mock(:io)
239
237
  File.should_receive(:directory?).with('gem1/.yardoc').and_return(false)
240
238
  File.should_receive(:directory?).with('gem2.gem/.yardoc').and_return(false)
241
239
  File.should_receive(:directory?).with('gem1').and_return(false)
@@ -244,11 +242,11 @@ eof
244
242
  File.should_receive(:exist?).with('gem1.gem').and_return(false)
245
243
  File.should_receive(:exist?).with('gem2.gem').and_return(false)
246
244
  File.should_receive(:exist?).any_number_of_times
247
- @diff.should_receive(:open).with('http://rubygems.org/downloads/gem1.gem').and_yield(iomock)
245
+ @diff.should_receive(:open).with('http://rubygems.org/downloads/gem1.gem')
248
246
  @diff.should_receive(:open).with('http://rubygems.org/downloads/gem2.gem')
249
- FileUtils.should_receive(:mkdir_p)
250
- Gem::Package.should_receive(:open).with(iomock)
251
- FileUtils.should_receive(:rm_rf)
247
+ FileUtils.stub(:mkdir_p)
248
+ Gem::Package.stub(:open)
249
+ FileUtils.stub(:rm_rf)
252
250
  @diff.run('gem1', 'gem2.gem')
253
251
  end
254
252
 
@@ -88,10 +88,13 @@ describe YARD::CodeObjects::ExtraFileObject do
88
88
 
89
89
  it "should attempt to re-parse data as 8bit ascii if parsing fails" do
90
90
  log.should_not_receive(:warn)
91
- str = "\xB0"
92
- str.force_encoding('utf-8') if str.respond_to?(:force_encoding)
91
+ str, out = *(["\xB0"] * 2)
92
+ if str.respond_to?(:force_encoding)
93
+ str.force_encoding('utf-8')
94
+ out.force_encoding('binary')
95
+ end
93
96
  file = ExtraFileObject.new('file.txt', str)
94
- file.contents.should == "\xB0"
97
+ file.contents.should == out
95
98
  end
96
99
  end
97
100
 
@@ -547,8 +547,13 @@ describe YARD::Parser::SourceParser do
547
547
  File.should_receive(:read_binary).with('tmpfile').and_return(src)
548
548
  result = parser.parse("tmpfile")
549
549
  if HAVE_RIPPER && YARD.ruby19?
550
- ['Shift_JIS', 'Windows-31J', 'UTF-8'].send(msg, include(
551
- result.enumerator[0].source.encoding.to_s))
550
+ if msg == :should_not
551
+ default_encoding = YARD.ruby2? ? 'UTF-8' : 'US-ASCII'
552
+ result.enumerator[0].source.encoding.to_s.should eq(default_encoding)
553
+ else
554
+ ['Shift_JIS', 'Windows-31J', 'UTF-8'].send(msg, include(
555
+ result.enumerator[0].source.encoding.to_s))
556
+ end
552
557
  end
553
558
  result.encoding_line.send(msg) == src.split("\n").last
554
559
  end
@@ -702,5 +707,11 @@ describe YARD::Parser::SourceParser do
702
707
  Registry.at('A#d').should be_nil
703
708
  Registry.at('A::B#d').should_not be_nil
704
709
  end
710
+
711
+ it 'supports keyword arguments' do
712
+ YARD.parse_string 'def foo(a: 1, b: 2, **kwargs) end'
713
+ args = [['a:', '1'], ['b:', '2'], ['**kwargs', nil]]
714
+ Registry.at('#foo').parameters.should eq(args)
715
+ end if YARD.ruby2?
705
716
  end
706
717
  end
@@ -115,8 +115,12 @@ describe YARD::Templates::Helpers::HtmlHelper do
115
115
 
116
116
  it "should handle various encodings" do
117
117
  stub!(:object).and_return(Registry.root)
118
- Encoding.default_internal = 'utf-8' if defined?(Encoding)
119
- htmlify("\xB0\xB1", :text)
118
+ text = "\xB0\xB1"
119
+ if defined?(Encoding)
120
+ Encoding.default_internal = 'utf-8'
121
+ text = text.force_encoding('binary')
122
+ end
123
+ htmlify(text, :text)
120
124
  # TODO: add more encoding tests
121
125
  end
122
126
 
@@ -5,6 +5,13 @@ describe YARD::Templates::Helpers::MethodHelper do
5
5
  include YARD::Templates::Helpers::MethodHelper
6
6
 
7
7
  describe '#format_args' do
8
+ it "should display keyword arguments" do
9
+ params = [['a:', '1'], ['b:', '2'], ['**kwargs', nil]]
10
+ YARD.parse_string 'def foo; end'
11
+ Registry.at('#foo').stub(:parameters) { params }
12
+ format_args(Registry.at('#foo')).should == '(a: 1, b: 2, **kwargs)'
13
+ end
14
+
8
15
  it "should not show &blockarg if no @param tag and has @yield" do
9
16
  YARD.parse_string <<-'eof'
10
17
  # @yield blah
@@ -26,6 +26,7 @@ end
26
26
  def html_equals_string(result, expected)
27
27
  [expected, result].each do |value|
28
28
  value.gsub!(/(>)\s+|\s+(<)/, '\1\2')
29
+ value.gsub!(/&#39;/, "'")
29
30
  value.strip!
30
31
  end
31
32
  text_equals_string(result, expected)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5.1
4
+ version: 0.8.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loren Segal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-02-25 00:00:00.000000000 Z
11
+ date: 2013-02-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  YARD is a documentation generation tool for the Ruby programming language.