yard 0.6.8 → 0.7.0
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.
- data/.yardopts +1 -0
- data/ChangeLog +723 -0
- data/README.md +16 -6
- data/docs/CodeObjects.md +10 -16
- data/docs/GettingStarted.md +232 -32
- data/docs/Glossary.md +1 -2
- data/docs/Handlers.md +10 -16
- data/docs/Overview.md +14 -13
- data/docs/Parser.md +13 -22
- data/docs/Tags.md +209 -16
- data/docs/Templates.md +237 -26
- data/docs/WhatsNew.md +178 -2
- data/lib/yard.rb +13 -10
- data/lib/yard/autoload.rb +22 -18
- data/lib/yard/cli/command.rb +13 -12
- data/lib/yard/cli/command_parser.rb +20 -19
- data/lib/yard/cli/config.rb +19 -19
- data/lib/yard/cli/diff.rb +46 -21
- data/lib/yard/cli/gems.rb +11 -11
- data/lib/yard/cli/graph.rb +13 -13
- data/lib/yard/cli/help.rb +1 -1
- data/lib/yard/cli/list.rb +22 -0
- data/lib/yard/cli/server.rb +17 -17
- data/lib/yard/cli/stats.rb +32 -32
- data/lib/yard/cli/yardoc.rb +181 -135
- data/lib/yard/cli/yri.rb +29 -29
- data/lib/yard/code_objects/base.rb +101 -101
- data/lib/yard/code_objects/class_object.rb +20 -20
- data/lib/yard/code_objects/constant_object.rb +1 -1
- data/lib/yard/code_objects/extended_method_object.rb +5 -5
- data/lib/yard/code_objects/extra_file_object.rb +89 -0
- data/lib/yard/code_objects/macro_object.rb +215 -0
- data/lib/yard/code_objects/method_object.rb +30 -30
- data/lib/yard/code_objects/module_object.rb +1 -1
- data/lib/yard/code_objects/namespace_object.rb +39 -39
- data/lib/yard/code_objects/proxy.rb +38 -38
- data/lib/yard/code_objects/root_object.rb +1 -1
- data/lib/yard/config.rb +40 -40
- data/lib/yard/core_ext/array.rb +2 -2
- data/lib/yard/core_ext/file.rb +11 -11
- data/lib/yard/core_ext/insertion.rb +10 -10
- data/lib/yard/core_ext/module.rb +2 -2
- data/lib/yard/core_ext/string.rb +2 -2
- data/lib/yard/core_ext/symbol_hash.rb +14 -14
- data/lib/yard/docstring.rb +122 -54
- data/lib/yard/globals.rb +2 -2
- data/lib/yard/handlers/base.rb +216 -127
- data/lib/yard/handlers/processor.rb +65 -27
- data/lib/yard/handlers/ruby/alias_handler.rb +6 -3
- data/lib/yard/handlers/ruby/attribute_handler.rb +7 -6
- data/lib/yard/handlers/ruby/base.rb +50 -31
- data/lib/yard/handlers/ruby/class_condition_handler.rb +11 -11
- data/lib/yard/handlers/ruby/class_handler.rb +10 -10
- data/lib/yard/handlers/ruby/class_variable_handler.rb +3 -3
- data/lib/yard/handlers/ruby/constant_handler.rb +7 -7
- data/lib/yard/handlers/ruby/exception_handler.rb +2 -2
- data/lib/yard/handlers/ruby/extend_handler.rb +1 -1
- data/lib/yard/handlers/ruby/legacy/alias_handler.rb +8 -5
- data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +6 -5
- data/lib/yard/handlers/ruby/legacy/base.rb +42 -27
- data/lib/yard/handlers/ruby/legacy/class_condition_handler.rb +9 -9
- data/lib/yard/handlers/ruby/legacy/class_handler.rb +13 -12
- data/lib/yard/handlers/ruby/legacy/class_variable_handler.rb +3 -6
- data/lib/yard/handlers/ruby/legacy/constant_handler.rb +5 -8
- data/lib/yard/handlers/ruby/legacy/exception_handler.rb +1 -1
- data/lib/yard/handlers/ruby/legacy/extend_handler.rb +1 -0
- data/lib/yard/handlers/ruby/legacy/macro_handler.rb +40 -0
- data/lib/yard/handlers/ruby/legacy/method_handler.rb +10 -10
- data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +4 -3
- data/lib/yard/handlers/ruby/legacy/module_handler.rb +2 -1
- data/lib/yard/handlers/ruby/legacy/private_constant_handler.rb +4 -4
- data/lib/yard/handlers/ruby/legacy/visibility_handler.rb +2 -1
- data/lib/yard/handlers/ruby/legacy/yield_handler.rb +3 -3
- data/lib/yard/handlers/ruby/macro_handler.rb +41 -0
- data/lib/yard/handlers/ruby/macro_handler_methods.rb +130 -0
- data/lib/yard/handlers/ruby/method_condition_handler.rb +1 -1
- data/lib/yard/handlers/ruby/method_handler.rb +13 -13
- data/lib/yard/handlers/ruby/mixin_handler.rb +4 -4
- data/lib/yard/handlers/ruby/module_handler.rb +2 -1
- data/lib/yard/handlers/ruby/private_constant_handler.rb +4 -4
- data/lib/yard/handlers/ruby/struct_handler_methods.rb +11 -11
- data/lib/yard/handlers/ruby/visibility_handler.rb +1 -1
- data/lib/yard/handlers/ruby/yield_handler.rb +5 -5
- data/lib/yard/logging.rb +11 -11
- data/lib/yard/parser/base.rb +8 -8
- data/lib/yard/parser/c_parser.rb +42 -33
- data/lib/yard/parser/ruby/ast_node.rb +62 -61
- data/lib/yard/parser/ruby/legacy/ruby_lex.rb +66 -66
- data/lib/yard/parser/ruby/legacy/ruby_parser.rb +4 -4
- data/lib/yard/parser/ruby/legacy/statement.rb +11 -11
- data/lib/yard/parser/ruby/legacy/statement_list.rb +15 -15
- data/lib/yard/parser/ruby/legacy/token_list.rb +9 -9
- data/lib/yard/parser/ruby/ruby_parser.rb +51 -37
- data/lib/yard/parser/source_parser.rb +271 -46
- data/lib/yard/rake/yardoc_task.rb +18 -17
- data/lib/yard/registry.rb +64 -64
- data/lib/yard/registry_store.rb +34 -34
- data/lib/yard/rubygems/backports.rb +8 -0
- data/lib/yard/rubygems/backports/LICENSE.txt +57 -0
- data/lib/yard/rubygems/backports/MIT.txt +20 -0
- data/lib/yard/rubygems/backports/gem.rb +8 -0
- data/lib/yard/rubygems/backports/source_index.rb +353 -0
- data/lib/yard/rubygems/specification.rb +2 -2
- data/lib/yard/serializers/base.rb +20 -20
- data/lib/yard/serializers/file_system_serializer.rb +28 -24
- data/lib/yard/serializers/process_serializer.rb +3 -3
- data/lib/yard/serializers/stdout_serializer.rb +6 -6
- data/lib/yard/serializers/yardoc_serializer.rb +17 -17
- data/lib/yard/server/adapter.rb +12 -12
- data/lib/yard/server/commands/base.rb +26 -26
- data/lib/yard/server/commands/display_file_command.rb +3 -2
- data/lib/yard/server/commands/display_object_command.rb +5 -5
- data/lib/yard/server/commands/frames_command.rb +1 -1
- data/lib/yard/server/commands/library_command.rb +7 -7
- data/lib/yard/server/commands/library_index_command.rb +2 -2
- data/lib/yard/server/commands/list_command.rb +8 -8
- data/lib/yard/server/commands/search_command.rb +8 -8
- data/lib/yard/server/commands/static_file_command.rb +3 -3
- data/lib/yard/server/doc_server_helper.rb +6 -3
- data/lib/yard/server/doc_server_serializer.rb +1 -1
- data/lib/yard/server/library_version.rb +45 -45
- data/lib/yard/server/rack_adapter.rb +10 -10
- data/lib/yard/server/router.rb +28 -28
- data/lib/yard/server/static_caching.rb +5 -5
- data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +3 -3
- data/lib/yard/server/templates/default/fulldoc/html/js/live.js +1 -1
- data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +2 -2
- data/lib/yard/server/templates/default/layout/html/headers.erb +13 -8
- data/lib/yard/server/templates/default/layout/html/setup.rb +7 -0
- data/lib/yard/server/templates/doc_server/full_list/html/full_list.erb +2 -2
- data/lib/yard/server/templates/doc_server/full_list/html/setup.rb +14 -4
- data/lib/yard/server/templates/doc_server/library_list/html/contents.erb +2 -2
- data/lib/yard/server/templates/doc_server/library_list/html/headers.erb +2 -2
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +1 -1
- data/lib/yard/server/templates/doc_server/search/html/search.erb +1 -1
- data/lib/yard/server/webrick_adapter.rb +2 -2
- data/lib/yard/tags/default_factory.rb +19 -19
- data/lib/yard/tags/default_tag.rb +1 -1
- data/lib/yard/tags/library.rb +68 -63
- data/lib/yard/tags/option_tag.rb +1 -1
- data/lib/yard/tags/overload_tag.rb +9 -9
- data/lib/yard/tags/ref_tag_list.rb +2 -2
- data/lib/yard/tags/tag.rb +7 -7
- data/lib/yard/templates/engine.rb +31 -31
- data/lib/yard/templates/erb_cache.rb +1 -1
- data/lib/yard/templates/helpers/base_helper.rb +46 -32
- data/lib/yard/templates/helpers/filter_helper.rb +2 -2
- data/lib/yard/templates/helpers/html_helper.rb +120 -81
- data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +4 -4
- data/lib/yard/templates/helpers/markup/rdoc_markup.rb +9 -9
- data/lib/yard/templates/helpers/markup_helper.rb +37 -30
- data/lib/yard/templates/helpers/method_helper.rb +7 -7
- data/lib/yard/templates/helpers/text_helper.rb +7 -7
- data/lib/yard/templates/helpers/uml_helper.rb +3 -3
- data/lib/yard/templates/section.rb +14 -14
- data/lib/yard/templates/template.rb +54 -54
- data/lib/yard/verifier.rb +27 -27
- data/spec/cli/list_spec.rb +8 -0
- data/spec/cli/yardoc_spec.rb +58 -10
- data/spec/code_objects/extra_file_object_spec.rb +132 -0
- data/spec/code_objects/macro_object_spec.rb +154 -0
- data/spec/docstring_spec.rb +90 -0
- data/spec/handlers/base_spec.rb +22 -0
- data/spec/handlers/examples/macro_handler_001.rb.txt +73 -0
- data/spec/handlers/examples/method_handler_001.rb.txt +17 -0
- data/spec/handlers/macro_handler_spec.rb +140 -0
- data/spec/handlers/method_handler_spec.rb +28 -0
- data/spec/handlers/processor_spec.rb +4 -0
- data/spec/handlers/spec_helper.rb +1 -1
- data/spec/parser/c_parser_spec.rb +47 -16
- data/spec/parser/examples/extrafile.c.txt +8 -0
- data/spec/parser/examples/multifile.c.txt +6 -0
- data/spec/parser/ruby/ruby_parser_spec.rb +5 -0
- data/spec/parser/source_parser_spec.rb +235 -0
- data/spec/rake/yardoc_task_spec.rb +22 -17
- data/spec/serializers/file_system_serializer_spec.rb +6 -0
- data/spec/server/commands/library_command_spec.rb +39 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/templates/examples/method001.html +6 -6
- data/spec/templates/examples/method002.html +4 -4
- data/spec/templates/examples/method003.html +10 -10
- data/spec/templates/examples/method005.html +2 -2
- data/spec/templates/examples/module001.dot +2 -0
- data/spec/templates/examples/module001.html +76 -37
- data/spec/templates/examples/module001.txt +1 -1
- data/spec/templates/helpers/base_helper_spec.rb +7 -2
- data/spec/templates/helpers/html_helper_spec.rb +49 -5
- data/spec/templates/helpers/markup_helper_spec.rb +9 -8
- data/spec/templates/module_spec.rb +7 -0
- data/spec/templates/onefile_spec.rb +47 -0
- data/templates/default/fulldoc/html/css/style.css +7 -5
- data/templates/default/fulldoc/html/full_list.erb +13 -10
- data/templates/default/fulldoc/html/full_list_files.erb +1 -1
- data/templates/default/fulldoc/html/js/app.js +16 -14
- data/templates/default/fulldoc/html/js/full_list.js +7 -6
- data/templates/default/fulldoc/html/setup.rb +78 -17
- data/templates/default/layout/html/files.erb +1 -1
- data/templates/default/layout/html/headers.erb +11 -7
- data/templates/default/layout/html/search.erb +4 -4
- data/templates/default/layout/html/setup.rb +28 -8
- data/templates/default/module/html/inherited_attributes.erb +17 -0
- data/templates/default/module/setup.rb +1 -1
- data/templates/default/onefile/html/files.erb +2 -2
- data/templates/default/onefile/html/layout.erb +1 -1
- data/templates/default/onefile/html/setup.rb +7 -5
- data/templates/default/tags/html/option.erb +1 -1
- data/templates/default/tags/html/tag.erb +3 -3
- data/templates/guide/class/html/setup.rb +1 -0
- data/templates/guide/docstring/html/setup.rb +1 -0
- data/templates/guide/fulldoc/html/css/style.css +91 -0
- data/templates/guide/fulldoc/html/js/app.js +33 -0
- data/templates/guide/fulldoc/html/setup.rb +54 -0
- data/templates/guide/layout/html/layout.erb +81 -0
- data/templates/guide/layout/html/setup.rb +24 -0
- data/templates/guide/method/html/header.erb +18 -0
- data/templates/guide/method/html/setup.rb +21 -0
- data/templates/guide/module/html/header.erb +7 -0
- data/templates/guide/module/html/method_list.erb +5 -0
- data/templates/guide/module/html/setup.rb +26 -0
- data/templates/guide/tags/html/setup.rb +8 -0
- metadata +40 -7
- data/lib/yard/handlers/ruby/legacy/process_handler.rb +0 -13
- data/lib/yard/handlers/ruby/process_handler.rb +0 -18
- data/spec/handlers/process_handler_spec.rb +0 -17
@@ -79,7 +79,7 @@ describe YARD::Templates::Helpers::BaseHelper do
|
|
79
79
|
end
|
80
80
|
|
81
81
|
it "should call #link_file for file: links" do
|
82
|
-
should_receive(:link_file).with('Filename',
|
82
|
+
should_receive(:link_file).with('Filename', nil, 'anchor')
|
83
83
|
linkify("file:Filename#anchor")
|
84
84
|
end
|
85
85
|
|
@@ -112,9 +112,14 @@ describe YARD::Templates::Helpers::BaseHelper do
|
|
112
112
|
linkify('include:file:path/to/file').should == 'FOO'
|
113
113
|
end
|
114
114
|
|
115
|
+
it "should not allow include:file for path above pwd" do
|
116
|
+
log.should_receive(:warn).with("Cannot include file from path `a/b/../../../../file'")
|
117
|
+
linkify('include:file:a/b/../../../../file').should == ''
|
118
|
+
end
|
119
|
+
|
115
120
|
it "should warn if include:file:path does not exist" do
|
116
121
|
log.should_receive(:warn).with(/Cannot find file .+ for inclusion/)
|
117
|
-
linkify('include:file
|
122
|
+
linkify('include:file:notexist').should == ''
|
118
123
|
end
|
119
124
|
end
|
120
125
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
require File.dirname(__FILE__) + "/shared_signature_examples"
|
3
|
+
require 'ostruct'
|
3
4
|
|
4
5
|
describe YARD::Templates::Helpers::HtmlHelper do
|
5
6
|
include YARD::Templates::Helpers::BaseHelper
|
@@ -29,6 +30,16 @@ describe YARD::Templates::Helpers::HtmlHelper do
|
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
33
|
+
it "should take file encoding if there is a file" do
|
34
|
+
@file = OpenStruct.new(:contents => 'foo'.force_encoding('sjis'))
|
35
|
+
charset.should == 'Shift_JIS' # not the correct charset name, but good enough
|
36
|
+
end if RUBY19
|
37
|
+
|
38
|
+
it "should take file encoding if there is a file" do
|
39
|
+
@file = OpenStruct.new(:contents => 'foo')
|
40
|
+
charset.should == 'utf-8'
|
41
|
+
end if RUBY18
|
42
|
+
|
32
43
|
if RUBY18
|
33
44
|
it "should return utf-8 if no LANG env is set" do
|
34
45
|
ENV.should_receive(:[]).with('LANG').and_return(nil)
|
@@ -93,6 +104,23 @@ describe YARD::Templates::Helpers::HtmlHelper do
|
|
93
104
|
it "should return regular text with :none markup" do
|
94
105
|
htmlify("fo\no\n\nbar<>", :none).should == "fo\no<br/>bar<>"
|
95
106
|
end
|
107
|
+
|
108
|
+
it "should highlight ruby if markup is :ruby" do
|
109
|
+
htmlify("class Foo; end", :ruby).should =~ /\A<pre class="code"><span/
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should include file and htmlify it" do
|
113
|
+
File.should_receive(:file?).with('foo.rdoc').and_return(true)
|
114
|
+
File.should_receive(:read).with('foo.rdoc').and_return('= HI')
|
115
|
+
htmlify("{include:file:foo.rdoc}", :rdoc).gsub(/\s+/, '').should == "<p><h1>HI</h1></p>"
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should autolink URLs (markdown specific)" do
|
119
|
+
log.enter_level(Logger::FATAL) do
|
120
|
+
pending 'This test depends on markdown' unless markup_class(:markdown)
|
121
|
+
end
|
122
|
+
htmlify('http://example.com', :markdown).should include('<a href="http://example.com"')
|
123
|
+
end
|
96
124
|
end
|
97
125
|
|
98
126
|
describe "#link_object" do
|
@@ -207,14 +235,20 @@ describe YARD::Templates::Helpers::HtmlHelper do
|
|
207
235
|
end
|
208
236
|
results
|
209
237
|
end
|
238
|
+
|
239
|
+
it "should escape {} syntax with backslash (\\{foo bar})" do
|
240
|
+
input = '\{foo bar} \{XYZ} \{file:FOO}'
|
241
|
+
output = '{foo bar} {XYZ} {file:FOO}'
|
242
|
+
resolve_links(input).should == output
|
243
|
+
end
|
210
244
|
|
211
245
|
it "should link static files with file: prefix" do
|
212
246
|
stub!(:serializer).and_return Serializers::FileSystemSerializer.new
|
213
247
|
stub!(:object).and_return Registry.root
|
214
248
|
|
215
249
|
parse_link(resolve_links("{file:TEST.txt#abc}")).should == {
|
216
|
-
:inner_text => "TEST
|
217
|
-
:title => "TEST
|
250
|
+
:inner_text => "TEST",
|
251
|
+
:title => "TEST",
|
218
252
|
:href => "file.TEST.html#abc"
|
219
253
|
}
|
220
254
|
parse_link(resolve_links("{file:TEST.txt title}")).should == {
|
@@ -258,6 +292,11 @@ describe YARD::Templates::Helpers::HtmlHelper do
|
|
258
292
|
resolve_links("{|x|x == 1}").should == "{|x|x == 1}"
|
259
293
|
end
|
260
294
|
|
295
|
+
it "should gracefully ignore {} in links" do
|
296
|
+
should_receive(:linkify).with('Foo', 'Foo').and_return('FOO')
|
297
|
+
resolve_links("{} {} {Foo Foo}").should == '{} {} FOO'
|
298
|
+
end
|
299
|
+
|
261
300
|
%w(tt code pre).each do |tag|
|
262
301
|
it "should ignore links in <#{tag}>" do
|
263
302
|
text = "<#{tag}>{Foo}</#{tag}>"
|
@@ -266,12 +305,12 @@ describe YARD::Templates::Helpers::HtmlHelper do
|
|
266
305
|
end
|
267
306
|
|
268
307
|
it "should resolve {Name}" do
|
269
|
-
should_receive(:link_file).with('TEST',
|
308
|
+
should_receive(:link_file).with('TEST', nil, nil).and_return('')
|
270
309
|
resolve_links("{file:TEST}")
|
271
310
|
end
|
272
311
|
|
273
312
|
it "should resolve ({Name})" do
|
274
|
-
should_receive(:link_file).with('TEST',
|
313
|
+
should_receive(:link_file).with('TEST', nil, nil).and_return('')
|
275
314
|
resolve_links("({file:TEST})")
|
276
315
|
end
|
277
316
|
|
@@ -321,7 +360,7 @@ describe YARD::Templates::Helpers::HtmlHelper do
|
|
321
360
|
end
|
322
361
|
|
323
362
|
it "should warn about missing reference for file template (no object)" do
|
324
|
-
@file =
|
363
|
+
@file = CodeObjects::ExtraFileObject.new('myfile.txt', '')
|
325
364
|
logger = mock(:log)
|
326
365
|
logger.should_receive(:warn).ordered.with("In file `myfile.txt':3: Cannot resolve link to InvalidObject from text:")
|
327
366
|
logger.should_receive(:warn).ordered.with("...{InvalidObject Some Title}")
|
@@ -414,6 +453,11 @@ describe YARD::Templates::Helpers::HtmlHelper do
|
|
414
453
|
should_not_receive(:html_syntax_highlight_NAME)
|
415
454
|
html_syntax_highlight("!!!NAME\ndef x; end").should == "def x; end"
|
416
455
|
end
|
456
|
+
|
457
|
+
it "should highlight as ruby if htmlify(text, :ruby) is called" do
|
458
|
+
should_receive(:html_syntax_highlight_ruby).with('def x; end').and_return('x')
|
459
|
+
htmlify('def x; end', :ruby).should == '<pre class="code">x</pre>'
|
460
|
+
end
|
417
461
|
end
|
418
462
|
|
419
463
|
describe '#link_url' do
|
@@ -46,30 +46,31 @@ describe YARD::Templates::Helpers::MarkupHelper do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should search through available markup providers for the markup type if none is set" do
|
49
|
-
@gen.should_receive(:eval).with('::
|
50
|
-
@gen.should_receive(:require).with('
|
49
|
+
@gen.should_receive(:eval).with('::RDiscount').and_return(mock(:bluecloth))
|
50
|
+
@gen.should_receive(:require).with('rdiscount').and_return(true)
|
51
51
|
@gen.should_not_receive(:require).with('maruku')
|
52
52
|
@gen.stub!(:options).and_return({:markup => :markdown})
|
53
53
|
# this only raises an exception because we mock out require to avoid
|
54
54
|
# loading any libraries but our implementation tries to return the library
|
55
55
|
# name as a constant
|
56
56
|
@gen.load_markup_provider.should == true
|
57
|
-
@gen.markup_provider.should == :
|
57
|
+
@gen.markup_provider.should == :rdiscount
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should continue searching if some of the providers are unavailable" do
|
61
|
-
@gen.should_receive(:require).with('
|
61
|
+
@gen.should_receive(:require).with('rdiscount').and_raise(LoadError)
|
62
62
|
@gen.should_receive(:require).with('kramdown').and_raise(LoadError)
|
63
|
+
@gen.should_receive(:require).with('bluecloth').and_raise(LoadError)
|
63
64
|
@gen.should_receive(:require).with('maruku').and_raise(LoadError)
|
64
|
-
@gen.should_receive(:require).with('
|
65
|
-
@gen.should_receive(:require).with('
|
66
|
-
@gen.should_receive(:eval).with('::
|
65
|
+
@gen.should_receive(:require).with('redcarpet').and_raise(LoadError)
|
66
|
+
@gen.should_receive(:require).with('rpeg-markdown').and_return(true)
|
67
|
+
@gen.should_receive(:eval).with('::PEGMarkdown').and_return(true)
|
67
68
|
@gen.stub!(:options).and_return({:markup => :markdown})
|
68
69
|
# this only raises an exception because we mock out require to avoid
|
69
70
|
# loading any libraries but our implementation tries to return the library
|
70
71
|
# name as a constant
|
71
72
|
@gen.load_markup_provider.should rescue nil
|
72
|
-
@gen.markup_provider.should == :
|
73
|
+
@gen.markup_provider.should == :"rpeg-markdown"
|
73
74
|
end
|
74
75
|
|
75
76
|
it "should override the search if `:markup_provider` is set in options" do
|
@@ -11,8 +11,15 @@ describe YARD::Templates::Engine.template(:default, :module) do
|
|
11
11
|
def e; end
|
12
12
|
end
|
13
13
|
|
14
|
+
module BaseMod
|
15
|
+
attr_reader :base_attr1
|
16
|
+
attr_writer :base_attr2
|
17
|
+
attr_accessor :base_attr3
|
18
|
+
end
|
19
|
+
|
14
20
|
# Comments
|
15
21
|
module A
|
22
|
+
include BaseMod
|
16
23
|
attr_accessor :attr1
|
17
24
|
attr_reader :attr2
|
18
25
|
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
class StringSerializer < YARD::Serializers::Base
|
4
|
+
attr_accessor :files, :string
|
5
|
+
def initialize(files, string)
|
6
|
+
@files = files
|
7
|
+
@string = string
|
8
|
+
end
|
9
|
+
|
10
|
+
def serialize(object, data)
|
11
|
+
files << object
|
12
|
+
string << data
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe YARD::Templates::Engine.template(:default, :onefile) do
|
17
|
+
before { Registry.clear }
|
18
|
+
|
19
|
+
it "should render html" do
|
20
|
+
files = []
|
21
|
+
string = ''
|
22
|
+
YARD.parse_string <<-eof
|
23
|
+
class A
|
24
|
+
# Foo method
|
25
|
+
# @return [String]
|
26
|
+
def foo; end
|
27
|
+
|
28
|
+
# Bar method
|
29
|
+
# @return [Numeric]
|
30
|
+
def bar; end
|
31
|
+
end
|
32
|
+
eof
|
33
|
+
Templates::Engine.generate Registry.all(:class),
|
34
|
+
:serializer => StringSerializer.new(files, string),
|
35
|
+
:onefile => true, :format => :html, :files => [
|
36
|
+
CodeObjects::ExtraFileObject.new('README',
|
37
|
+
"# This is a code comment\n\n# Top of file\n\n\nclass C; end"),
|
38
|
+
CodeObjects::ExtraFileObject.new('LICENSE', 'This is a license!')
|
39
|
+
]
|
40
|
+
files.should == ['index.html']
|
41
|
+
string.should include("This is a code comment")
|
42
|
+
string.should include("This is a license!")
|
43
|
+
string.should include("Class: A")
|
44
|
+
string.should include("Foo method")
|
45
|
+
string.should include("Bar method")
|
46
|
+
end
|
47
|
+
end
|
@@ -70,23 +70,25 @@ p.inherited {
|
|
70
70
|
margin-left: 25px;
|
71
71
|
}
|
72
72
|
|
73
|
-
dl.box {
|
73
|
+
#filecontents dl.box, dl.box {
|
74
|
+
border: 0;
|
74
75
|
width: 520px;
|
75
76
|
font-size: 1em;
|
76
77
|
}
|
77
|
-
dl.box dt {
|
78
|
+
#filecontents dl.box dt, dl.box dt {
|
78
79
|
float: left;
|
79
80
|
display: block;
|
80
81
|
width: 100px;
|
81
82
|
margin: 0;
|
82
83
|
text-align: right;
|
83
84
|
font-weight: bold;
|
85
|
+
background: transparent;
|
84
86
|
border: 1px solid #aaa;
|
85
87
|
border-width: 1px 0px 0px 1px;
|
86
88
|
padding: 6px 0;
|
87
89
|
padding-right: 10px;
|
88
90
|
}
|
89
|
-
dl.box dd {
|
91
|
+
#filecontents dl.box dd, dl.box dd {
|
90
92
|
float: left;
|
91
93
|
display: block;
|
92
94
|
width: 380px;
|
@@ -96,10 +98,10 @@ dl.box dd {
|
|
96
98
|
border: 1px solid #aaa;
|
97
99
|
border-width: 1px 1px 0 0;
|
98
100
|
}
|
99
|
-
dl.box .last {
|
101
|
+
#filecontents dl.box .last, dl.box .last {
|
100
102
|
border-bottom: 1px solid #aaa;
|
101
103
|
}
|
102
|
-
dl.box .r1 { background: #eee; }
|
104
|
+
#filecontents dl.box .r1, dl.box .r1 { background: #eee; }
|
103
105
|
|
104
106
|
ul.toplevel { list-style: none; padding-left: 0; font-size: 1.1em; }
|
105
107
|
#files { padding-left: 15px; font-size: 1.1em; }
|
@@ -2,11 +2,15 @@
|
|
2
2
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
3
|
<html>
|
4
4
|
<head>
|
5
|
-
<meta
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=<%= charset %>" />
|
6
|
+
<% stylesheets_full_list.each do |stylesheet| %>
|
7
|
+
<link rel="stylesheet" href="<%= url_for(stylesheet) %>" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<% javascripts_full_list.each do |javascript| %>
|
11
|
+
<script type="text/javascript" charset="utf-8" src="<%= url_for(javascript) %>"></script>
|
12
|
+
<% end %>
|
13
|
+
|
10
14
|
<base id="base_target" target="_parent" />
|
11
15
|
</head>
|
12
16
|
<body>
|
@@ -19,16 +23,15 @@
|
|
19
23
|
<div id="content">
|
20
24
|
<h1 id="full_list_header"><%= @list_title %></h1>
|
21
25
|
<div id="nav">
|
22
|
-
|
23
|
-
|
24
|
-
|
26
|
+
<% menu_lists.each do |list| %>
|
27
|
+
<a target="_self" href="<%= list[:type] %>_list.html"><%= list[:title] %></a>
|
28
|
+
<% end %>
|
25
29
|
</div>
|
26
30
|
<div id="search">Search: <input type="text" /></div>
|
27
31
|
|
28
|
-
<ul id="full_list" class="<%= @list_type %>">
|
32
|
+
<ul id="full_list" class="<%= @list_class || @list_type %>">
|
29
33
|
<%= erb "full_list_#{@list_type}" %>
|
30
34
|
</ul>
|
31
35
|
</div>
|
32
36
|
</body>
|
33
37
|
</html>
|
34
|
-
|
@@ -23,7 +23,7 @@ function createDefineLinks() {
|
|
23
23
|
function() {
|
24
24
|
$(this).prev().hide();
|
25
25
|
$(this).parent().prev().height(tHeight);
|
26
|
-
$(this).text("more...")
|
26
|
+
$(this).text("more...");
|
27
27
|
});
|
28
28
|
}
|
29
29
|
|
@@ -38,7 +38,7 @@ function createFullTreeLinks() {
|
|
38
38
|
function() {
|
39
39
|
$(this).parent().toggleClass('showAll');
|
40
40
|
$(this).parent().prev().height(tHeight);
|
41
|
-
$(this).text("show all")
|
41
|
+
$(this).text("show all");
|
42
42
|
});
|
43
43
|
}
|
44
44
|
|
@@ -93,13 +93,14 @@ function keyboardShortcuts() {
|
|
93
93
|
if (window.top.frames.main) return;
|
94
94
|
$(document).keypress(function(evt) {
|
95
95
|
if (evt.altKey || evt.ctrlKey || evt.metaKey || evt.shiftKey) return;
|
96
|
-
if (typeof evt.
|
97
|
-
(evt.
|
98
|
-
evt.
|
96
|
+
if (typeof evt.target !== "undefined" &&
|
97
|
+
(evt.target.nodeName == "INPUT" ||
|
98
|
+
evt.target.nodeName == "TEXTAREA")) return;
|
99
99
|
switch (evt.charCode) {
|
100
100
|
case 67: case 99: $('#class_list_link').click(); break; // 'c'
|
101
101
|
case 77: case 109: $('#method_list_link').click(); break; // 'm'
|
102
102
|
case 70: case 102: $('#file_list_link').click(); break; // 'f'
|
103
|
+
default: break;
|
103
104
|
}
|
104
105
|
});
|
105
106
|
}
|
@@ -139,31 +140,32 @@ function fixOutsideWorldLinks() {
|
|
139
140
|
}
|
140
141
|
|
141
142
|
function generateTOC() {
|
142
|
-
if ($('#filecontents').length
|
143
|
+
if ($('#filecontents').length === 0) return;
|
143
144
|
var _toc = $('<ol class="top"></ol>');
|
144
145
|
var show = false;
|
145
146
|
var toc = _toc;
|
146
147
|
var counter = 0;
|
147
148
|
var tags = ['h2', 'h3', 'h4', 'h5', 'h6'];
|
149
|
+
var i;
|
148
150
|
if ($('#filecontents h1').length > 1) tags.unshift('h1');
|
149
|
-
for (i
|
150
|
-
var lastTag = parseInt(tags[0][1]);
|
151
|
+
for (i = 0; i < tags.length; i++) { tags[i] = '#filecontents ' + tags[i]; }
|
152
|
+
var lastTag = parseInt(tags[0][1], 10);
|
151
153
|
$(tags.join(', ')).each(function() {
|
152
154
|
if (this.id == "filecontents") return;
|
153
155
|
show = true;
|
154
|
-
var thisTag = parseInt(this.tagName[1]);
|
155
|
-
if (this.id.length
|
156
|
+
var thisTag = parseInt(this.tagName[1], 10);
|
157
|
+
if (this.id.length === 0) {
|
156
158
|
var proposedId = $(this).text().replace(/[^a-z0-9-]/ig, '_');
|
157
|
-
if ($('#' + proposedId).length > 0) proposedId += counter++;
|
159
|
+
if ($('#' + proposedId).length > 0) { proposedId += counter; counter++; }
|
158
160
|
this.id = proposedId;
|
159
161
|
}
|
160
162
|
if (thisTag > lastTag) {
|
161
|
-
for (
|
163
|
+
for (i = 0; i < thisTag - lastTag; i++) {
|
162
164
|
var tmp = $('<ol/>'); toc.append(tmp); toc = tmp;
|
163
165
|
}
|
164
166
|
}
|
165
167
|
if (thisTag < lastTag) {
|
166
|
-
for (
|
168
|
+
for (i = 0; i < lastTag - thisTag; i++) toc = toc.parent();
|
167
169
|
}
|
168
170
|
toc.append('<li><a href="#' + this.id + '">' + $(this).text() + '</a></li>');
|
169
171
|
lastTag = thisTag;
|
@@ -185,7 +187,7 @@ function generateTOC() {
|
|
185
187
|
$(this).text('float');
|
186
188
|
$('#toc').toggleClass('nofloat');
|
187
189
|
}, function() {
|
188
|
-
$(this).text('left')
|
190
|
+
$(this).text('left');
|
189
191
|
$('#toc').toggleClass('nofloat');
|
190
192
|
});
|
191
193
|
}
|
@@ -13,7 +13,7 @@ function fullListSearch() {
|
|
13
13
|
|
14
14
|
$('#search input').keyup(function() {
|
15
15
|
searchString = this.value.toLowerCase();
|
16
|
-
if (searchString
|
16
|
+
if (searchString === "") {
|
17
17
|
clearTimeout(inSearch);
|
18
18
|
inSearch = null;
|
19
19
|
$('#full_list, #content').removeClass('insearch');
|
@@ -40,7 +40,7 @@ function fullListSearch() {
|
|
40
40
|
});
|
41
41
|
|
42
42
|
$('#search input').focus();
|
43
|
-
$('#full_list').after("<div id='noresults'></div>")
|
43
|
+
$('#full_list').after("<div id='noresults'></div>");
|
44
44
|
}
|
45
45
|
|
46
46
|
var lastRowClass = '';
|
@@ -59,8 +59,9 @@ function searchItem() {
|
|
59
59
|
'<strong>$1</strong>'));
|
60
60
|
}
|
61
61
|
|
62
|
-
if (searchCache.length
|
63
|
-
|
62
|
+
if (searchCache.length === searchIndex + 1) {
|
63
|
+
searchDone();
|
64
|
+
return;
|
64
65
|
}
|
65
66
|
else {
|
66
67
|
searchIndex++;
|
@@ -71,7 +72,7 @@ function searchItem() {
|
|
71
72
|
|
72
73
|
function searchDone() {
|
73
74
|
highlight(true);
|
74
|
-
if ($('#full_list li:visible').size()
|
75
|
+
if ($('#full_list li:visible').size() === 0) {
|
75
76
|
$('#noresults').text('No results were found.').hide().fadeIn();
|
76
77
|
}
|
77
78
|
else {
|
@@ -137,7 +138,7 @@ function escapeShortcut() {
|
|
137
138
|
$(document).keydown(function(evt) {
|
138
139
|
if (evt.which == 27) {
|
139
140
|
$('#search_frame', window.top.document).slideUp(100);
|
140
|
-
$('#search a', window.top.document).removeClass('active inactive')
|
141
|
+
$('#search a', window.top.document).removeClass('active inactive');
|
141
142
|
$(window.top).focus();
|
142
143
|
}
|
143
144
|
});
|