yard 0.9.0 → 0.9.1

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 (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +33 -0
  3. data/Rakefile +1 -1
  4. data/docs/Tags.md +10 -9
  5. data/lib/rubygems_plugin.rb +7 -3
  6. data/lib/yard.rb +5 -6
  7. data/lib/yard/autoload.rb +12 -9
  8. data/lib/yard/cli/stats.rb +11 -1
  9. data/lib/yard/cli/yri.rb +2 -2
  10. data/lib/yard/code_objects/base.rb +12 -2
  11. data/lib/yard/code_objects/class_object.rb +2 -0
  12. data/lib/yard/code_objects/class_variable_object.rb +2 -0
  13. data/lib/yard/code_objects/constant_object.rb +2 -0
  14. data/lib/yard/code_objects/method_object.rb +3 -0
  15. data/lib/yard/code_objects/module_object.rb +2 -0
  16. data/lib/yard/code_objects/namespace_mapper.rb +113 -0
  17. data/lib/yard/code_objects/namespace_object.rb +3 -0
  18. data/lib/yard/docstring.rb +1 -1
  19. data/lib/yard/docstring_parser.rb +28 -1
  20. data/lib/yard/handlers/c/handler_methods.rb +1 -0
  21. data/lib/yard/handlers/c/mixin_handler.rb +7 -1
  22. data/lib/yard/handlers/ruby/alias_handler.rb +4 -3
  23. data/lib/yard/handlers/ruby/constant_handler.rb +6 -1
  24. data/lib/yard/handlers/ruby/dsl_handler_methods.rb +20 -3
  25. data/lib/yard/parser/c/comment_parser.rb +1 -1
  26. data/lib/yard/parser/ruby/ruby_parser.rb +25 -5
  27. data/lib/yard/parser/source_parser.rb +1 -0
  28. data/lib/yard/registry.rb +22 -43
  29. data/lib/yard/registry_resolver.rb +171 -0
  30. data/lib/yard/rubygems/hook.rb +164 -0
  31. data/lib/yard/server.rb +2 -1
  32. data/lib/yard/server/commands/root_request_command.rb +27 -0
  33. data/lib/yard/server/commands/static_file_command.rb +3 -16
  34. data/lib/yard/server/doc_server_helper.rb +1 -1
  35. data/lib/yard/server/router.rb +16 -6
  36. data/lib/yard/tags/default_factory.rb +3 -1
  37. data/lib/yard/tags/directives.rb +4 -0
  38. data/lib/yard/templates/engine.rb +1 -1
  39. data/lib/yard/templates/helpers/html_helper.rb +7 -2
  40. data/lib/yard/templates/helpers/module_helper.rb +1 -0
  41. data/lib/yard/templates/helpers/text_helper.rb +12 -0
  42. data/lib/yard/templates/template_options.rb +1 -1
  43. data/lib/yard/version.rb +1 -1
  44. data/spec/cli/stats_spec.rb +8 -3
  45. data/spec/code_objects/base_spec.rb +9 -1
  46. data/spec/docstring_parser_spec.rb +36 -1
  47. data/spec/docstring_spec.rb +1 -6
  48. data/spec/handlers/c/mixin_handler_spec.rb +16 -0
  49. data/spec/handlers/constant_handler_spec.rb +9 -0
  50. data/spec/handlers/dsl_handler_spec.rb +18 -0
  51. data/spec/handlers/examples/dsl_handler_001.rb.txt +29 -0
  52. data/spec/parser/ruby/ruby_parser_spec.rb +42 -0
  53. data/spec/registry_spec.rb +46 -3
  54. data/spec/server/router_spec.rb +1 -1
  55. data/spec/server_spec.rb +9 -0
  56. data/spec/tags/default_factory_spec.rb +5 -0
  57. data/spec/templates/engine_spec.rb +10 -0
  58. data/spec/templates/examples/constant001.txt +2 -2
  59. data/spec/templates/helpers/html_helper_spec.rb +8 -1
  60. data/spec/templates/helpers/module_helper_spec.rb +35 -0
  61. data/spec/templates/helpers/text_helper_spec.rb +20 -0
  62. data/templates/default/module/setup.rb +1 -1
  63. metadata +7 -4
  64. data/spec/server/commands/static_file_command_spec.rb +0 -84
@@ -5,8 +5,8 @@ DEFAULT_SEARCH_PATHS = []
5
5
  ------------------------------------------------------------------------
6
6
 
7
7
  Default search paths that should be loaded dynamically into YRI.
8
- These paths take precedence over all other paths
9
- ({SEARCH_PATHS_FILE} and RubyGems paths). To add a path, call:
8
+ These paths take precedence over all other paths (SEARCH_PATHS_FILE
9
+ and RubyGems paths). To add a path, call:
10
10
 
11
11
  DEFAULT_SEARCH_PATHS.push("/path/to/.yardoc")
12
12
 
@@ -148,7 +148,14 @@ describe YARD::Templates::Helpers::HtmlHelper do
148
148
  load_markup_provider(:rdoc)
149
149
  expect(File).to receive(:file?).with('foo.rdoc').and_return(true)
150
150
  expect(File).to receive(:read).with('foo.rdoc').and_return('HI')
151
- expect(htmlify("{include:file:foo.rdoc}", :rdoc).gsub(/\s+/, '')).to eq "<p><p>HI</p></p>"
151
+ expect(htmlify("{include:file:foo.rdoc}", :rdoc).gsub(/\s+/, '')).to eq "<p>HI</p>"
152
+ end
153
+
154
+ it "allows inline includes for {include:} in the middle of a line" do
155
+ load_markup_provider(:rdoc)
156
+ expect(File).to receive(:file?).with('foo.rdoc').and_return(true)
157
+ expect(File).to receive(:read).with('foo.rdoc').and_return('HI')
158
+ expect(htmlify("test {include:file:foo.rdoc}", :rdoc).gsub(/[\r?\n]+/, '')).to eq '<p>test HI</p>'
152
159
  end
153
160
 
154
161
  it "autolinks URLs (markdown specific)" do
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+
3
+ describe YARD::Templates::Helpers::ModuleHelper do
4
+ include YARD::Templates::Helpers::BaseHelper
5
+ include YARD::Templates::Helpers::ModuleHelper
6
+
7
+ describe "#prune_method_listing" do
8
+ before { YARD::Registry.clear }
9
+ let(:options) { OpenStruct.new }
10
+ let(:object) { YARD::Registry.at("Foo#bar") }
11
+ let(:objects) { [object] }
12
+
13
+ it "filters aliases" do
14
+ YARD.parse_string "class Foo; def orig; end; alias bar orig end"
15
+ expect(prune_method_listing(objects)).to eq []
16
+ end
17
+
18
+ it "filters attributes" do
19
+ YARD.parse_string "class Foo; attr_accessor :bar end"
20
+ expect(prune_method_listing(objects)).to eq []
21
+ end
22
+
23
+ it "ignores methods if namespace object is filtered" do
24
+ YARD.parse_string <<-eof
25
+ # @author test
26
+ class Foo
27
+ def bar; end
28
+ end
29
+ eof
30
+
31
+ options.verifier = YARD::Verifier.new('@author.text != "test"')
32
+ expect(prune_method_listing(objects)).to eq []
33
+ end
34
+ end
35
+ end
@@ -2,6 +2,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
2
2
  require File.dirname(__FILE__) + "/shared_signature_examples"
3
3
 
4
4
  describe YARD::Templates::Helpers::TextHelper do
5
+ include YARD::Templates::Helpers::BaseHelper
5
6
  include YARD::Templates::Helpers::TextHelper
6
7
  include YARD::Templates::Helpers::MethodHelper
7
8
 
@@ -41,4 +42,23 @@ describe YARD::Templates::Helpers::TextHelper do
41
42
  expect(align_right(text)).to eq ' ' + text[0,68] + '...'
42
43
  end
43
44
  end
45
+
46
+ describe "#h" do
47
+ let(:object) do
48
+ o = YARD::CodeObjects::MethodObject.new(:root, :foo, :instance)
49
+ o.tap {|o| o.docstring = "test" }
50
+ end
51
+
52
+ it "resolves links" do
53
+ expect(h("{include:#foo} 1 2 3").strip).to eq "test 1 2 3"
54
+ end
55
+
56
+ it "uses title when present" do
57
+ expect(h("{A b}").strip).to eq "b"
58
+ end
59
+
60
+ it "uses object name when no title is present" do
61
+ expect(h("{A}").strip).to eq "A"
62
+ end
63
+ end
44
64
  end
@@ -55,7 +55,7 @@ def attr_listing
55
55
  object.inheritance_tree(true).each do |superclass|
56
56
  next if superclass.is_a?(CodeObjects::Proxy)
57
57
  next if options.embed_mixins.size > 0 &&
58
- options.embed_mixins_match?(superclass) == false
58
+ !options.embed_mixins_match?(superclass)
59
59
  [:class, :instance].each do |scope|
60
60
  superclass.attributes[scope].each do |name, rw|
61
61
  attr = prune_method_listing([rw[:read], rw[:write]].compact, false).first
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.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loren Segal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-04 00:00:00.000000000 Z
11
+ date: 2016-07-18 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.
@@ -98,6 +98,7 @@ files:
98
98
  - lib/yard/code_objects/macro_object.rb
99
99
  - lib/yard/code_objects/method_object.rb
100
100
  - lib/yard/code_objects/module_object.rb
101
+ - lib/yard/code_objects/namespace_mapper.rb
101
102
  - lib/yard/code_objects/namespace_object.rb
102
103
  - lib/yard/code_objects/proxy.rb
103
104
  - lib/yard/code_objects/root_object.rb
@@ -193,6 +194,7 @@ files:
193
194
  - lib/yard/parser/source_parser.rb
194
195
  - lib/yard/rake/yardoc_task.rb
195
196
  - lib/yard/registry.rb
197
+ - lib/yard/registry_resolver.rb
196
198
  - lib/yard/registry_store.rb
197
199
  - lib/yard/rubygems/backports.rb
198
200
  - lib/yard/rubygems/backports/LICENSE.txt
@@ -200,6 +202,7 @@ files:
200
202
  - lib/yard/rubygems/backports/gem.rb
201
203
  - lib/yard/rubygems/backports/source_index.rb
202
204
  - lib/yard/rubygems/doc_manager.rb
205
+ - lib/yard/rubygems/hook.rb
203
206
  - lib/yard/rubygems/specification.rb
204
207
  - lib/yard/serializers/base.rb
205
208
  - lib/yard/serializers/file_system_serializer.rb
@@ -215,6 +218,7 @@ files:
215
218
  - lib/yard/server/commands/library_command.rb
216
219
  - lib/yard/server/commands/library_index_command.rb
217
220
  - lib/yard/server/commands/list_command.rb
221
+ - lib/yard/server/commands/root_request_command.rb
218
222
  - lib/yard/server/commands/search_command.rb
219
223
  - lib/yard/server/commands/static_file_command.rb
220
224
  - lib/yard/server/doc_server_helper.rb
@@ -400,7 +404,6 @@ files:
400
404
  - spec/server/adapter_spec.rb
401
405
  - spec/server/commands/base_spec.rb
402
406
  - spec/server/commands/library_command_spec.rb
403
- - spec/server/commands/static_file_command_spec.rb
404
407
  - spec/server/doc_server_helper_spec.rb
405
408
  - spec/server/doc_server_serializer_spec.rb
406
409
  - spec/server/rack_adapter_spec.rb
@@ -448,6 +451,7 @@ files:
448
451
  - spec/templates/helpers/markup/rdoc_markup_spec.rb
449
452
  - spec/templates/helpers/markup_helper_spec.rb
450
453
  - spec/templates/helpers/method_helper_spec.rb
454
+ - spec/templates/helpers/module_helper_spec.rb
451
455
  - spec/templates/helpers/shared_signature_examples.rb
452
456
  - spec/templates/helpers/text_helper_spec.rb
453
457
  - spec/templates/method_spec.rb
@@ -611,4 +615,3 @@ signing_key:
611
615
  specification_version: 4
612
616
  summary: Documentation tool for consistent and usable documentation in Ruby.
613
617
  test_files: []
614
- has_rdoc: yard
@@ -1,84 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- describe YARD::Server::Commands::StaticFileCommand do
4
- before do
5
- adapter = mock_adapter
6
- adapter.document_root = '/c'
7
- @cmd = StaticFileCommand.new(:adapter => adapter)
8
- end
9
-
10
- describe "#run" do
11
- def run(path, status = nil, body = nil)
12
- s, h, b = *@cmd.call(mock_request(path))
13
- expect(body).to eq b.first if body
14
- expect(status).to eq s if status
15
- [s, h, b]
16
- end
17
-
18
- it "searches through document root before static paths" do
19
- expect(File).to receive(:exist?).with('/c/path/to/file.txt').ordered.and_return(false)
20
- StaticFileCommand::STATIC_PATHS.reverse.each do |path|
21
- expect(File).to receive(:exist?).with(File.join(path, 'path/to/file.txt')).ordered.and_return(false)
22
- end
23
- run '/path/to/file.txt'
24
- end
25
-
26
- it "returns file contents if found" do
27
- tpl = Templates::Engine.template(:default, :fulldoc, :html)
28
- expect(File).to receive(:exist?).with('/c/path/to/file.txt').and_return(false)
29
- expect(tpl).to receive(:find_file).with('/path/to/file.txt').and_return('/path/to/foo')
30
- expect(File).to receive(:read).with('/path/to/foo').and_return('FOO')
31
- run('/path/to/file.txt', 200, 'FOO')
32
- end
33
-
34
- it "allows registering of new paths and use those before other static paths" do
35
- Server.register_static_path '/foo'
36
- path = '/foo/path/to/file.txt'
37
- expect(File).to receive(:exist?).with('/c/path/to/file.txt').and_return(false)
38
- expect(File).to receive(:exist?).with(path).and_return(true)
39
- expect(File).to receive(:read).with(path).and_return('FOO')
40
- run('/path/to/file.txt', 200, 'FOO')
41
- end
42
-
43
- it "does not use registered path before docroot" do
44
- Server.register_static_path '/foo'
45
- path = '/foo/path/to/file.txt'
46
- expect(File).to receive(:exist?).with('/c/path/to/file.txt').and_return(true)
47
- expect(File).to receive(:read).with('/c/path/to/file.txt').and_return('FOO')
48
- run('/c/path/to/file.txt', 200, 'FOO')
49
- end
50
-
51
- it "returns 404 if not found" do
52
- expect(File).to receive(:exist?).with('/c/path/to/file.txt').ordered.and_return(false)
53
- StaticFileCommand::STATIC_PATHS.reverse.each do |path|
54
- expect(File).to receive(:exist?).with(File.join(path, 'path/to/file.txt')).ordered.and_return(false)
55
- end
56
- run('/path/to/file.txt', 404)
57
- end
58
-
59
- it "returns text/html for file with no extension" do
60
- expect(File).to receive(:exist?).with('/c/file').and_return(true)
61
- expect(File).to receive(:read).with('/c/file')
62
- s, h, b = *run('/file')
63
- expect(h['Content-Type']).to eq 'text/html'
64
- end
65
-
66
- {
67
- "js" => "text/javascript",
68
- "css" => "text/css",
69
- "png" => "image/png",
70
- "gif" => "image/gif",
71
- "htm" => "text/html",
72
- "html" => "text/html",
73
- "txt" => "text/plain",
74
- "unknown" => "application/octet-stream"
75
- }.each do |ext, mime|
76
- it "serves file.#{ext} as #{mime}" do
77
- expect(File).to receive(:exist?).with('/c/file.' + ext).and_return(true)
78
- expect(File).to receive(:read).with('/c/file.' + ext)
79
- s, h, b = *run('/file.' + ext)
80
- expect(h['Content-Type']).to eq mime
81
- end
82
- end
83
- end
84
- end