yard 0.5.6 → 0.5.7
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/ChangeLog +113 -0
- data/README.md +30 -4
- data/docs/Parser.md +26 -6
- data/docs/images/parser-class-diagram.png +0 -0
- data/lib/yard.rb +1 -1
- data/lib/yard/cli/yard_graph.rb +1 -2
- data/lib/yard/cli/yardoc.rb +54 -32
- data/lib/yard/code_objects/base.rb +7 -2
- data/lib/yard/code_objects/proxy.rb +11 -3
- data/lib/yard/code_objects/root_object.rb +5 -0
- data/lib/yard/parser/c_parser.rb +4 -1
- data/lib/yard/parser/ruby/ruby_parser.rb +0 -1
- data/lib/yard/parser/source_parser.rb +8 -7
- data/lib/yard/registry.rb +21 -6
- data/lib/yard/registry_store.rb +1 -0
- data/lib/yard/serializers/file_system_serializer.rb +8 -0
- data/lib/yard/serializers/yardoc_serializer.rb +4 -0
- data/lib/yard/tags/overload_tag.rb +6 -1
- data/lib/yard/templates/helpers/html_helper.rb +1 -1
- data/lib/yard/verifier.rb +20 -3
- data/spec/cli/yardoc_spec.rb +46 -8
- data/spec/handlers/ruby/base_spec.rb +1 -1
- data/spec/handlers/ruby/legacy/base_spec.rb +3 -3
- data/spec/parser/c_parser_spec.rb +1 -0
- data/spec/parser/source_parser_spec.rb +6 -0
- data/spec/registry_spec.rb +22 -6
- data/spec/serializers/data/serialized_yardoc/checksums +1 -0
- data/spec/serializers/data/serialized_yardoc/objects/Foo.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/objects/Foo/bar_i.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/objects/Foo/baz_i.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/objects/root.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/proxy_types +2 -0
- data/spec/serializers/yardoc_serializer_spec.rb +35 -0
- data/spec/verifier_spec.rb +30 -0
- data/templates/default/module/html/item_summary.erb +2 -2
- data/templates/default/tags/text/example.erb +2 -2
- metadata +11 -4
data/ChangeLog
CHANGED
@@ -1,3 +1,116 @@
|
|
1
|
+
2010-06-21 Loren Segal <lsegal@soen.ca>
|
2
|
+
|
3
|
+
* ChangeLog, README.md, lib/yard.rb, yard.gemspec: Bump to version 0.5.7
|
4
|
+
|
5
|
+
2010-06-17 Loren Segal <lsegal@soen.ca>
|
6
|
+
|
7
|
+
* lib/yard/cli/yardoc.rb, lib/yard/serializers/file_system_serializer.rb,
|
8
|
+
spec/cli/yardoc_spec.rb: Clean up parsing of yardoc options and handle
|
9
|
+
.document files more effectively
|
10
|
+
|
11
|
+
* README.md: Add special installation instructions for some Ubuntu/Debian
|
12
|
+
installations. It is impossible to add rdoc as a dependency, since this will
|
13
|
+
force the RDoc gem to be installed rather than the Ruby stdlib package. It is
|
14
|
+
therefore preferable to install rdoc locally with apt-get on such an OS.
|
15
|
+
Closes gh-109
|
16
|
+
|
17
|
+
2010-06-16 Loren Segal <lsegal@soen.ca>
|
18
|
+
|
19
|
+
* lib/yard/parser/ruby/ruby_parser.rb: Don't undef 'on_bodystmt'
|
20
|
+
|
21
|
+
* lib/yard/cli/yardoc.rb: Add Yardoc#parse_arguments method to perform all
|
22
|
+
argument parsing (from CLI,.yardopts,.document) at once
|
23
|
+
|
24
|
+
* lib/yard/registry_store.rb, lib/yard/serializers/yardoc_serializer.rb:
|
25
|
+
Improve StubProxy to implement #hash which removes need for TemporaryObject
|
26
|
+
hack
|
27
|
+
|
28
|
+
* spec/verifier_spec.rb: Add spec for Verifier
|
29
|
+
|
30
|
+
* lib/yard/verifier.rb: Force updating of Verifier
|
31
|
+
|
32
|
+
* templates/default/module/html/item_summary.erb: Show full method name with
|
33
|
+
"=" suffix in method summary listing
|
34
|
+
|
35
|
+
* lib/yard/parser/source_parser.rb: Add documentation for
|
36
|
+
SourceParser.parser_types
|
37
|
+
|
38
|
+
* docs/Parser.md, docs/images/parser-class-diagram.png: Update Parser
|
39
|
+
Architecture documentation Closes gh-137
|
40
|
+
|
41
|
+
* lib/yard/registry.rb: Update Registry documentation Closes gh-136
|
42
|
+
|
43
|
+
* lib/yard/parser/source_parser.rb, spec/parser/source_parser_spec.rb:
|
44
|
+
Support list of regex in registered file extensions for parser type (instead
|
45
|
+
of a single Regexp)
|
46
|
+
|
47
|
+
* lib/yard/parser/source_parser.rb: Document parser_type_extensions as
|
48
|
+
@private attr
|
49
|
+
|
50
|
+
2010-06-15 Loren Segal <lsegal@soen.ca>
|
51
|
+
|
52
|
+
* lib/yard/cli/yardoc.rb, spec/cli/yardoc_spec.rb: Hide methods inside a
|
53
|
+
@private class if --no-private is used.
|
54
|
+
|
55
|
+
* templates/default/tags/text/example.erb: Don't wrap example code in yri.
|
56
|
+
Wrapping would just cause confusion. Closes gh-71
|
57
|
+
|
58
|
+
* lib/yard/cli/yardoc.rb, lib/yard/verifier.rb, spec/cli/yardoc_spec.rb,
|
59
|
+
spec/verifier_spec.rb: Fix --private and other visibility flags when
|
60
|
+
specified in .yardopts file. The following changes were made to make this
|
61
|
+
possible: - Generate verifier for visibilities after option parsing is
|
62
|
+
finished. - Add Verifier#add_expressions and Verifier#expressions to allow
|
63
|
+
manipulation of Verifier expressions after it is created. Modifying
|
64
|
+
expressions will recompile the verifier object. Closes gh-142
|
65
|
+
|
66
|
+
* lib/yard/cli/yard_graph.rb: Update default options documentation for
|
67
|
+
YardGraph
|
68
|
+
|
69
|
+
* lib/yard/code_objects/base.rb, lib/yard/code_objects/proxy.rb,
|
70
|
+
lib/yard/code_objects/root_object.rb, lib/yard/registry_store.rb,
|
71
|
+
spec/registry_spec.rb, spec/serializers/data/serialized_yardoc/checksums,
|
72
|
+
.../data/serialized_yardoc/objects/Foo.dat,
|
73
|
+
.../data/serialized_yardoc/objects/Foo/bar_i.dat,
|
74
|
+
.../data/serialized_yardoc/objects/Foo/baz_i.dat,
|
75
|
+
.../data/serialized_yardoc/objects/root.dat,
|
76
|
+
.../serializers/data/serialized_yardoc/proxy_types,
|
77
|
+
spec/serializers/yardoc_serializer_spec.rb: Improve equality checking on
|
78
|
+
CodeObjects and add #hash/#equal? methods Closes gh-119
|
79
|
+
|
80
|
+
* lib/yard/registry.rb, spec/registry_spec.rb: Fix "cannot resolve link"
|
81
|
+
warnings for --incremental Closes gh-70
|
82
|
+
|
83
|
+
2010-06-13 Loren Segal <lsegal@soen.ca>
|
84
|
+
|
85
|
+
* lib/yard/tags/overload_tag.rb: Only override #to_a in 1.9.x
|
86
|
+
|
87
|
+
* lib/yard/tags/overload_tag.rb: 1.9.2 compatibility fix: add #to_ary and
|
88
|
+
#to_a implementations for splatting a delegate class
|
89
|
+
|
90
|
+
* lib/yard/code_objects/proxy.rb: 1.9.2 compatibility fix: re-implement fix
|
91
|
+
for #to_ary in Proxy in a cleaner way
|
92
|
+
|
93
|
+
* spec/parser/c_parser_spec.rb: 1.9.2 compatibility fix: require
|
94
|
+
'continuation' for CParser spec, since it is not required anywhere else
|
95
|
+
|
96
|
+
* spec/handlers/ruby/legacy/base_spec.rb: 1.9.2 compatibility fix: workaround
|
97
|
+
for RSpec not removing metaprogrammed class after test
|
98
|
+
|
99
|
+
* lib/yard/code_objects/proxy.rb: 1.9.2 compatibility fix: add #to_str as
|
100
|
+
alias for #path
|
101
|
+
|
102
|
+
* lib/yard/code_objects/proxy.rb: 1.9.2 compatibility fix: handle #to_ary
|
103
|
+
calls on Proxy class for #flatten in 1.9.2
|
104
|
+
|
105
|
+
* spec/handlers/ruby/base_spec.rb: 1.9.2 compatibility fix: name resolution
|
106
|
+
behaves differently
|
107
|
+
|
108
|
+
* lib/yard/templates/helpers/html_helper.rb: Fix handling of "!!!lang" code
|
109
|
+
block prefix for RDoc markup
|
110
|
+
|
111
|
+
* lib/yard/parser/c_parser.rb: Fix parsing of call-seq in .c files Closes
|
112
|
+
gh-135
|
113
|
+
|
1
114
|
2010-06-12 Loren Segal <lsegal@soen.ca>
|
2
115
|
|
3
116
|
* ChangeLog, README.md, docs/WhatsNew.md, lib/yard.rb, yard.gemspec: Release
|
data/README.md
CHANGED
@@ -5,12 +5,12 @@ YARD: Yay! A Ruby Documentation Tool
|
|
5
5
|
**IRC**: [irc://irc.freenode.net/yard](irc.freenode.net / #yard)
|
6
6
|
**Git**: [http://github.com/lsegal/yard](http://github.com/lsegal/yard)
|
7
7
|
**Author**: Loren Segal
|
8
|
-
**Contributors**: Nathan Weizenbaum, Yehuda Katz, Denis Defreyne,
|
9
|
-
Michael Edgar
|
8
|
+
**Contributors**: Nathan Weizenbaum, Dann Kubb, Yehuda Katz, Denis Defreyne,
|
9
|
+
Postmodern, Michael Edgar
|
10
10
|
**Copyright**: 2007-2010
|
11
11
|
**License**: MIT License
|
12
|
-
**Latest Version**: 0.5.
|
13
|
-
**Release Date**:
|
12
|
+
**Latest Version**: 0.5.7 (codename "The Longest")
|
13
|
+
**Release Date**: June 21st 2010
|
14
14
|
|
15
15
|
Synopsis
|
16
16
|
--------
|
@@ -95,6 +95,25 @@ who would like to reap the benefits of YARD's processing in other forms, such
|
|
95
95
|
as throwing all the documentation into a database. Another useful way of
|
96
96
|
exploiting this raw data format would be to write tools that can auto generate
|
97
97
|
test cases, for example, or show possible unhandled exceptions in code.
|
98
|
+
|
99
|
+
|
100
|
+
Installing
|
101
|
+
----------
|
102
|
+
|
103
|
+
To install YARD, use the following command:
|
104
|
+
|
105
|
+
$ gem install yard
|
106
|
+
|
107
|
+
(Add `sudo` if you're installing under a POSIX system as root)
|
108
|
+
|
109
|
+
Alternatively, if you've checked the source out directly, you can call
|
110
|
+
`rake install` from the root project directory.
|
111
|
+
|
112
|
+
**Important Note for Debian/Ubuntu users:** there's a possible chance your Ruby
|
113
|
+
install lacks RDoc, which is occasionally used by YARD to convert markup to HTML.
|
114
|
+
If running `which rdoc` turns up empty, install RDoc by issuing:
|
115
|
+
|
116
|
+
$ sudo apt-get install rdoc
|
98
117
|
|
99
118
|
|
100
119
|
Usage
|
@@ -224,6 +243,13 @@ More options can be seen by typing `yard-graph --help`, but here is an example:
|
|
224
243
|
Changelog
|
225
244
|
---------
|
226
245
|
|
246
|
+
- **June.21.10**: 0.5.7 release
|
247
|
+
- Fixed visibility flag parsing in `yardoc`
|
248
|
+
- Updated Parser Architecture documentation with new SourceParser API
|
249
|
+
- Improved Registry documentation for new load commands
|
250
|
+
- Fix loading of .yardoc file as cache (and preserving aliases)
|
251
|
+
- Fix "lib" directory missing when running YARD on installed gems
|
252
|
+
|
227
253
|
- **June.12.10**: 0.5.6 release
|
228
254
|
- Bug fixes for RubyGems plugin, `has_rdoc=false` should now work
|
229
255
|
- New API for registering custom parsers. See {file:WhatsNew.md}
|
data/docs/Parser.md
CHANGED
@@ -17,9 +17,11 @@ SourceParser
|
|
17
17
|
------------
|
18
18
|
|
19
19
|
The main class {YARD::Parser::SourceParser} acts as a factory class, instantiating
|
20
|
-
the correct parser class
|
21
|
-
|
22
|
-
|
20
|
+
the correct parser class, an implementation of {YARD::Parser::Base}. The selected parser
|
21
|
+
is chosen based on either the file extension or by selecting it explicitly (as an argument
|
22
|
+
to parsing methods). YARD supports Ruby and C source files, but custom parsers can
|
23
|
+
be implemented and registered for various other languages by subclassing `Parser::Base`
|
24
|
+
and registering the parser with {YARD::Parser::SourceParser.register_parser_type}.
|
23
25
|
|
24
26
|
This factory class should always be used when parsing source files rather than
|
25
27
|
the individual parser classes since it initiates the pipeline that runs the
|
@@ -46,11 +48,29 @@ used:
|
|
46
48
|
|
47
49
|
YARD::Parser::SourceParser.parse_string("def method(a, b) end")
|
48
50
|
|
49
|
-
|
50
|
-
parser type as an argument:
|
51
|
+
You can also provide the parser type explicitly as the second argument:
|
51
52
|
|
52
|
-
# Parses a string of C
|
53
|
+
# Parses a string of C
|
53
54
|
YARD::Parser::SourceParser.parse_string("int main() { }", :c)
|
55
|
+
|
56
|
+
Note that these two methods are aliased as {YARD.parse} and {YARD.parse_string} for
|
57
|
+
convenience.
|
58
|
+
|
59
|
+
Implementing and Registering a Custom Parser
|
60
|
+
--------------------------------------------
|
61
|
+
|
62
|
+
To implement a custom parser, subclass {YARD::Parser::Base}. Documentation on which
|
63
|
+
abstract methods should be implemented are documented in that class. After the class
|
64
|
+
is implemented, it is registered with the {YARD::Parser::SourceParser} factory class
|
65
|
+
to be called when a file of the right extension needs to be parsed, or when a user
|
66
|
+
selects that parser type explicitly. To register your new parser class, call the
|
67
|
+
method {YARD::Parser::SourceParser.register_parser_type}:
|
68
|
+
|
69
|
+
SourceParser.register_parser_type(:my_parser, MyParser, 'my_parser_ext')
|
70
|
+
|
71
|
+
The last argument can be a single extension, a list of extensions (Array), a single Regexp, or a
|
72
|
+
list of Regexps. Do not include the '.' in the extension.
|
73
|
+
|
54
74
|
|
55
75
|
The Two Ruby Parser Types
|
56
76
|
-------------------------
|
Binary file
|
data/lib/yard.rb
CHANGED
data/lib/yard/cli/yard_graph.rb
CHANGED
data/lib/yard/cli/yardoc.rb
CHANGED
@@ -36,6 +36,13 @@ module YARD
|
|
36
36
|
# @return [String] the filename to load extra options from
|
37
37
|
attr_accessor :options_file
|
38
38
|
|
39
|
+
# Keep track of which visibilities are to be shown
|
40
|
+
# @return [Array<Symbol>] a list of visibilities
|
41
|
+
attr_accessor :visibilities
|
42
|
+
|
43
|
+
# @return [Boolean] whether to build or rebuild gems
|
44
|
+
attr_accessor :build_gems, :rebuild_gems
|
45
|
+
|
39
46
|
# Helper method to create an instance and run the utility
|
40
47
|
# @see #run
|
41
48
|
def self.run(*args) new.run(*args) end
|
@@ -53,11 +60,14 @@ module YARD
|
|
53
60
|
:hide_void_return => false,
|
54
61
|
:no_highlight => false,
|
55
62
|
:files => [],
|
56
|
-
:verifier =>
|
63
|
+
:verifier => Verifier.new
|
57
64
|
)
|
65
|
+
@visibilities = [:public]
|
58
66
|
@excluded = []
|
59
67
|
@files = []
|
60
68
|
@use_cache = false
|
69
|
+
@build_gems = false
|
70
|
+
@rebuild_gems = false
|
61
71
|
@generate = true
|
62
72
|
@incremental = false
|
63
73
|
@options_file = DEFAULT_YARDOPTS_FILE
|
@@ -69,9 +79,7 @@ module YARD
|
|
69
79
|
# @param [Array<String>] args the list of arguments
|
70
80
|
# @return [void]
|
71
81
|
def run(*args)
|
72
|
-
args
|
73
|
-
optparse(*yardopts)
|
74
|
-
optparse(*args)
|
82
|
+
parse_arguments(*args)
|
75
83
|
|
76
84
|
if use_cache
|
77
85
|
Registry.load
|
@@ -80,7 +88,10 @@ module YARD
|
|
80
88
|
YARD.parse(files, excluded)
|
81
89
|
Registry.save(use_cache)
|
82
90
|
|
83
|
-
|
91
|
+
|
92
|
+
if build_gems
|
93
|
+
do_build_gems(rebuild_gems)
|
94
|
+
elsif generate
|
84
95
|
if incremental
|
85
96
|
generate_with_cache(checksums)
|
86
97
|
else
|
@@ -94,6 +105,20 @@ module YARD
|
|
94
105
|
true
|
95
106
|
end
|
96
107
|
|
108
|
+
# Parses commandline arguments
|
109
|
+
# @param [Array<String>] args the list of arguments
|
110
|
+
# @return [void]
|
111
|
+
def parse_arguments(*args)
|
112
|
+
optparse(*support_rdoc_document_file!)
|
113
|
+
optparse(*yardopts)
|
114
|
+
optparse(*args)
|
115
|
+
|
116
|
+
# Last minute modifications
|
117
|
+
self.files = ['lib/**/*.rb', 'ext/**/*.c'] if self.files.empty?
|
118
|
+
options[:readme] ||= Dir.glob('README*').first
|
119
|
+
add_visibility_verifier
|
120
|
+
end
|
121
|
+
|
97
122
|
# The list of all objects to process. Override this method to change
|
98
123
|
# which objects YARD should generate documentation for.
|
99
124
|
#
|
@@ -153,8 +178,11 @@ module YARD
|
|
153
178
|
def add_extra_files(*files)
|
154
179
|
files.map! {|f| f.include?("*") ? Dir.glob(f) : f }.flatten!
|
155
180
|
files.each do |file|
|
156
|
-
|
157
|
-
|
181
|
+
if File.file?(file)
|
182
|
+
options[:files] << file
|
183
|
+
else
|
184
|
+
log.warn "Could not find extra file: #{file}"
|
185
|
+
end
|
158
186
|
end
|
159
187
|
end
|
160
188
|
|
@@ -168,7 +196,6 @@ module YARD
|
|
168
196
|
# @param [Array<String>] files the list of files to parse
|
169
197
|
# @return [void]
|
170
198
|
def parse_files(*files)
|
171
|
-
self.files = []
|
172
199
|
seen_extra_files_marker = false
|
173
200
|
|
174
201
|
files.each do |file|
|
@@ -187,7 +214,7 @@ module YARD
|
|
187
214
|
|
188
215
|
# Builds .yardoc files for all non-existing gems
|
189
216
|
# @param [Boolean] rebuild Forces rebuild of all gems
|
190
|
-
def
|
217
|
+
def do_build_gems(rebuild = false)
|
191
218
|
require 'rubygems'
|
192
219
|
Gem.source_index.find_name('').each do |spec|
|
193
220
|
reload = true
|
@@ -207,15 +234,16 @@ module YARD
|
|
207
234
|
exit(0)
|
208
235
|
end
|
209
236
|
|
237
|
+
# Adds verifier rule for visibilities
|
238
|
+
# @return [void]
|
239
|
+
def add_visibility_verifier
|
240
|
+
vis_expr = "object.type != :method || #{visibilities.uniq.inspect}.include?(object.visibility)"
|
241
|
+
options[:verifier].add_expressions(vis_expr)
|
242
|
+
end
|
243
|
+
|
210
244
|
# Parses commandline options.
|
211
245
|
# @param [Array<String>] args each tokenized argument
|
212
246
|
def optparse(*args)
|
213
|
-
excluded = []
|
214
|
-
query_expressions = []
|
215
|
-
visibilities = [:public]
|
216
|
-
do_build_gems, do_rebuild_gems = false, false
|
217
|
-
serialopts = SymbolHash.new
|
218
|
-
|
219
247
|
opts = OptionParser.new
|
220
248
|
opts.banner = "Usage: yardoc [options] [source_files [- extra_files]]"
|
221
249
|
|
@@ -268,12 +296,12 @@ module YARD
|
|
268
296
|
end
|
269
297
|
|
270
298
|
opts.on('--build-gems', 'Builds .yardoc files for all gems (implies -n)') do
|
271
|
-
|
299
|
+
self.build_gems = true
|
272
300
|
end
|
273
301
|
|
274
302
|
opts.on('--re-build-gems', 'Forces building .yardoc files for all gems (implies -n)') do
|
275
|
-
|
276
|
-
|
303
|
+
self.build_gems = true
|
304
|
+
self.rebuild_gems = true
|
277
305
|
end
|
278
306
|
|
279
307
|
opts.separator ""
|
@@ -292,7 +320,7 @@ module YARD
|
|
292
320
|
end
|
293
321
|
|
294
322
|
opts.on('--no-private', "Hide objects with @private tag") do
|
295
|
-
|
323
|
+
options[:verifier].add_expressions '!object.tag(:private) && !object.namespace.tag(:private)'
|
296
324
|
end
|
297
325
|
|
298
326
|
opts.on('--no-highlight', "Don't highlight code in docs as Ruby.") do
|
@@ -308,7 +336,7 @@ module YARD
|
|
308
336
|
end
|
309
337
|
|
310
338
|
opts.on('--query QUERY', "Only show objects that match a specific query") do |query|
|
311
|
-
|
339
|
+
options[:verifier].add_expressions(query.taint)
|
312
340
|
end
|
313
341
|
|
314
342
|
opts.on('--list', 'List objects to standard out (implies -n)') do |format|
|
@@ -321,8 +349,11 @@ module YARD
|
|
321
349
|
end
|
322
350
|
|
323
351
|
opts.on('-r', '--readme FILE', '--main FILE', 'The readme file used as the title page of documentation.') do |readme|
|
324
|
-
|
325
|
-
|
352
|
+
if File.file?(readme)
|
353
|
+
options[:readme] = readme
|
354
|
+
else
|
355
|
+
log.warn "Could not find readme file: #{readme}"
|
356
|
+
end
|
326
357
|
end
|
327
358
|
|
328
359
|
opts.on('--files FILE1,FILE2,...', 'Any extra comma separated static files to be included (eg. FAQ)') do |files|
|
@@ -341,8 +372,7 @@ module YARD
|
|
341
372
|
|
342
373
|
opts.on('-o', '--output-dir PATH',
|
343
374
|
'The output directory. (defaults to ./doc)') do |dir|
|
344
|
-
options[:serializer] =
|
345
|
-
serialopts[:basepath] = dir
|
375
|
+
options[:serializer].basepath = dir
|
346
376
|
end
|
347
377
|
|
348
378
|
opts.on('--charset ENC', 'Character set to use for HTML output (default is system locale)') do |encoding|
|
@@ -370,15 +400,7 @@ module YARD
|
|
370
400
|
|
371
401
|
common_options(opts)
|
372
402
|
parse_options(opts, args)
|
373
|
-
|
374
|
-
# Last minute modifications
|
375
|
-
build_gems(do_rebuild_gems) if do_build_gems
|
376
403
|
parse_files(*args) unless args.empty?
|
377
|
-
self.files = ['lib/**/*.rb', 'ext/**/*.c'] if self.files.empty?
|
378
|
-
query_expressions << "object.type != :method || #{visibilities.uniq.inspect}.include?(object.visibility)"
|
379
|
-
options[:verifier] = Verifier.new(*query_expressions) unless query_expressions.empty?
|
380
|
-
options[:serializer] ||= Serializers::FileSystemSerializer.new(serialopts)
|
381
|
-
options[:readme] ||= Dir.glob('README*').first
|
382
404
|
end
|
383
405
|
end
|
384
406
|
end
|
@@ -248,13 +248,18 @@ module YARD
|
|
248
248
|
# @param [Base, Proxy] other if other is a {Proxy}, tests if
|
249
249
|
# the paths are equal
|
250
250
|
# @return [Boolean] whether or not the objects are considered the same
|
251
|
-
def
|
252
|
-
if other.is_a?(Proxy)
|
251
|
+
def equal?(other)
|
252
|
+
if other.is_a?(Base) || other.is_a?(Proxy)
|
253
253
|
path == other.path
|
254
254
|
else
|
255
255
|
super
|
256
256
|
end
|
257
257
|
end
|
258
|
+
alias == equal?
|
259
|
+
alias eql? equal?
|
260
|
+
|
261
|
+
# @return [Integer] the object's hash value (for equality checking)
|
262
|
+
def hash; path.hash end
|
258
263
|
|
259
264
|
# Accesses a custom attribute on the object
|
260
265
|
# @param [#to_s] key the name of the custom attribute
|
@@ -95,6 +95,7 @@ module YARD
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
alias to_s path
|
98
|
+
alias to_str path
|
98
99
|
|
99
100
|
# @return [Boolean]
|
100
101
|
def is_a?(klass)
|
@@ -124,13 +125,17 @@ module YARD
|
|
124
125
|
end
|
125
126
|
|
126
127
|
# @return [Boolean]
|
127
|
-
def
|
128
|
+
def equal?(other)
|
128
129
|
if other.respond_to? :path
|
129
130
|
path == other.path
|
130
131
|
else
|
131
132
|
false
|
132
133
|
end
|
133
134
|
end
|
135
|
+
alias == equal?
|
136
|
+
|
137
|
+
# @return [Integer] the object's hash value (for equality checking)
|
138
|
+
def hash; path.hash end
|
134
139
|
|
135
140
|
# Returns the class name of the object the proxy is mimicking, if
|
136
141
|
# resolved. Otherwise returns +Proxy+.
|
@@ -179,7 +184,7 @@ module YARD
|
|
179
184
|
super
|
180
185
|
end
|
181
186
|
end
|
182
|
-
|
187
|
+
|
183
188
|
# Dispatches the method to the resolved object.
|
184
189
|
#
|
185
190
|
# @raise [ProxyMethodError] if the proxy cannot find the real object
|
@@ -189,7 +194,7 @@ module YARD
|
|
189
194
|
else
|
190
195
|
log.warn "Load Order / Name Resolution Problem on #{path}:"
|
191
196
|
log.warn "-"
|
192
|
-
log.warn "Something is trying to
|
197
|
+
log.warn "Something is trying to call #{meth} on object #{path} before it has been recognized."
|
193
198
|
log.warn "This error usually means that you need to modify the order in which you parse files"
|
194
199
|
log.warn "so that #{path} is parsed before methods or other objects attempt to access it."
|
195
200
|
log.warn "-"
|
@@ -208,6 +213,9 @@ module YARD
|
|
208
213
|
def root?; false end
|
209
214
|
|
210
215
|
private
|
216
|
+
|
217
|
+
# @note this method fixes a bug in 1.9.2: http://gist.github.com/437136
|
218
|
+
def to_ary; nil end
|
211
219
|
|
212
220
|
# Attempts to find the object that this unresolved object
|
213
221
|
# references by checking if any objects by this name are
|
data/lib/yard/parser/c_parser.rb
CHANGED
@@ -199,9 +199,12 @@ module YARD
|
|
199
199
|
comments.shift
|
200
200
|
end
|
201
201
|
overloads = []
|
202
|
+
seen_data = false
|
202
203
|
while comments.first =~ /^\s+(\S.+)/ || comments.first =~ /^\s*$/
|
203
204
|
line = comments.shift.strip
|
205
|
+
break if line.empty? && seen_data
|
204
206
|
next if line.empty?
|
207
|
+
seen_data = true
|
205
208
|
line.sub!(/^\w+[\.#]/, '')
|
206
209
|
signature, types = *line.split(/ [-=]> /)
|
207
210
|
types = parse_types(object, types)
|
@@ -221,7 +224,7 @@ module YARD
|
|
221
224
|
when /^\w+\s+(#{CodeObjects::METHODMATCH})\s+(\w+)/
|
222
225
|
signature = "#{$1}(#{$2})"
|
223
226
|
end
|
224
|
-
|
227
|
+
break unless signature =~ /^#{CodeObjects::METHODNAMEMATCH}/
|
225
228
|
signature = signature.rstrip
|
226
229
|
overloads << "@overload #{signature}"
|
227
230
|
overloads << " @yield [#{blkparams}]" if blk
|
@@ -102,10 +102,16 @@ module YARD
|
|
102
102
|
end
|
103
103
|
|
104
104
|
# @return [Hash{Symbol=>Object}] a list of registered parser types
|
105
|
+
# @private
|
106
|
+
attr_reader :parser_types
|
107
|
+
undef parser_types
|
105
108
|
def parser_types; @@parser_types ||= {} end
|
106
109
|
def parser_types=(value) @@parser_types = value end
|
107
110
|
|
108
111
|
# @return [Hash] a list of registered parser type extensions
|
112
|
+
# @private
|
113
|
+
attr_reader :parser_type_extensions
|
114
|
+
undef parser_type_extensions
|
109
115
|
def parser_type_extensions; @@parser_type_extensions ||= {} end
|
110
116
|
def parser_type_extensions=(value) @@parser_type_extensions = value end
|
111
117
|
|
@@ -115,13 +121,7 @@ module YARD
|
|
115
121
|
# @return [Symbol] the parser type to be used for the extension
|
116
122
|
def parser_type_for_extension(extension)
|
117
123
|
type = parser_type_extensions.find do |t, exts|
|
118
|
-
|
119
|
-
exts.include?(extension)
|
120
|
-
elsif exts.is_a?(String)
|
121
|
-
exts == extension
|
122
|
-
elsif exts.is_a?(Regexp)
|
123
|
-
extension =~ exts
|
124
|
-
end
|
124
|
+
[exts].flatten.any? {|ext| ext === extension }
|
125
125
|
end
|
126
126
|
validated_parser_type(type ? type.first : :ruby)
|
127
127
|
end
|
@@ -131,6 +131,7 @@ module YARD
|
|
131
131
|
#
|
132
132
|
# @param [Symbol] type the parser type to set
|
133
133
|
# @return [Symbol] the validated parser type
|
134
|
+
# @private
|
134
135
|
def validated_parser_type(type)
|
135
136
|
RUBY18 && type == :ruby ? :ruby18 : type
|
136
137
|
end
|
data/lib/yard/registry.rb
CHANGED
@@ -143,11 +143,26 @@ module YARD
|
|
143
143
|
@store.load(file)
|
144
144
|
end
|
145
145
|
|
146
|
+
# Loads a yardoc file and forces all objects cached on disk into
|
147
|
+
# memory. Equivalent to calling {#load_yardoc} followed by {#load_all}
|
148
|
+
#
|
149
|
+
# @param [String] file the yardoc file to load
|
150
|
+
# @return [void]
|
151
|
+
# @see #load_yardoc
|
152
|
+
# @see #load_all
|
146
153
|
def load!(file = yardoc_file)
|
147
154
|
clear
|
148
155
|
@store.load!(file)
|
149
156
|
end
|
150
157
|
|
158
|
+
# Forces all objects cached on disk into memory
|
159
|
+
#
|
160
|
+
# @example Loads all objects from disk
|
161
|
+
# Registry.load
|
162
|
+
# Registry.all.count #=> 0
|
163
|
+
# Registry.load_all
|
164
|
+
# Registry.all.count #=> 17
|
165
|
+
# @return [void]
|
151
166
|
def load_all
|
152
167
|
@store.load_all
|
153
168
|
end
|
@@ -160,14 +175,19 @@ module YARD
|
|
160
175
|
@store.save(merge, file)
|
161
176
|
end
|
162
177
|
|
178
|
+
# @return [Hash{String => String}] a set of checksums for files
|
163
179
|
def checksums
|
164
180
|
@store.checksums
|
165
181
|
end
|
166
182
|
|
183
|
+
# @param [String] data data to checksum
|
184
|
+
# @return [String] the SHA1 checksum for data
|
167
185
|
def checksum_for(data)
|
168
186
|
Digest::SHA1.hexdigest(data)
|
169
187
|
end
|
170
188
|
|
189
|
+
# Deletes the yardoc file from disk
|
190
|
+
# @return [void]
|
171
191
|
def delete_from_disk
|
172
192
|
@store.destroy
|
173
193
|
end
|
@@ -302,12 +322,6 @@ module YARD
|
|
302
322
|
end
|
303
323
|
namespace = namespace.parent
|
304
324
|
end
|
305
|
-
|
306
|
-
# Look for ::name or #name in the root space
|
307
|
-
[CodeObjects::ISEP, CodeObjects::NSEP].each do |s|
|
308
|
-
found = at(s + name)
|
309
|
-
return found if found
|
310
|
-
end
|
311
325
|
end
|
312
326
|
proxy_fallback ? CodeObjects::Proxy.new(orignamespace, name) : nil
|
313
327
|
end
|
@@ -326,6 +340,7 @@ module YARD
|
|
326
340
|
# @param [CodeObjects::NamespaceObject] namespace the starting namespace
|
327
341
|
# @param [String] name the name to look for
|
328
342
|
def partial_resolve(namespace, name)
|
343
|
+
return at(name) || at('#' + name) if namespace.root?
|
329
344
|
[CodeObjects::NSEP, CodeObjects::CSEP, ''].each do |s|
|
330
345
|
next if s.empty? && name =~ /^\w/
|
331
346
|
path = name
|
data/lib/yard/registry_store.rb
CHANGED
@@ -5,11 +5,19 @@ module YARD
|
|
5
5
|
# @return [String] a base path
|
6
6
|
attr_reader :basepath
|
7
7
|
|
8
|
+
def basepath=(value)
|
9
|
+
@basepath = options[:basepath] = value
|
10
|
+
end
|
11
|
+
|
8
12
|
# The extension of the filename (defaults to +html+)
|
9
13
|
#
|
10
14
|
# @return [String] the extension of the file. Empty string for no extension.
|
11
15
|
attr_reader :extension
|
12
16
|
|
17
|
+
def extension=(value)
|
18
|
+
@extension = options[:extension] = value
|
19
|
+
end
|
20
|
+
|
13
21
|
# Creates a new FileSystemSerializer with options
|
14
22
|
#
|
15
23
|
# @option opts [String] :basepath ('doc') the base path to write data to
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module YARD
|
2
|
+
# Stubs marshal dumps and acts a delegate class for an object by path
|
3
|
+
#
|
4
|
+
# @private
|
2
5
|
class StubProxy
|
3
6
|
instance_methods.each {|m| undef_method(m) unless m.to_s =~ /^__|^object_id$/ }
|
4
7
|
|
5
8
|
def _dump(depth) @path end
|
6
9
|
def self._load(str) new(str) end
|
10
|
+
def hash; @path.hash end
|
7
11
|
|
8
12
|
def initialize(path, transient = false)
|
9
13
|
@path = path
|
@@ -35,8 +35,13 @@ module YARD
|
|
35
35
|
object.is_a?(other) || self.class >= other.class || false
|
36
36
|
end
|
37
37
|
alias kind_of? is_a?
|
38
|
-
|
38
|
+
|
39
39
|
private
|
40
|
+
|
41
|
+
if RUBY19
|
42
|
+
def to_a; nil end
|
43
|
+
def to_ary; nil end
|
44
|
+
end
|
40
45
|
|
41
46
|
def parse_tag(text)
|
42
47
|
@signature, text = *text.split(/\r?\n/, 2)
|
@@ -333,7 +333,7 @@ module YARD
|
|
333
333
|
return h(source) if options[:no_highlight]
|
334
334
|
|
335
335
|
# handle !!!LANG prefix to send to html_syntax_highlight_LANG
|
336
|
-
if source =~ /\A[ \t]*!!!([\w.+-]+)[ \t]*\r?\n/
|
336
|
+
if source =~ /\A(?:[ \t]*\r?\n)?[ \t]*!!!([\w.+-]+)[ \t]*\r?\n/
|
337
337
|
type, source = $1, $'
|
338
338
|
source = $'
|
339
339
|
end
|
data/lib/yard/verifier.rb
CHANGED
@@ -31,12 +31,29 @@ module YARD
|
|
31
31
|
# # Equivalent to:
|
32
32
|
# Verifier.new('@return && @param && @yield')
|
33
33
|
class Verifier
|
34
|
+
# @return [Array<String>] a list of all expressions the verifier checks for
|
35
|
+
attr_reader :expressions
|
36
|
+
|
37
|
+
def expressions=(value)
|
38
|
+
@expressions = value
|
39
|
+
create_method_from_expressions
|
40
|
+
end
|
41
|
+
|
34
42
|
# Creates a verifier from a set of expressions
|
35
43
|
#
|
36
44
|
# @param [Array<String>] expressions a list of Ruby expressions to
|
37
45
|
# parse.
|
38
46
|
def initialize(*expressions)
|
39
|
-
|
47
|
+
@expressions = []
|
48
|
+
add_expressions(*expressions)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Adds a set of expressions and recompiles the verifier
|
52
|
+
#
|
53
|
+
# @param [Array<String>] expressions a list of expressions
|
54
|
+
# @return [void]
|
55
|
+
def add_expressions(*expressions)
|
56
|
+
self.expressions += expressions.flatten
|
40
57
|
end
|
41
58
|
|
42
59
|
# Passes any method calls to the object from the {#call}
|
@@ -87,8 +104,8 @@ module YARD
|
|
87
104
|
# Creates the +__execute+ method by evaluating the expressions
|
88
105
|
# as Ruby code
|
89
106
|
# @return [void]
|
90
|
-
def create_method_from_expressions
|
91
|
-
expr =
|
107
|
+
def create_method_from_expressions
|
108
|
+
expr = expressions.map {|e| "(#{parse_expression(e)})" }.join(" && ")
|
92
109
|
|
93
110
|
instance_eval(<<-eof, __FILE__, __LINE__ + 1)
|
94
111
|
def __execute; #{expr}; end
|
data/spec/cli/yardoc_spec.rb
CHANGED
@@ -35,9 +35,18 @@ describe YARD::CLI::Yardoc do
|
|
35
35
|
@yardoc.stub!(:support_rdoc_document_file!).and_return([])
|
36
36
|
@yardoc.options_file = "test"
|
37
37
|
@yardoc.run
|
38
|
-
@yardoc.options[:serializer].options[:basepath].should ==
|
38
|
+
@yardoc.options[:serializer].options[:basepath].should == "MYPATH"
|
39
39
|
@yardoc.files.should == ["FILE1", "FILE2"]
|
40
40
|
end
|
41
|
+
|
42
|
+
it "should setup visibility rules as verifier" do
|
43
|
+
methobj = CodeObjects::MethodObject.new(:root, :test) {|o| o.visibility = :private }
|
44
|
+
File.should_receive(:read_binary).with("test").and_return("--private")
|
45
|
+
@yardoc.stub!(:support_rdoc_document_file!).and_return([])
|
46
|
+
@yardoc.options_file = "test"
|
47
|
+
@yardoc.run
|
48
|
+
@yardoc.options[:verifier].call(methobj).should be_true
|
49
|
+
end
|
41
50
|
|
42
51
|
it "should use String#shell_split to split .yardopts tokens" do
|
43
52
|
optsdata = "foo bar"
|
@@ -60,7 +69,7 @@ describe YARD::CLI::Yardoc do
|
|
60
69
|
File.should_receive(:read_binary).with(".yardopts").and_return("-o NOTMYPATH")
|
61
70
|
@yardoc.stub!(:support_rdoc_document_file!).and_return([])
|
62
71
|
@yardoc.run("-o", "MYPATH", "FILE")
|
63
|
-
@yardoc.options[:serializer].options[:basepath].should ==
|
72
|
+
@yardoc.options[:serializer].options[:basepath].should == "MYPATH"
|
64
73
|
@yardoc.files.should == ["FILE"]
|
65
74
|
end
|
66
75
|
|
@@ -68,8 +77,8 @@ describe YARD::CLI::Yardoc do
|
|
68
77
|
File.should_receive(:read_binary).with(".yardopts").and_return("-o NOTMYPATH")
|
69
78
|
@yardoc.stub!(:support_rdoc_document_file!).and_return(["FILE2", "FILE3"])
|
70
79
|
@yardoc.run("-o", "MYPATH", "FILE1")
|
71
|
-
@yardoc.options[:serializer].options[:basepath].should ==
|
72
|
-
@yardoc.files.should == ["
|
80
|
+
@yardoc.options[:serializer].options[:basepath].should == "MYPATH"
|
81
|
+
@yardoc.files.should == ["FILE2", "FILE3", "FILE1"]
|
73
82
|
end
|
74
83
|
|
75
84
|
it "should accept extra files if specified after '-' with source files" do
|
@@ -81,23 +90,29 @@ describe YARD::CLI::Yardoc do
|
|
81
90
|
end
|
82
91
|
|
83
92
|
it "should accept files section only containing extra files" do
|
84
|
-
@yardoc.
|
93
|
+
@yardoc.stub!(:support_rdoc_document_file!).and_return([])
|
94
|
+
@yardoc.stub!(:yardopts).and_return([])
|
95
|
+
@yardoc.parse_arguments *%w( - LICENSE )
|
85
96
|
@yardoc.files.should == %w( lib/**/*.rb ext/**/*.c )
|
86
97
|
@yardoc.options[:files].should == %w( LICENSE )
|
87
98
|
end
|
88
99
|
|
89
100
|
it "should accept globs as extra files" do
|
101
|
+
@yardoc.stub!(:support_rdoc_document_file!).and_return([])
|
102
|
+
@yardoc.stub!(:yardopts).and_return([])
|
90
103
|
Dir.should_receive(:glob).with('README*').and_return []
|
91
104
|
Dir.should_receive(:glob).with('*.txt').and_return ['a.txt', 'b.txt']
|
92
105
|
File.should_receive(:file?).with('a.txt').and_return(true)
|
93
106
|
File.should_receive(:file?).with('b.txt').and_return(true)
|
94
|
-
@yardoc.
|
107
|
+
@yardoc.parse_arguments *%w( file1 file2 - *.txt )
|
95
108
|
@yardoc.files.should == %w( file1 file2 )
|
96
109
|
@yardoc.options[:files].should == %w( a.txt b.txt )
|
97
110
|
end
|
98
111
|
|
99
112
|
it "should accept no params and parse lib/**/*.rb ext/**/*.c" do
|
100
|
-
@yardoc.
|
113
|
+
@yardoc.stub!(:support_rdoc_document_file!).and_return([])
|
114
|
+
@yardoc.stub!(:yardopts).and_return([])
|
115
|
+
@yardoc.parse_arguments
|
101
116
|
@yardoc.files.should == %w( lib/**/*.rb ext/**/*.c )
|
102
117
|
end
|
103
118
|
|
@@ -117,11 +132,24 @@ describe YARD::CLI::Yardoc do
|
|
117
132
|
|
118
133
|
it "should accept --no-private" do
|
119
134
|
obj = mock(:object)
|
120
|
-
obj.should_receive(:tag).ordered.with(
|
135
|
+
obj.should_receive(:tag).ordered.with(:private).and_return(true)
|
121
136
|
@yardoc.optparse *%w( --no-private )
|
122
137
|
@yardoc.options[:verifier].call(obj).should == false
|
123
138
|
end
|
124
139
|
|
140
|
+
it "should hide methods inside a 'private' class/module with --no-private" do
|
141
|
+
Registry.clear
|
142
|
+
YARD.parse_string <<-eof
|
143
|
+
# @private
|
144
|
+
class A
|
145
|
+
def foo; end
|
146
|
+
end
|
147
|
+
eof
|
148
|
+
@yardoc.optparse *%w( --no-private )
|
149
|
+
@yardoc.options[:verifier].call(Registry.at('A')).should be_false
|
150
|
+
@yardoc.options[:verifier].call(Registry.at('A#foo')).should be_false
|
151
|
+
end
|
152
|
+
|
125
153
|
it "should accept --default-return" do
|
126
154
|
@yardoc.optparse *%w( --default-return XYZ )
|
127
155
|
@yardoc.options[:default_return].should == "XYZ"
|
@@ -151,4 +179,14 @@ describe YARD::CLI::Yardoc do
|
|
151
179
|
@yardoc.use_cache.should == true
|
152
180
|
@yardoc.generate.should == true
|
153
181
|
end
|
182
|
+
|
183
|
+
it "should warn if extra file is not found" do
|
184
|
+
log.should_receive(:warn).with(/Could not find extra file: UNKNOWN/)
|
185
|
+
@yardoc.optparse *%w( - UNKNOWN )
|
186
|
+
end
|
187
|
+
|
188
|
+
it "should warn if readme file is not found" do
|
189
|
+
log.should_receive(:warn).with(/Could not find readme file: UNKNOWN/)
|
190
|
+
@yardoc.optparse *%w( -r UNKNOWN )
|
191
|
+
end
|
154
192
|
end
|
@@ -17,11 +17,11 @@ describe YARD::Handlers::Ruby::Legacy::Base, "#handles and inheritance" do
|
|
17
17
|
class IgnoredHandler < Handlers::Base
|
18
18
|
handles "hello"
|
19
19
|
end
|
20
|
-
class
|
20
|
+
class NotIgnoredHandlerLegacy < Handlers::Ruby::Legacy::Base
|
21
21
|
handles "hello"
|
22
22
|
end
|
23
|
-
Handlers::Base.stub!(:subclasses).and_return [IgnoredHandler,
|
24
|
-
@processor.find_handlers(stmt("hello world")).should == [
|
23
|
+
Handlers::Base.stub!(:subclasses).and_return [IgnoredHandler, NotIgnoredHandlerLegacy]
|
24
|
+
@processor.find_handlers(stmt("hello world")).should == [NotIgnoredHandlerLegacy]
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should handle a string input" do
|
@@ -50,6 +50,12 @@ describe YARD::Parser::SourceParser do
|
|
50
50
|
Parser::SourceParser.parser_type_for_extension('dabcd').should_not == :my_parser
|
51
51
|
end
|
52
52
|
|
53
|
+
it "should find an extension in a list of Regexps" do
|
54
|
+
Parser::SourceParser.register_parser_type(:my_parser, MyParser, [/ab$/, /abc$/])
|
55
|
+
Parser::SourceParser.parser_type_for_extension('dabc').should == :my_parser
|
56
|
+
Parser::SourceParser.parser_type_for_extension('dabcd').should_not == :my_parser
|
57
|
+
end
|
58
|
+
|
53
59
|
it "should find an extension in a String" do
|
54
60
|
Parser::SourceParser.register_parser_type(:my_parser, MyParser, "abc")
|
55
61
|
Parser::SourceParser.parser_type_for_extension('abc').should == :my_parser
|
data/spec/registry_spec.rb
CHANGED
@@ -137,6 +137,17 @@ describe YARD::Registry do
|
|
137
137
|
Registry.resolve(yard, "class_hello", false).should be_nil
|
138
138
|
Registry.resolve(yard, "class_hello", true).should == cmeth
|
139
139
|
end
|
140
|
+
|
141
|
+
it "should only check 'Path' in lookup on root namespace" do
|
142
|
+
Registry.instance.should_receive(:at).once.with('Test').and_return(true)
|
143
|
+
Registry.resolve(Registry.root, "Test")
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should not perform lookup by joining namespace and name without separator" do
|
147
|
+
yard = ClassObject.new(:root, :YARD)
|
148
|
+
Registry.instance.should_not_receive(:at).with('YARDB')
|
149
|
+
Registry.resolve(yard, 'B')
|
150
|
+
end
|
140
151
|
end
|
141
152
|
|
142
153
|
describe '#all' do
|
@@ -173,15 +184,20 @@ describe YARD::Registry do
|
|
173
184
|
end
|
174
185
|
|
175
186
|
describe '#load_yardoc' do
|
176
|
-
before do
|
177
|
-
@store = RegistryStore.new
|
178
|
-
RegistryStore.should_receive(:new).and_return(@store)
|
179
|
-
end
|
180
|
-
|
181
187
|
it "should delegate load to RegistryStore" do
|
182
|
-
|
188
|
+
store = RegistryStore.new
|
189
|
+
store.should_receive(:load).with('foo')
|
190
|
+
RegistryStore.should_receive(:new).and_return(store)
|
183
191
|
Registry.yardoc_file = 'foo'
|
184
192
|
Registry.load_yardoc
|
185
193
|
end
|
194
|
+
|
195
|
+
it "should maintain hash key equality on loaded objects" do
|
196
|
+
Registry.clear
|
197
|
+
Registry.load!(File.dirname(__FILE__) + '/serializers/data/serialized_yardoc')
|
198
|
+
baz = Registry.at('Foo#baz')
|
199
|
+
Registry.at('Foo').aliases.keys.should include(baz)
|
200
|
+
Registry.at('Foo').aliases.has_key?(baz).should == true
|
201
|
+
end
|
186
202
|
end
|
187
203
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
test.rb 80e5834ff1e98223761615c0917ff9b77b7ae057
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/spec_helper"
|
2
|
+
|
3
|
+
instance_eval do
|
4
|
+
class YARD::Serializers::YardocSerializer
|
5
|
+
public :dump
|
6
|
+
public :internal_dump
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe YARD::Serializers::YardocSerializer do
|
11
|
+
describe '#dump' do
|
12
|
+
before do
|
13
|
+
@serializer = YARD::Serializers::YardocSerializer.new('.yardoc')
|
14
|
+
|
15
|
+
Registry.clear
|
16
|
+
@foo = CodeObjects::ClassObject.new(:root, :Foo)
|
17
|
+
@bar = CodeObjects::MethodObject.new(@foo, :bar)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should maintain object equality when loading a dumped object" do
|
21
|
+
newfoo = @serializer.internal_dump(@foo)
|
22
|
+
newfoo.should equal(@foo)
|
23
|
+
newfoo.should == @foo
|
24
|
+
@foo.should equal(newfoo)
|
25
|
+
@foo.should == newfoo
|
26
|
+
newfoo.hash.should == @foo.hash
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should maintain hash key equality when loading a dumped object" do
|
30
|
+
newfoo = @serializer.internal_dump(@foo)
|
31
|
+
{@foo => 1}.should have_key(newfoo)
|
32
|
+
{newfoo => 1}.should have_key(@foo)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/verifier_spec.rb
CHANGED
@@ -47,5 +47,35 @@ describe YARD::Verifier do
|
|
47
47
|
obj.should_receive(:tag).and_return(nil)
|
48
48
|
Verifier.new('@return.text').call(obj).should == false
|
49
49
|
end
|
50
|
+
|
51
|
+
it "should not fail if no expressions were added" do
|
52
|
+
lambda { Verifier.new.call(nil) }.should_not raise_error
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#expressions' do
|
57
|
+
it "should maintain a list of all unparsed expressions" do
|
58
|
+
Verifier.new('@return.text', '@private').expressions.should == ['@return.text', '@private']
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#expressions=' do
|
63
|
+
it "should recompile expressions when attribute is modified" do
|
64
|
+
obj = mock(:object)
|
65
|
+
obj.should_receive(:tag).with('return')
|
66
|
+
v = Verifier.new
|
67
|
+
v.expressions = ['@return']
|
68
|
+
v.call(obj)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#add_expressions' do
|
73
|
+
it "should add new expressions and recompile" do
|
74
|
+
obj = mock(:object)
|
75
|
+
obj.should_receive(:tag).with('return')
|
76
|
+
v = Verifier.new
|
77
|
+
v.add_expressions '@return'
|
78
|
+
v.call(obj)
|
79
|
+
end
|
50
80
|
end
|
51
81
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<li class="<%= @item.visibility %> <%= @item.has_tag?(:deprecated) ? 'deprecated' : '' %>">
|
2
2
|
<span class="summary_signature">
|
3
3
|
<% if @item.tags(:overload).size == 1 %>
|
4
|
-
<%= signature(@item.tag(:overload), true,
|
4
|
+
<%= signature(@item.tag(:overload), true, !@item.attr_info) %>
|
5
5
|
<% else %>
|
6
|
-
<%= signature(@item, true, false,
|
6
|
+
<%= signature(@item, true, false, !@item.attr_info) %>
|
7
7
|
<% end %>
|
8
8
|
|
9
9
|
<% if @item.aliases.size > 0 %>
|
@@ -4,8 +4,8 @@ Examples:
|
|
4
4
|
---------
|
5
5
|
|
6
6
|
<% object.tags(:example).each_with_index do |tag, i| %>
|
7
|
-
<%= indent(
|
8
|
-
<%= indent(
|
7
|
+
<%= indent("# " + tag.name + "\n") if tag.name %>
|
8
|
+
<%= indent(format_source(tag.text)) + "\n" %>
|
9
9
|
<%= "\n" if i < object.tags(:example).size - 1 %>
|
10
10
|
<% end %>
|
11
11
|
<% end %>
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 7
|
10
|
+
version: 0.5.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Loren Segal
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-21 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -218,8 +218,15 @@ files:
|
|
218
218
|
- spec/rake/yardoc_task_spec.rb
|
219
219
|
- spec/registry_spec.rb
|
220
220
|
- spec/registry_store_spec.rb
|
221
|
+
- spec/serializers/data/serialized_yardoc/checksums
|
222
|
+
- spec/serializers/data/serialized_yardoc/objects/Foo/bar_i.dat
|
223
|
+
- spec/serializers/data/serialized_yardoc/objects/Foo/baz_i.dat
|
224
|
+
- spec/serializers/data/serialized_yardoc/objects/Foo.dat
|
225
|
+
- spec/serializers/data/serialized_yardoc/objects/root.dat
|
226
|
+
- spec/serializers/data/serialized_yardoc/proxy_types
|
221
227
|
- spec/serializers/file_system_serializer_spec.rb
|
222
228
|
- spec/serializers/spec_helper.rb
|
229
|
+
- spec/serializers/yardoc_serializer_spec.rb
|
223
230
|
- spec/spec_helper.rb
|
224
231
|
- spec/tags/default_factory_spec.rb
|
225
232
|
- spec/tags/default_tag_spec.rb
|