yard 0.8.3 → 0.8.4
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 +197 -38
- data/LICENSE +1 -1
- data/README.md +15 -4
- data/docs/GettingStarted.md +6 -6
- data/docs/WhatsNew.md +5 -0
- data/docs/images/code-objects-class-diagram.png +0 -0
- data/docs/images/handlers-class-diagram.png +0 -0
- data/docs/images/overview-class-diagram.png +0 -0
- data/docs/images/parser-class-diagram.png +0 -0
- data/docs/images/tags-class-diagram.png +0 -0
- data/lib/yard/autoload.rb +2 -0
- data/lib/yard/cli/graph.rb +3 -2
- data/lib/yard/cli/server.rb +3 -0
- data/lib/yard/cli/yardoc.rb +1 -0
- data/lib/yard/code_objects/base.rb +60 -30
- data/lib/yard/code_objects/extra_file_object.rb +1 -1
- data/lib/yard/code_objects/proxy.rb +1 -0
- data/lib/yard/docstring.rb +36 -2
- data/lib/yard/docstring_parser.rb +25 -2
- data/lib/yard/handlers/base.rb +18 -2
- data/lib/yard/handlers/c/handler_methods.rb +1 -1
- data/lib/yard/handlers/processor.rb +3 -0
- data/lib/yard/handlers/ruby/class_handler.rb +1 -2
- data/lib/yard/handlers/ruby/dsl_handler_methods.rb +7 -1
- data/lib/yard/handlers/ruby/exception_handler.rb +2 -2
- data/lib/yard/handlers/ruby/legacy/class_handler.rb +4 -3
- data/lib/yard/handlers/ruby/legacy/exception_handler.rb +2 -2
- data/lib/yard/handlers/ruby/legacy/method_handler.rb +4 -4
- data/lib/yard/handlers/ruby/legacy/yield_handler.rb +4 -4
- data/lib/yard/handlers/ruby/method_handler.rb +6 -6
- data/lib/yard/handlers/ruby/struct_handler_methods.rb +4 -4
- data/lib/yard/handlers/ruby/yield_handler.rb +4 -4
- data/lib/yard/i18n/locale.rb +16 -0
- data/lib/yard/parser/ruby/legacy/statement_list.rb +3 -0
- data/lib/yard/parser/ruby/ruby_parser.rb +9 -4
- data/lib/yard/rubygems/doc_manager.rb +16 -7
- data/lib/yard/server/templates/default/fulldoc/html/images/processing.gif +0 -0
- data/lib/yard/tags/directives.rb +3 -2
- data/lib/yard/tags/overload_tag.rb +1 -1
- data/lib/yard/templates/helpers/html_helper.rb +5 -2
- data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +3 -3
- data/lib/yard/version.rb +1 -1
- data/spec/cli/server_spec.rb +18 -0
- data/spec/code_objects/base_spec.rb +32 -1
- data/spec/handlers/base_spec.rb +9 -0
- data/spec/handlers/dsl_handler_spec.rb +12 -1
- data/spec/handlers/examples/dsl_handler_001.rb.txt +16 -1
- data/spec/handlers/examples/visibility_handler_001.rb.txt +5 -0
- data/spec/handlers/method_handler_spec.rb +3 -3
- data/spec/handlers/processor_spec.rb +12 -1
- data/spec/handlers/visibility_handler_spec.rb +5 -0
- data/spec/parser/ruby/ruby_parser_spec.rb +13 -0
- data/spec/parser/source_parser_spec.rb +38 -1
- data/spec/server/doc_server_helper_spec.rb +2 -0
- data/spec/tags/directives_spec.rb +8 -1
- data/spec/tags/overload_tag_spec.rb +1 -1
- data/spec/templates/helpers/html_helper_spec.rb +25 -5
- data/templates/default/class/setup.rb +1 -1
- data/templates/default/module/html/box_info.erb +1 -1
- data/templates/default/tags/html/example.erb +1 -1
- data/templates/default/tags/setup.rb +1 -1
- data/templates/guide/fulldoc/html/css/style.css +12 -5
- data/templates/guide/layout/html/layout.erb +4 -4
- metadata +3 -3
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -6,10 +6,10 @@ YARD: Yay! A Ruby Documentation Tool
|
|
6
6
|
**Git**: [http://github.com/lsegal/yard](http://github.com/lsegal/yard)
|
7
7
|
**Author**: Loren Segal
|
8
8
|
**Contributors**: See Contributors section below
|
9
|
-
**Copyright**: 2007-
|
9
|
+
**Copyright**: 2007-2013
|
10
10
|
**License**: MIT License
|
11
|
-
**Latest Version**: 0.8.
|
12
|
-
**Release Date**:
|
11
|
+
**Latest Version**: 0.8.4
|
12
|
+
**Release Date**: February 4th 2013
|
13
13
|
|
14
14
|
Synopsis
|
15
15
|
--------
|
@@ -286,6 +286,17 @@ More options can be seen by typing `yard graph --help`, but here is an example:
|
|
286
286
|
|
287
287
|
## Changelog
|
288
288
|
|
289
|
+
- **February.4.13**: 0.8.4 release
|
290
|
+
- Add `-B/--bind` switch to yard server (#593, #608)
|
291
|
+
- Add CodeObjects::Base#title for plugins to customize how object
|
292
|
+
links display (#646)
|
293
|
+
- Disable linking objects filtered out by verifiers (#645)
|
294
|
+
- Allow macro expansion on class methods (#632)
|
295
|
+
- Expand newly attached macro on first DSL method call (#631)
|
296
|
+
- Disable RubyGems plugin in Ruby 2.0 (#627)
|
297
|
+
- Fix line range for class/module node bodies (#626)
|
298
|
+
- Search extended modules for attached DSL macros (#553)
|
299
|
+
|
289
300
|
- **October.14.12**: 0.8.3 release
|
290
301
|
- Add `--non-transitive-tag` to disable tag transitivity (#571)
|
291
302
|
- Support --db inside .yardopts for graph/server commands (#583, #586)
|
@@ -562,7 +573,7 @@ http://github.com/lsegal/yard/contributors
|
|
562
573
|
|
563
574
|
## Copyright
|
564
575
|
|
565
|
-
YARD © 2007-
|
576
|
+
YARD © 2007-2013 by [Loren Segal](mailto:lsegal@soen.ca). YARD is
|
566
577
|
licensed under the MIT license except for some files which come from the
|
567
578
|
RDoc/Ruby distributions. Please see the {file:LICENSE} and {file:LEGAL}
|
568
579
|
documents for more information.
|
data/docs/GettingStarted.md
CHANGED
@@ -51,7 +51,7 @@ In YARD, we would simply define our method as:
|
|
51
51
|
|
52
52
|
# Converts the object into textual markup given a specific format.
|
53
53
|
#
|
54
|
-
# @param [Symbol]
|
54
|
+
# @param format [Symbol] the format type, `:text` or `:html`
|
55
55
|
# @return [String] the object converted into the expected format.
|
56
56
|
def to_format(format = :html)
|
57
57
|
# format the object
|
@@ -105,7 +105,7 @@ from that docstring/tag into your current object. Consider the example:
|
|
105
105
|
|
106
106
|
class MyWebServer
|
107
107
|
# Handles a request
|
108
|
-
# @param [Request]
|
108
|
+
# @param request [Request] the request object
|
109
109
|
# @return [String] the resulting webpage
|
110
110
|
def get(request) "hello" end
|
111
111
|
|
@@ -134,7 +134,7 @@ and return tags:
|
|
134
134
|
|
135
135
|
class MyWebServer
|
136
136
|
# Handles a GET request
|
137
|
-
# @param [Request]
|
137
|
+
# @param request [Request] the request object
|
138
138
|
# @return [String] the resulting webpage
|
139
139
|
def get(request) "hello" end
|
140
140
|
|
@@ -165,8 +165,8 @@ with or without a types field.
|
|
165
165
|
The list of types is in the form `[type1, type2, ...]` and is mostly free-form,
|
166
166
|
so we can also specify duck-types or constant values. For example:
|
167
167
|
|
168
|
-
# @param [#to_s]
|
169
|
-
# @param [true, false]
|
168
|
+
# @param argname [#to_s] any object that responds to `#to_s`
|
169
|
+
# @param argname [true, false] only true or false
|
170
170
|
|
171
171
|
Note the latter example can be replaced by the meta-type "Boolean".
|
172
172
|
Another meta-type is "void", which stands for "no meaningful value"
|
@@ -177,7 +177,7 @@ List types can be specified in the form `CollectionClass<ElementType, ...>`.
|
|
177
177
|
For instance, consider the following Array that holds a set of Strings and
|
178
178
|
Symbols:
|
179
179
|
|
180
|
-
# @param [Array<String, Symbol>]
|
180
|
+
# @param list [Array<String, Symbol>] the list of strings and symbols.
|
181
181
|
|
182
182
|
We mentioned that these type fields are "mostly" free-form. In truth, they
|
183
183
|
are defined "by convention". To view samples of common type specifications
|
data/docs/WhatsNew.md
CHANGED
@@ -17,6 +17,7 @@
|
|
17
17
|
13. **Single object db now default (multi-object db unsupported)** (0.8.0)
|
18
18
|
14. **Added `--api` tag to generate documentation for API sets** (0.8.1)
|
19
19
|
15. **Added `--non-transitive-tag` to disable transitive tag** (0.8.3)
|
20
|
+
16. **Added `-B/--bind` to bind to a port in yard server** (0.8.4)
|
20
21
|
|
21
22
|
## Directives (new behavioural tag syntax) (0.8.0)
|
22
23
|
|
@@ -292,6 +293,10 @@ when you define it on a class. Only the class itself has a specific
|
|
292
293
|
Which will avoid classifying treating @api as a transitive tag
|
293
294
|
when parsing modules and classes.
|
294
295
|
|
296
|
+
## Added `-B/--bind` to bind to a port in yard server (0.8.4)
|
297
|
+
|
298
|
+
You can now bind the `yard server` command to a given local port
|
299
|
+
with `yard server -B PORT` or `yard server --bind PORT`.
|
295
300
|
|
296
301
|
# What's New in 0.7.x?
|
297
302
|
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/yard/autoload.rb
CHANGED
@@ -127,6 +127,7 @@ module YARD
|
|
127
127
|
end
|
128
128
|
|
129
129
|
autoload :Base, __p('handlers/base')
|
130
|
+
autoload :HandlerAborted, __p('handlers/base')
|
130
131
|
autoload :NamespaceMissingError, __p('handlers/base')
|
131
132
|
autoload :Processor, __p('handlers/processor')
|
132
133
|
end
|
@@ -230,6 +231,7 @@ module YARD
|
|
230
231
|
autoload :AttributeDirective, __p('tags/directives')
|
231
232
|
autoload :DefaultFactory, __p('tags/default_factory')
|
232
233
|
autoload :DefaultTag, __p('tags/default_tag')
|
234
|
+
autoload :Directive, __p('tags/directives')
|
233
235
|
autoload :EndGroupDirective, __p('tags/directives')
|
234
236
|
autoload :GroupDirective, __p('tags/directives')
|
235
237
|
autoload :Library, __p('tags/library')
|
data/lib/yard/cli/graph.rb
CHANGED
@@ -26,7 +26,7 @@ module YARD
|
|
26
26
|
# :format => :dot
|
27
27
|
attr_reader :options
|
28
28
|
|
29
|
-
# The set of objects to include
|
29
|
+
# The set of objects to include in the graph.
|
30
30
|
attr_reader :objects
|
31
31
|
|
32
32
|
# Creates a new instance of the command-line utility
|
@@ -50,7 +50,6 @@ module YARD
|
|
50
50
|
# @param [Array<String>] args each tokenized argument
|
51
51
|
def run(*args)
|
52
52
|
parse_arguments(*args)
|
53
|
-
Registry.load
|
54
53
|
|
55
54
|
contents = objects.map do |o|
|
56
55
|
o.format(options.merge(:serialize => false))
|
@@ -112,6 +111,8 @@ module YARD
|
|
112
111
|
common_options(opts)
|
113
112
|
parse_options(opts, args)
|
114
113
|
|
114
|
+
Registry.load
|
115
|
+
|
115
116
|
options.verifier = Verifier.new("object.type != :method || #{visibilities.uniq.inspect}.include?(object.visibility)")
|
116
117
|
if args.first
|
117
118
|
@objects = args.map {|o| Registry.at(o) }.compact
|
data/lib/yard/cli/server.rb
CHANGED
@@ -181,6 +181,9 @@ module YARD
|
|
181
181
|
opts.on('-d', '--daemon', 'Daemonizes the server process') do
|
182
182
|
server_options[:daemonize] = true
|
183
183
|
end
|
184
|
+
opts.on('-B HOST', '--bind', 'The host address to bind to') do |host|
|
185
|
+
server_options[:Host] = host.to_s
|
186
|
+
end
|
184
187
|
opts.on('-p PORT', '--port', 'Serves documentation on PORT') do |port|
|
185
188
|
server_options[:Port] = port.to_i
|
186
189
|
end
|
data/lib/yard/cli/yardoc.rb
CHANGED
@@ -50,7 +50,7 @@ module YARD
|
|
50
50
|
CONSTANTMATCH = /[A-Z]\w*/
|
51
51
|
|
52
52
|
# Regular expression to match namespaces (const A or complex path A::B)
|
53
|
-
NAMESPACEMATCH = /(?:(?:#{NSEPQ})?#{CONSTANTMATCH})+/
|
53
|
+
NAMESPACEMATCH = /(?:(?:#{NSEPQ}\s*)?#{CONSTANTMATCH})+/
|
54
54
|
|
55
55
|
# Regular expression to match a method name
|
56
56
|
METHODNAMEMATCH = /[a-zA-Z_]\w*[!?=]?|[-+~]\@|<<|>>|=~|===?|<=>|[<>]=?|\*\*|[-\/+%^&*~`|]|\[\]=?/
|
@@ -136,9 +136,10 @@ module YARD
|
|
136
136
|
# @return [String] a line of source
|
137
137
|
attr_accessor :signature
|
138
138
|
|
139
|
-
# The documentation string associated with the object
|
139
|
+
# The non-localized documentation string associated with the object
|
140
140
|
# @return [Docstring] the documentation string
|
141
|
-
|
141
|
+
# @since 0.8.4
|
142
|
+
attr_reader :base_docstring
|
142
143
|
|
143
144
|
# Marks whether or not the method is conditionally defined at runtime
|
144
145
|
# @return [Boolean] true if the method is conditionally defined at runtime
|
@@ -218,9 +219,8 @@ module YARD
|
|
218
219
|
@source_type = :ruby
|
219
220
|
@visibility = :public
|
220
221
|
@tags = []
|
221
|
-
@
|
222
|
-
@
|
223
|
-
@docstring_extra_tags = nil
|
222
|
+
@docstrings = {}
|
223
|
+
@base_docstring = Docstring.new('', self)
|
224
224
|
@namespace = nil
|
225
225
|
self.namespace = namespace
|
226
226
|
yield(self) if block_given?
|
@@ -237,7 +237,7 @@ module YARD
|
|
237
237
|
ivar = "@#{ivar}"
|
238
238
|
other.instance_variable_set(ivar, instance_variable_get(ivar))
|
239
239
|
end
|
240
|
-
other.docstring =
|
240
|
+
other.docstring = @base_docstring.to_raw
|
241
241
|
other
|
242
242
|
end
|
243
243
|
|
@@ -365,19 +365,25 @@ module YARD
|
|
365
365
|
end
|
366
366
|
end
|
367
367
|
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
@
|
376
|
-
@
|
377
|
-
|
378
|
-
|
368
|
+
# The documentation string associated with the object
|
369
|
+
#
|
370
|
+
# @param [String, I18n::Locale] locale (I18n::Locale.default)
|
371
|
+
# the locale of the documentation string.
|
372
|
+
# @return [Docstring] the documentation string
|
373
|
+
def docstring(locale = I18n::Locale.default)
|
374
|
+
if locale.nil?
|
375
|
+
@base_docstring.resolve_reference
|
376
|
+
return @base_docstring
|
377
|
+
end
|
378
|
+
|
379
|
+
if locale.is_a?(String)
|
380
|
+
locale_name = locale
|
381
|
+
locale = nil
|
382
|
+
else
|
383
|
+
locale_name = locale.name
|
379
384
|
end
|
380
|
-
@
|
385
|
+
@docstrings[locale_name] ||=
|
386
|
+
translate_docstring(locale || Registry.locale(locale_name))
|
381
387
|
end
|
382
388
|
|
383
389
|
# Attaches a docstring to a code object by parsing the comments attached to the statement
|
@@ -387,16 +393,11 @@ module YARD
|
|
387
393
|
# the comments attached to the code object to be parsed
|
388
394
|
# into a docstring and meta tags.
|
389
395
|
def docstring=(comments)
|
390
|
-
|
391
|
-
|
392
|
-
@
|
393
|
-
@docstring_extra_tags = Docstring === comments ? comments.tags : []
|
394
|
-
@docstring_extra.add_tag(*@docstring_extra_tags)
|
395
|
-
@docstring = Proxy.new(namespace, path)
|
396
|
+
@docstrings.clear
|
397
|
+
if Docstring === comments
|
398
|
+
@base_docstring = comments
|
396
399
|
else
|
397
|
-
@
|
398
|
-
@docstring_extra_tags = nil
|
399
|
-
@docstring = Docstring === comments ? comments : Docstring.new(comments, self)
|
400
|
+
@base_docstring = Docstring.new(comments, self)
|
400
401
|
end
|
401
402
|
end
|
402
403
|
|
@@ -405,7 +406,7 @@ module YARD
|
|
405
406
|
#
|
406
407
|
# @return [Symbol] the type of code object this represents
|
407
408
|
def type
|
408
|
-
self.class.name.split(
|
409
|
+
self.class.name.split('::').last.gsub(/Object$/, '').downcase.to_sym
|
409
410
|
end
|
410
411
|
|
411
412
|
# Represents the unique path of the object. The default implementation
|
@@ -426,6 +427,16 @@ module YARD
|
|
426
427
|
end
|
427
428
|
alias_method :to_s, :path
|
428
429
|
|
430
|
+
# @note
|
431
|
+
# Override this method if your object has a special title that does
|
432
|
+
# not match the {#path} attribute value. This title will be used
|
433
|
+
# when linking or displaying the object.
|
434
|
+
# @return [String] the display title for an object
|
435
|
+
# @see 0.8.4
|
436
|
+
def title
|
437
|
+
path
|
438
|
+
end
|
439
|
+
|
429
440
|
# @param [Base, String] other another code object (or object path)
|
430
441
|
# @return [String] the shortest relative path from this object to +other+
|
431
442
|
# @since 0.5.3
|
@@ -509,6 +520,14 @@ module YARD
|
|
509
520
|
# @see Docstring#has_tag?
|
510
521
|
def has_tag?(name); docstring.has_tag?(name) end
|
511
522
|
|
523
|
+
# Add tags to the {#docstring}
|
524
|
+
# @see Docstring#add_tag
|
525
|
+
# @since 0.8.4
|
526
|
+
def add_tag(*tags)
|
527
|
+
@docstrings.clear
|
528
|
+
@base_docstring.add_tag(*tags)
|
529
|
+
end
|
530
|
+
|
512
531
|
# @return whether or not this object is a RootObject
|
513
532
|
def root?; false end
|
514
533
|
|
@@ -532,7 +551,7 @@ module YARD
|
|
532
551
|
# @since 0.8.0
|
533
552
|
def copyable_attributes
|
534
553
|
vars = instance_variables.map {|ivar| ivar.to_s[1..-1] }
|
535
|
-
vars -= %w(
|
554
|
+
vars -= %w(base_docstring docstrings namespace name path)
|
536
555
|
vars
|
537
556
|
end
|
538
557
|
|
@@ -548,6 +567,17 @@ module YARD
|
|
548
567
|
indent = last ? last[/^([ \t]*)/, 1].length : 0
|
549
568
|
source.gsub(/^[ \t]{#{indent}}/, '')
|
550
569
|
end
|
570
|
+
|
571
|
+
def translate_docstring(locale)
|
572
|
+
@base_docstring.resolve_reference
|
573
|
+
return @base_docstring if locale.nil?
|
574
|
+
|
575
|
+
text = I18n::Text.new(@base_docstring)
|
576
|
+
localized_text = text.translate(locale)
|
577
|
+
docstring = Docstring.new(localized_text, self)
|
578
|
+
docstring.add_tag(*@base_docstring.tags)
|
579
|
+
docstring
|
580
|
+
end
|
551
581
|
end
|
552
582
|
end
|
553
583
|
end
|
data/lib/yard/docstring.rb
CHANGED
@@ -118,13 +118,23 @@ module YARD
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
+
def to_s
|
122
|
+
resolve_reference
|
123
|
+
super
|
124
|
+
end
|
125
|
+
|
121
126
|
# Replaces the docstring with new raw content. Called by {#all=}.
|
122
127
|
# @param [String] content the raw comments to be parsed
|
123
128
|
def replace(content, parse = true)
|
124
129
|
content = content.join("\n") if content.is_a?(Array)
|
125
130
|
@tags, @ref_tags = [], []
|
126
|
-
|
127
|
-
|
131
|
+
if parse
|
132
|
+
super(parse_comments(content))
|
133
|
+
else
|
134
|
+
@all = content
|
135
|
+
@unresolved_reference = nil
|
136
|
+
super(content)
|
137
|
+
end
|
128
138
|
end
|
129
139
|
alias all= replace
|
130
140
|
|
@@ -136,6 +146,7 @@ module YARD
|
|
136
146
|
# @return [Docstring] a new copied docstring
|
137
147
|
# @since 0.7.0
|
138
148
|
def dup
|
149
|
+
resolve_reference
|
139
150
|
obj = super
|
140
151
|
%w(all summary tags ref_tags).each do |name|
|
141
152
|
val = instance_variable_get("@#{name}")
|
@@ -155,6 +166,7 @@ module YARD
|
|
155
166
|
# Gets the first line of a docstring to the period or the first paragraph.
|
156
167
|
# @return [String] The first line or paragraph of the docstring; always ends with a period.
|
157
168
|
def summary
|
169
|
+
resolve_reference
|
158
170
|
return @summary if @summary
|
159
171
|
open_parens = ['{', '(', '[']
|
160
172
|
close_parens = ['}', ')', ']']
|
@@ -298,6 +310,26 @@ module YARD
|
|
298
310
|
|
299
311
|
# @endgroup
|
300
312
|
|
313
|
+
# Resolves unresolved other docstring reference if there is
|
314
|
+
# unresolved reference. Does nothing if there is no unresolved
|
315
|
+
# reference.
|
316
|
+
#
|
317
|
+
# Normally, you don't need to call this method
|
318
|
+
# explicitly. Resolving unresolved reference is done implicitly.
|
319
|
+
#
|
320
|
+
# @return [void]
|
321
|
+
def resolve_reference
|
322
|
+
loop do
|
323
|
+
return if @unresolved_reference.nil?
|
324
|
+
return if CodeObjects::Proxy === @unresolved_reference
|
325
|
+
|
326
|
+
reference, @unresolved_reference = @unresolved_reference, nil
|
327
|
+
resolved_tags = reference.docstring.tags
|
328
|
+
self.all = [reference.docstring.all, @all].join("\n")
|
329
|
+
add_tag(*resolved_tags)
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
301
333
|
private
|
302
334
|
|
303
335
|
# Maps valid reference tags
|
@@ -319,6 +351,8 @@ module YARD
|
|
319
351
|
def parse_comments(comments)
|
320
352
|
parser = self.class.parser
|
321
353
|
parser.parse(comments, object)
|
354
|
+
@all = parser.raw_text
|
355
|
+
@unresolved_reference = parser.reference
|
322
356
|
add_tag(*parser.tags)
|
323
357
|
parser.text
|
324
358
|
end
|
@@ -54,6 +54,11 @@ module YARD
|
|
54
54
|
# not attached to any object.
|
55
55
|
attr_accessor :object
|
56
56
|
|
57
|
+
# @return [CodeObjects::Base, nil] the object referenced by
|
58
|
+
# the docstring being parsed. May be nil if the docstring doesn't
|
59
|
+
# refer to any object.
|
60
|
+
attr_accessor :reference
|
61
|
+
|
57
62
|
# @return [Handlers::Base, nil] the handler parsing this
|
58
63
|
# docstring. May be nil if this docstring parser is not
|
59
64
|
# initialized through
|
@@ -79,6 +84,7 @@ module YARD
|
|
79
84
|
@directives = []
|
80
85
|
@library = library
|
81
86
|
@object = nil
|
87
|
+
@reference = nil
|
82
88
|
@handler = nil
|
83
89
|
@state = OpenStruct.new
|
84
90
|
end
|
@@ -106,8 +112,8 @@ module YARD
|
|
106
112
|
def parse(content, object = nil, handler = nil)
|
107
113
|
@object = object
|
108
114
|
@handler = handler
|
109
|
-
@raw_text = content
|
110
|
-
text = parse_content(
|
115
|
+
@reference, @raw_text = detect_reference(content)
|
116
|
+
text = parse_content(@raw_text)
|
111
117
|
# Remove trailing/leading whitespace / newlines
|
112
118
|
@text = text.gsub(/\A[\r\n\s]+|[\r\n\s]+\Z/, '')
|
113
119
|
call_directives_after_parse
|
@@ -232,6 +238,23 @@ module YARD
|
|
232
238
|
|
233
239
|
private
|
234
240
|
|
241
|
+
def namespace
|
242
|
+
if object
|
243
|
+
object.namespace
|
244
|
+
else
|
245
|
+
nil
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
def detect_reference(content)
|
250
|
+
if content =~ /\A\s*\(see (\S+)\s*\)(?:\s|$)/
|
251
|
+
path, extra = $1, $'
|
252
|
+
[CodeObjects::Proxy.new(namespace, path), extra]
|
253
|
+
else
|
254
|
+
[nil, content]
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
235
258
|
# @!group Parser Callback Methods
|
236
259
|
|
237
260
|
# Calls the {Directive#after_parse} callback on all the
|