yard 0.8.7.4 → 0.8.7.5

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.

Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/README.md +5 -332
  4. data/lib/yard/cli/gems.rb +0 -1
  5. data/lib/yard/cli/stats.rb +3 -3
  6. data/lib/yard/cli/yardoc.rb +6 -2
  7. data/lib/yard/docstring_parser.rb +0 -3
  8. data/lib/yard/handlers/c/symbol_handler.rb +1 -1
  9. data/lib/yard/handlers/ruby/method_handler.rb +34 -6
  10. data/lib/yard/handlers/ruby/private_class_method_handler.rb +13 -2
  11. data/lib/yard/i18n/pot_generator.rb +2 -0
  12. data/lib/yard/logging.rb +1 -1
  13. data/lib/yard/parser/ruby/ast_node.rb +45 -11
  14. data/lib/yard/parser/ruby/ruby_parser.rb +24 -12
  15. data/lib/yard/rake/yardoc_task.rb +8 -1
  16. data/lib/yard/server/commands/library_command.rb +5 -2
  17. data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +1 -1
  18. data/lib/yard/server/templates/doc_server/processing/html/processing.erb +2 -1
  19. data/lib/yard/tags/library.rb +0 -2
  20. data/lib/yard/templates/helpers/html_helper.rb +4 -2
  21. data/lib/yard/templates/template.rb +3 -3
  22. data/lib/yard/version.rb +1 -1
  23. data/spec/cli/yardoc_spec.rb +6 -6
  24. data/spec/handlers/examples/private_class_method_handler_001.rb.txt +2 -0
  25. data/spec/handlers/examples/private_class_method_handler_002.rb.txt +18 -0
  26. data/spec/handlers/examples/private_class_method_handler_003.rb.txt +11 -0
  27. data/spec/handlers/private_class_method_handler_spec.rb +41 -6
  28. data/spec/i18n/pot_generator_spec.rb +30 -0
  29. data/spec/parser/c_parser_spec.rb +18 -0
  30. data/spec/parser/ruby/ruby_parser_spec.rb +42 -1
  31. data/spec/parser/source_parser_spec.rb +15 -5
  32. data/spec/rake/yardoc_task_spec.rb +27 -0
  33. data/spec/spec_helper.rb +2 -0
  34. data/spec/templates/helpers/html_helper_spec.rb +32 -0
  35. data/templates/default/fulldoc/html/full_list.erb +5 -1
  36. data/templates/default/fulldoc/html/js/full_list.js +4 -1
  37. metadata +43 -42
@@ -4,16 +4,51 @@ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}PrivateClassMe
4
4
  before(:all) { parse_file :private_class_method_handler_001, __FILE__ }
5
5
 
6
6
  it "should handle private_class_method statement" do
7
- Registry.at('A.c').visibility.should == :private
8
- Registry.at('A.d').visibility.should == :private
7
+ Registry.at('A.c').visibility.should eq :private
8
+ Registry.at('A.d').visibility.should eq :private
9
+ Registry.at('A.e').visibility.should eq :private
9
10
  end
10
11
 
11
12
  it "should fail if parameter is not String or Symbol" do
12
- undoc_error 'class Foo; private_class_method "x"; end'
13
13
  undoc_error 'class Foo; X = 1; private_class_method X.new("hi"); end'
14
+ undoc_error 'class Foo; X = 1; private_class_method 123; end'
14
15
  end unless LEGACY_PARSER
15
16
 
16
- it "should fail if method can't be recognized" do
17
- undoc_error 'class Foo2; private_class_method :x; end'
18
- end
17
+ # Issue #760
18
+ # https://github.com/lsegal/yard/issues/760
19
+ it "should handle singleton classes" do
20
+ # Note: It's important to def a method within the singleton class or
21
+ # the bug may not trigger.
22
+ code = 'class SingletonClass; private_class_method :new; def self.foo; "foo"end; end'
23
+ StubbedSourceParser.parse_string(code) # Should be successful.
24
+ end unless LEGACY_PARSER
25
+
26
+
27
+ describe "should handle reopened class" do
28
+
29
+ # Modified #parse_file from '/spec/spec_helper.rb' because the second example
30
+ # file was overwriting the data from the first example when trying to reopen
31
+ # the class.
32
+ def parse_files(files, thisfile = __FILE__, log_level = log.level, ext = '.rb.txt')
33
+ Registry.clear
34
+ paths = files.map { |file| File.join(File.dirname(thisfile), 'examples', file.to_s + ext) }
35
+ YARD::Parser::SourceParser.parse(paths, [], log_level)
36
+ end
37
+
38
+ before {
39
+ parse_files [
40
+ :private_class_method_handler_002,
41
+ :private_class_method_handler_003
42
+ ], __FILE__
43
+ }
44
+
45
+ specify do
46
+ Registry.at('SingletonClass.foo').visibility.should eq :public
47
+ Registry.at('SingletonClass.bar').visibility.should eq :private
48
+ Registry.at('SingletonClass.baz').visibility.should eq :private
49
+ Registry.at('SingletonClass.bat').visibility.should eq :public
50
+ end
51
+
52
+ end unless LEGACY_PARSER # reopened class
53
+
19
54
  end
@@ -205,6 +205,36 @@ eod
205
205
  }
206
206
  })
207
207
  end
208
+
209
+ it "should extract overload tag recursively" do
210
+ object = YARD::CodeObjects::MethodObject.new(@yard, :parse, :module) do |o|
211
+ o.docstring = <<-eod
212
+ @overload foo(i)
213
+ docstring foo(i)
214
+ @param [Integer] i integer parameter
215
+ eod
216
+ end
217
+
218
+ @generator.parse_objects([object])
219
+ @generator.messages.should == create_messages({
220
+ "tag|overload|foo" => {
221
+ :locations => [],
222
+ :comments => ["@overload"]
223
+ },
224
+ "docstring foo(i)" => {
225
+ :locations => [],
226
+ :comments => ["YARD.parse"]
227
+ },
228
+ "tag|param|i" => {
229
+ :locations => [],
230
+ :comments => ["@param [Integer]"]
231
+ },
232
+ "integer parameter" => {
233
+ :locations => [],
234
+ :comments => ["@param [Integer] i"]
235
+ },
236
+ })
237
+ end
208
238
  end
209
239
 
210
240
  describe "File" do
@@ -126,6 +126,24 @@ describe YARD::Parser::C::CParser do
126
126
  end
127
127
  end
128
128
  end
129
+
130
+ describe 'C macros in declaration' do
131
+ it "should handle C macros in method declaration" do
132
+ Registry.clear
133
+ parse <<-eof
134
+ // docstring
135
+ FOOBAR VALUE func() { }
136
+
137
+ void
138
+ Init_mod(void)
139
+ {
140
+ rb_define_method(rb_cFoo, "func", func, 0); \
141
+ }
142
+ eof
143
+
144
+ Registry.at('Foo#func').docstring.should == "docstring"
145
+ end
146
+ end
129
147
  end
130
148
 
131
149
  describe 'Override comments' do
@@ -178,11 +178,40 @@ eof
178
178
  ast.jump(:class).line_range.should == (2..4)
179
179
  end
180
180
 
181
+ it 'should handle defs with unnamed argument with default values' do
182
+ ast = stmt('def hello(one, two = 2, three = 3) end').jump(:params)
183
+ ast.source.should == 'one, two = 2, three = 3'
184
+ end
185
+
186
+ it 'should handle defs with splats' do
187
+ ast = stmt('def hello(one, *two) end').jump(:params)
188
+ ast.source.should == 'one, *two'
189
+ end
190
+
191
+ if YARD.ruby2?
192
+ it 'should handle defs with named arguments with default values' do
193
+ ast = stmt('def hello(one, two: 2, three: 3) end').jump(:params)
194
+ ast.source.should == 'one, two: 2, three: 3'
195
+ end
196
+ end
197
+
198
+ if NAMED_OPTIONAL_ARGUMENTS
199
+ it 'should handle defs with named arguments without default values' do
200
+ ast = stmt('def hello(one, two:, three:) end').jump(:params)
201
+ ast.source.should == 'one, two:, three:'
202
+ end
203
+
204
+ it 'should handle defs with double splats' do
205
+ ast = stmt('def hello(one, **two) end').jump(:params)
206
+ ast.source.should == 'one, **two'
207
+ end
208
+ end
209
+
181
210
  it "should end source properly on array reference" do
182
211
  ast = stmt("AS[0, 1 ] ")
183
212
  ast.source.should == 'AS[0, 1 ]'
184
213
 
185
- ast = stmt("def x(a = S[1]) end").jump(:default_arg)
214
+ ast = stmt('def x(a = S[1]) end').jump(:params)
186
215
  ast.source.should == 'a = S[1]'
187
216
  end
188
217
 
@@ -330,5 +359,17 @@ eof
330
359
  ast.first.last.last.type.should == :comment
331
360
  ast.first.last.last.docstring.should == "end comment"
332
361
  end
362
+
363
+ it "should not group comments if they don't begin the line" do
364
+ Registry.clear
365
+ ast = YARD.parse_string(<<-eof).enumerator
366
+ class Foo
367
+ CONST1 = 1 # Comment here
368
+ CONST2 = 2 # Another comment here
369
+ end
370
+ eof
371
+ Registry.at("Foo::CONST1").docstring.should == "Comment here"
372
+ Registry.at("Foo::CONST2").docstring.should == "Another comment here"
373
+ end
333
374
  end
334
375
  end if HAVE_RIPPER
@@ -708,10 +708,20 @@ describe YARD::Parser::SourceParser do
708
708
  Registry.at('A::B#d').should_not be_nil
709
709
  end
710
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?
711
+ if YARD.ruby2?
712
+ it 'supports named arguments with default values' do
713
+ YARD.parse_string 'def foo(a, b = 1, *c, d, e: 3, **f, &g) end'
714
+ args = [['a', nil], ['b', '1'], ['*c', nil], ['d', nil], ['e:', '3'], ['**f', nil], ['&g', nil]]
715
+ Registry.at('#foo').parameters.should eq(args)
716
+ end
717
+ end
718
+
719
+ if NAMED_OPTIONAL_ARGUMENTS && !LEGACY_PARSER
720
+ it 'supports named arguments without default values' do
721
+ YARD.parse_string 'def foo(a, b = 1, *c, d, e: 3, f:, **g, &h) end'
722
+ args = [['a', nil], ['b', '1'], ['*c', nil], ['d', nil], ['e:', '3'], ['f:', nil], ['**g', nil], ['&h', nil]]
723
+ Registry.at('#foo').parameters.should eq(args)
724
+ end
725
+ end
716
726
  end
717
727
  end
@@ -56,6 +56,33 @@ describe YARD::Rake::YardocTask do
56
56
  end
57
57
  end
58
58
 
59
+ describe '#stats_options' do
60
+ before do
61
+ @yard_stats = Object.new
62
+ @yard_stats.stub!(:run)
63
+ YARD::CLI::Stats.stub!(:new).and_return(@yard_stats)
64
+ end
65
+
66
+ it "should not invoke stats" do
67
+ @yard_stats.should_not_receive(:run)
68
+ @yardoc.statistics = true
69
+ YARD::Rake::YardocTask.new do |t|
70
+ end
71
+ run
72
+ @yardoc.statistics.should == true
73
+ end
74
+
75
+ it "should invoke stats" do
76
+ @yard_stats.should_receive(:run).with('--list-undoc', '--use-cache')
77
+ @yardoc.statistics = true
78
+ YARD::Rake::YardocTask.new do |t|
79
+ t.stats_options = %w(--list-undoc)
80
+ end
81
+ run
82
+ @yardoc.statistics.should == false
83
+ end
84
+ end
85
+
59
86
  describe '#before' do
60
87
  it "should allow before callback" do
61
88
  proc = lambda { }
data/spec/spec_helper.rb CHANGED
@@ -36,6 +36,8 @@ unless defined?(HAVE_RIPPER)
36
36
  end if ENV['LEGACY']
37
37
  end
38
38
 
39
+ NAMED_OPTIONAL_ARGUMENTS = RUBY_VERSION >= '2.1.0'
40
+
39
41
  def parse_file(file, thisfile = __FILE__, log_level = log.level, ext = '.rb.txt')
40
42
  Registry.clear
41
43
  path = File.join(File.dirname(thisfile), 'examples', file.to_s + ext)
@@ -166,6 +166,38 @@ describe YARD::Templates::Helpers::HtmlHelper do
166
166
  htmlify('{http://example.com}', :markdown).chomp.should =~
167
167
  %r{<p><a href="http://example.com".*>http://example.com</a></p>}
168
168
  end
169
+
170
+ it "should create tables (markdown specific)" do
171
+ log.enter_level(Logger::FATAL) do
172
+ unless markup_class(:markdown).to_s == "RedcarpetCompat"
173
+ pending 'This test depends on a markdown engine that supports tables'
174
+ end
175
+ end
176
+
177
+ markdown = <<-EOF.strip
178
+ City | State | Country
179
+ --------|-------|--------
180
+ Raleigh | NC | US
181
+ Seattle | WA | US
182
+ EOF
183
+
184
+ html = htmlify(markdown, :markdown)
185
+ html.should =~ %r{<table>}
186
+ html.should =~ %r{<th>City</th>}
187
+ html.should =~ %r{<td>NC</td>}
188
+ end
189
+
190
+ it 'should handle fenced code blocks (Redcarpet specific)' do
191
+ log.enter_level(Logger::FATAL) do
192
+ unless markup_class(:markdown).to_s == 'RedcarpetCompat'
193
+ pending 'This test is Redcarpet specific'
194
+ end
195
+ end
196
+
197
+ markdown = "Introduction:\n```ruby\nputs\n\nputs\n```"
198
+ html = htmlify(markdown, :markdown)
199
+ html.should =~ %r{^<p>Introduction:</p>.*<code class="ruby">}m
200
+ end
169
201
  end
170
202
 
171
203
  describe "#link_object" do
@@ -16,7 +16,11 @@
16
16
  </head>
17
17
  <body>
18
18
  <script type="text/javascript" charset="utf-8">
19
- if (window.top.frames.main) {
19
+ var hasFrames = false;
20
+ try {
21
+ hasFrames = window.top.frames.main ? true : false;
22
+ } catch (e) { }
23
+ if (hasFrames) {
20
24
  document.getElementById('base_target').target = 'main';
21
25
  document.body.className = 'frames';
22
26
  }
@@ -123,7 +123,10 @@ function linkList() {
123
123
  }
124
124
  }
125
125
  if (clicked) clicked.removeClass('clicked');
126
- var win = window.top.frames.main ? window.top.frames.main : window.parent;
126
+ var win;
127
+ try {
128
+ win = window.top.frames.main ? window.top.frames.main : window.parent;
129
+ } catch (e) { win = window.parent; }
127
130
  if (this.tagName.toLowerCase() == "a") {
128
131
  clicked = $(this).parents('li').addClass('clicked');
129
132
  win.location = this.href;
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.7.4
4
+ version: 0.8.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loren Segal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-22 00:00:00.000000000 Z
11
+ date: 2014-10-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.
@@ -23,18 +23,45 @@ executables:
23
23
  extensions: []
24
24
  extra_rdoc_files: []
25
25
  files:
26
+ - ".yardopts"
27
+ - LEGAL
28
+ - LICENSE
29
+ - README.md
30
+ - Rakefile
31
+ - benchmarks/builtins_vs_eval.rb
32
+ - benchmarks/concat_vs_join.rb
33
+ - benchmarks/erb_vs_erubis.rb
34
+ - benchmarks/format_args.rb
35
+ - benchmarks/generation.rb
36
+ - benchmarks/marshal_vs_dbm.rb
37
+ - benchmarks/parsing.rb
38
+ - benchmarks/pathname_vs_string.rb
39
+ - benchmarks/rdoc_vs_yardoc.rb
40
+ - benchmarks/registry_store_types.rb
41
+ - benchmarks/ri_vs_yri.rb
42
+ - benchmarks/ripper_parser.rb
43
+ - benchmarks/splat_vs_flatten.rb
44
+ - benchmarks/template_erb.rb
45
+ - benchmarks/template_format.rb
46
+ - benchmarks/template_profile.rb
47
+ - benchmarks/yri_cache.rb
48
+ - bin/yard
49
+ - bin/yardoc
50
+ - bin/yri
26
51
  - docs/CodeObjects.md
27
52
  - docs/GettingStarted.md
28
53
  - docs/Handlers.md
54
+ - docs/Overview.md
55
+ - docs/Parser.md
56
+ - docs/Tags.md
57
+ - docs/TagsArch.md
58
+ - docs/Templates.md
59
+ - docs/WhatsNew.md
29
60
  - docs/images/code-objects-class-diagram.png
30
61
  - docs/images/handlers-class-diagram.png
31
62
  - docs/images/overview-class-diagram.png
32
63
  - docs/images/parser-class-diagram.png
33
64
  - docs/images/tags-class-diagram.png
34
- - docs/Overview.md
35
- - docs/Parser.md
36
- - docs/Tags.md
37
- - docs/TagsArch.md
38
65
  - docs/templates/default/fulldoc/html/full_list_tag.erb
39
66
  - docs/templates/default/fulldoc/html/setup.rb
40
67
  - docs/templates/default/layout/html/setup.rb
@@ -42,12 +69,8 @@ files:
42
69
  - docs/templates/default/yard_tags/html/list.erb
43
70
  - docs/templates/default/yard_tags/html/setup.rb
44
71
  - docs/templates/plugin.rb
45
- - docs/Templates.md
46
- - docs/WhatsNew.md
47
- - bin/yard
48
- - bin/yardoc
49
- - bin/yri
50
72
  - lib/rubygems_plugin.rb
73
+ - lib/yard.rb
51
74
  - lib/yard/autoload.rb
52
75
  - lib/yard/cli/command.rb
53
76
  - lib/yard/cli/command_parser.rb
@@ -168,11 +191,11 @@ files:
168
191
  - lib/yard/rake/yardoc_task.rb
169
192
  - lib/yard/registry.rb
170
193
  - lib/yard/registry_store.rb
171
- - lib/yard/rubygems/backports/gem.rb
194
+ - lib/yard/rubygems/backports.rb
172
195
  - lib/yard/rubygems/backports/LICENSE.txt
173
196
  - lib/yard/rubygems/backports/MIT.txt
197
+ - lib/yard/rubygems/backports/gem.rb
174
198
  - lib/yard/rubygems/backports/source_index.rb
175
- - lib/yard/rubygems/backports.rb
176
199
  - lib/yard/rubygems/doc_manager.rb
177
200
  - lib/yard/rubygems/specification.rb
178
201
  - lib/yard/serializers/base.rb
@@ -180,6 +203,7 @@ files:
180
203
  - lib/yard/serializers/process_serializer.rb
181
204
  - lib/yard/serializers/stdout_serializer.rb
182
205
  - lib/yard/serializers/yardoc_serializer.rb
206
+ - lib/yard/server.rb
183
207
  - lib/yard/server/adapter.rb
184
208
  - lib/yard/server/commands/base.rb
185
209
  - lib/yard/server/commands/display_file_command.rb
@@ -214,7 +238,6 @@ files:
214
238
  - lib/yard/server/templates/doc_server/search/html/search.erb
215
239
  - lib/yard/server/templates/doc_server/search/html/setup.rb
216
240
  - lib/yard/server/webrick_adapter.rb
217
- - lib/yard/server.rb
218
241
  - lib/yard/tags/default_factory.rb
219
242
  - lib/yard/tags/default_tag.rb
220
243
  - lib/yard/tags/directives.rb
@@ -243,7 +266,6 @@ files:
243
266
  - lib/yard/templates/template_options.rb
244
267
  - lib/yard/verifier.rb
245
268
  - lib/yard/version.rb
246
- - lib/yard.rb
247
269
  - spec/cli/command_parser_spec.rb
248
270
  - spec/cli/command_spec.rb
249
271
  - spec/cli/config_spec.rb
@@ -314,6 +336,8 @@ files:
314
336
  - spec/handlers/examples/mixin_handler_001.rb.txt
315
337
  - spec/handlers/examples/module_handler_001.rb.txt
316
338
  - spec/handlers/examples/private_class_method_handler_001.rb.txt
339
+ - spec/handlers/examples/private_class_method_handler_002.rb.txt
340
+ - spec/handlers/examples/private_class_method_handler_003.rb.txt
317
341
  - spec/handlers/examples/private_constant_handler_001.rb.txt
318
342
  - spec/handlers/examples/process_handler_001.rb.txt
319
343
  - spec/handlers/examples/visibility_handler_001.rb.txt
@@ -362,9 +386,9 @@ files:
362
386
  - spec/registry_store_spec.rb
363
387
  - spec/rubygems/doc_manager_spec.rb
364
388
  - spec/serializers/data/serialized_yardoc/checksums
389
+ - spec/serializers/data/serialized_yardoc/objects/Foo.dat
365
390
  - spec/serializers/data/serialized_yardoc/objects/Foo/bar_i.dat
366
391
  - spec/serializers/data/serialized_yardoc/objects/Foo/baz_i.dat
367
- - spec/serializers/data/serialized_yardoc/objects/Foo.dat
368
392
  - spec/serializers/data/serialized_yardoc/objects/root.dat
369
393
  - spec/serializers/data/serialized_yardoc/proxy_types
370
394
  - spec/serializers/file_system_serializer_spec.rb
@@ -558,28 +582,6 @@ files:
558
582
  - templates/guide/onefile/html/setup.rb
559
583
  - templates/guide/onefile/html/toc.erb
560
584
  - templates/guide/tags/html/setup.rb
561
- - benchmarks/builtins_vs_eval.rb
562
- - benchmarks/concat_vs_join.rb
563
- - benchmarks/erb_vs_erubis.rb
564
- - benchmarks/format_args.rb
565
- - benchmarks/generation.rb
566
- - benchmarks/marshal_vs_dbm.rb
567
- - benchmarks/parsing.rb
568
- - benchmarks/pathname_vs_string.rb
569
- - benchmarks/rdoc_vs_yardoc.rb
570
- - benchmarks/registry_store_types.rb
571
- - benchmarks/ri_vs_yri.rb
572
- - benchmarks/ripper_parser.rb
573
- - benchmarks/splat_vs_flatten.rb
574
- - benchmarks/template_erb.rb
575
- - benchmarks/template_format.rb
576
- - benchmarks/template_profile.rb
577
- - benchmarks/yri_cache.rb
578
- - LICENSE
579
- - LEGAL
580
- - README.md
581
- - Rakefile
582
- - .yardopts
583
585
  - yard.gemspec
584
586
  homepage: http://yardoc.org
585
587
  licenses:
@@ -591,19 +593,18 @@ require_paths:
591
593
  - lib
592
594
  required_ruby_version: !ruby/object:Gem::Requirement
593
595
  requirements:
594
- - - '>='
596
+ - - ">="
595
597
  - !ruby/object:Gem::Version
596
598
  version: '0'
597
599
  required_rubygems_version: !ruby/object:Gem::Requirement
598
600
  requirements:
599
- - - '>='
601
+ - - ">="
600
602
  - !ruby/object:Gem::Version
601
603
  version: '0'
602
604
  requirements: []
603
605
  rubyforge_project: yard
604
- rubygems_version: 2.0.3
606
+ rubygems_version: 2.4.1
605
607
  signing_key:
606
608
  specification_version: 4
607
609
  summary: Documentation tool for consistent and usable documentation in Ruby.
608
610
  test_files: []
609
- has_rdoc: yard