yard 0.9.16 → 0.9.21
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.
- checksums.yaml +5 -5
- data/.dockerignore +2 -0
- data/.github/ISSUE_TEMPLATE.md +33 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +12 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.rubocop.yml +99 -0
- data/.travis.yml +52 -0
- data/.yardopts +0 -0
- data/.yardopts_guide +19 -0
- data/.yardopts_i18n +23 -0
- data/CHANGELOG.md +41 -1
- data/CODE_OF_CONDUCT.md +15 -0
- data/CONTRIBUTING.md +140 -0
- data/Dockerfile.samus +28 -0
- data/Gemfile +32 -0
- data/README.md +3 -1
- data/Rakefile +7 -17
- data/SECURITY.md +26 -0
- data/bin/yard +0 -0
- data/bin/yardoc +0 -0
- data/bin/yri +0 -0
- data/docs/GettingStarted.md +1 -1
- data/lib/yard/autoload.rb +5 -0
- data/lib/yard/cli/i18n.rb +1 -1
- data/lib/yard/cli/stats.rb +1 -1
- data/lib/yard/cli/yardoc.rb +4 -3
- data/lib/yard/code_objects/base.rb +14 -2
- data/lib/yard/code_objects/extra_file_object.rb +7 -4
- data/lib/yard/code_objects/proxy.rb +4 -0
- data/lib/yard/core_ext/module.rb +0 -9
- data/lib/yard/docstring.rb +10 -2
- data/lib/yard/handlers/c/handler_methods.rb +2 -1
- data/lib/yard/handlers/c/method_handler.rb +9 -0
- data/lib/yard/handlers/common/method_handler.rb +19 -0
- data/lib/yard/handlers/ruby/alias_handler.rb +5 -4
- data/lib/yard/handlers/ruby/attribute_handler.rb +1 -1
- data/lib/yard/handlers/ruby/constant_handler.rb +1 -5
- data/lib/yard/handlers/ruby/dsl_handler_methods.rb +6 -5
- data/lib/yard/handlers/ruby/method_handler.rb +3 -17
- data/lib/yard/handlers/ruby/mixin_handler.rb +13 -1
- data/lib/yard/parser/c/statement.rb +2 -0
- data/lib/yard/parser/ruby/ast_node.rb +11 -0
- data/lib/yard/parser/ruby/legacy/irb/slex.rb +276 -0
- data/lib/yard/parser/ruby/legacy/ruby_lex.rb +3 -12
- data/lib/yard/parser/ruby/legacy/statement.rb +2 -0
- data/lib/yard/parser/ruby/ruby_parser.rb +14 -2
- data/lib/yard/parser/source_parser.rb +1 -1
- data/lib/yard/registry_resolver.rb +47 -5
- data/lib/yard/registry_store.rb +6 -1
- data/lib/yard/server/commands/display_file_command.rb +1 -1
- data/lib/yard/server/commands/static_file_helpers.rb +0 -1
- data/lib/yard/templates/helpers/html_helper.rb +25 -4
- data/lib/yard/version.rb +6 -4
- data/po/ja.po +31108 -0
- data/samus.json +80 -0
- data/spec/cli/yardoc_spec.rb +48 -1
- data/spec/code_objects/base_spec.rb +25 -0
- data/spec/code_objects/extra_file_object_spec.rb +4 -3
- data/spec/code_objects/proxy_spec.rb +6 -0
- data/spec/core_ext/module_spec.rb +0 -6
- data/spec/docstring_parser_spec.rb +18 -0
- data/spec/docstring_spec.rb +9 -0
- data/spec/handlers/c/method_handler_spec.rb +2 -0
- data/spec/handlers/constant_handler_spec.rb +1 -1
- data/spec/handlers/dsl_handler_spec.rb +7 -0
- data/spec/handlers/examples/dsl_handler_001.rb.txt +2 -0
- data/spec/handlers/examples/extend_handler_001.rb.txt +4 -1
- data/spec/handlers/examples/mixin_handler_001.rb.txt +3 -0
- data/spec/handlers/extend_handler_spec.rb +4 -0
- data/spec/handlers/method_handler_spec.rb +24 -0
- data/spec/handlers/mixin_handler_spec.rb +4 -0
- data/spec/parser/c_parser_spec.rb +13 -0
- data/spec/parser/examples/file.c.txt +28 -0
- data/spec/registry_store_spec.rb +11 -0
- data/spec/templates/examples/module001.html +3 -3
- data/spec/templates/examples/module002.html +1 -1
- data/spec/templates/examples/module003.html +1 -1
- data/spec/templates/helpers/html_helper_spec.rb +34 -0
- data/spec/templates/helpers/method_helper_spec.rb +2 -2
- data/spec/templates/markup_processor_integrations/asciidoctor_spec.rb +60 -0
- data/spec/templates/markup_processor_integrations/integration_spec_helper.rb +46 -0
- data/spec/templates/markup_processor_integrations/rdoc_markdown_spec.rb +59 -0
- data/spec/templates/markup_processor_integrations/rdoc_spec.rb +39 -0
- data/spec/templates/markup_processor_integrations/redcarpet_spec.rb +59 -0
- data/spec/templates/markup_processor_integrations/redcloth_spec.rb +48 -0
- data/spec/templates/method_spec.rb +2 -2
- data/templates/default/docstring/setup.rb +1 -1
- data/templates/default/fulldoc/html/css/style.css +2 -2
- data/templates/default/fulldoc/html/frames.erb +1 -1
- data/templates/default/fulldoc/html/full_list.erb +1 -1
- data/templates/default/fulldoc/html/js/app.js +25 -3
- data/templates/default/fulldoc/html/js/jquery.js +2 -4
- data/templates/default/layout/html/headers.erb +1 -1
- data/templates/default/layout/html/script_setup.erb +1 -1
- data/templates/default/onefile/html/headers.erb +1 -1
- data/templates/default/onefile/html/setup.rb +1 -1
- data/templates/default/tags/html/tag.erb +1 -1
- data/templates/guide/layout/html/layout.erb +1 -1
- data/yard.gemspec +1 -20
- metadata +29 -22
- data/spec/examples.txt +0 -1874
data/Dockerfile.samus
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
FROM lsegal/samus:latest as samus
|
2
|
+
|
3
|
+
FROM ruby:2
|
4
|
+
ARG VERSION
|
5
|
+
ENV VERSION=${VERSION}
|
6
|
+
WORKDIR /github/lsegal/yard
|
7
|
+
ENTRYPOINT samus publish release-v${VERSION}.tar.gz
|
8
|
+
|
9
|
+
# Prepare credential config
|
10
|
+
RUN mkdir -p ~/.ssh
|
11
|
+
RUN echo "Host *" > ~/.ssh/config
|
12
|
+
RUN echo " StrictHostKeyChecking no" >> ~/.ssh/config
|
13
|
+
RUN chmod 400 ~/.ssh/config
|
14
|
+
COPY ./.samusprep/.samus /root/.samus
|
15
|
+
COPY ./.samusprep/.gitconfig /root/.gitconfig
|
16
|
+
|
17
|
+
# Setup Samus
|
18
|
+
ENV PATH=$PATH:/samus/bin
|
19
|
+
COPY --from=samus /samus /samus
|
20
|
+
|
21
|
+
# Install gems
|
22
|
+
ENV BUNDLE_PATH=/var/gems
|
23
|
+
COPY Gemfile /github/lsegal/yard
|
24
|
+
RUN bundle
|
25
|
+
|
26
|
+
# Run build
|
27
|
+
COPY . /github/lsegal/yard
|
28
|
+
RUN samus build --skip-restore ${VERSION}
|
data/Gemfile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
source 'https://rubygems.org'
|
3
|
+
|
4
|
+
group :development do
|
5
|
+
gem 'rspec'
|
6
|
+
gem 'rake'
|
7
|
+
gem 'rdoc'
|
8
|
+
gem 'json'
|
9
|
+
gem 'simplecov'
|
10
|
+
gem 'samus', '~> 3.0.8', :require => false
|
11
|
+
gem 'coveralls', :require => false
|
12
|
+
end
|
13
|
+
|
14
|
+
group :asciidoc do
|
15
|
+
gem 'asciidoctor'
|
16
|
+
end
|
17
|
+
|
18
|
+
group :markdown do
|
19
|
+
gem 'redcarpet', :platforms => [:ruby]
|
20
|
+
end
|
21
|
+
|
22
|
+
group :textile do
|
23
|
+
gem 'RedCloth', :platforms => [:ruby]
|
24
|
+
end
|
25
|
+
|
26
|
+
group :server do
|
27
|
+
gem 'rack'
|
28
|
+
end
|
29
|
+
|
30
|
+
group :i18n do
|
31
|
+
gem 'gettext'
|
32
|
+
end
|
data/README.md
CHANGED
@@ -45,7 +45,7 @@ following method documented with YARD formatting:
|
|
45
45
|
```ruby
|
46
46
|
# Reverses the contents of a String or IO object.
|
47
47
|
#
|
48
|
-
# @param [String, #read]
|
48
|
+
# @param contents [String, #read] the contents to reverse
|
49
49
|
# @return [String] the contents reversed lexically
|
50
50
|
def reverse(contents)
|
51
51
|
contents = contents.read if contents.respond_to? :read
|
@@ -226,6 +226,8 @@ The second most obvious is to generate docs via a Rake task. You can do this by
|
|
226
226
|
adding the following to your `Rakefile`:
|
227
227
|
|
228
228
|
```ruby
|
229
|
+
require 'yard'
|
230
|
+
|
229
231
|
YARD::Rake::YardocTask.new do |t|
|
230
232
|
t.files = ['lib/**/*.rb', OTHER_PATHS] # optional
|
231
233
|
t.options = ['--any', '--extra', '--opts'] # optional
|
data/Rakefile
CHANGED
@@ -2,23 +2,10 @@
|
|
2
2
|
require File.dirname(__FILE__) + '/lib/yard'
|
3
3
|
require File.dirname(__FILE__) + '/lib/yard/rubygems/specification'
|
4
4
|
require 'rbconfig'
|
5
|
+
require 'samus'
|
5
6
|
|
6
7
|
YARD::VERSION.replace(ENV['YARD_VERSION']) if ENV['YARD_VERSION']
|
7
8
|
|
8
|
-
desc "Publish gem"
|
9
|
-
task :publish do
|
10
|
-
ver = ENV['VERSION']
|
11
|
-
|
12
|
-
raise "missing VERSION=x.y.z" if ver.nil? || ver.empty?
|
13
|
-
if ver < YARD::VERSION
|
14
|
-
raise "invalid version `#{ver}' (must be >= `#{YARD::VERSION}')"
|
15
|
-
end
|
16
|
-
|
17
|
-
file = "release-v#{ver}.tar.gz"
|
18
|
-
cmd = "bundle exec samus"
|
19
|
-
sh "#{cmd} build #{ver} && #{cmd} publish #{file} && rm #{file}"
|
20
|
-
end
|
21
|
-
|
22
9
|
desc "Builds the gem"
|
23
10
|
task :gem do
|
24
11
|
sh "gem build yard.gemspec"
|
@@ -36,12 +23,15 @@ rescue LoadError
|
|
36
23
|
nil # noop
|
37
24
|
end
|
38
25
|
|
39
|
-
|
40
|
-
|
26
|
+
desc "Generate documentation for Yard, and fail if there are any warnings"
|
27
|
+
task :test_doc do
|
28
|
+
sh "ruby bin/yard --fail-on-warning #{"--no-progress" if ENV["CI"]}"
|
41
29
|
end
|
42
30
|
|
43
|
-
task :default => [:
|
31
|
+
task :default => [:spec, :test_doc]
|
44
32
|
|
45
33
|
YARD::Rake::YardocTask.new do |t|
|
46
34
|
t.options += ['--title', "YARD #{YARD::VERSION} Documentation"]
|
47
35
|
end
|
36
|
+
|
37
|
+
Samus::Rake::DockerReleaseTask.new
|
data/SECURITY.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
## Supported Versions
|
4
|
+
|
5
|
+
The following versions are supported with security patches for
|
6
|
+
any reported vulnerabilities in YARD or dependent software.
|
7
|
+
|
8
|
+
| Version | Supported |
|
9
|
+
| ------- | ------------------ |
|
10
|
+
| 0.9.x | :white_check_mark: |
|
11
|
+
| < 0.9 | :x: |
|
12
|
+
|
13
|
+
## Reporting a Vulnerability
|
14
|
+
|
15
|
+
If you've discovered a vulnerability in YARD source code, please email
|
16
|
+
lsegal@soen.ca with as much information as possible. You should typically
|
17
|
+
receive a response within 24-48 hours, though depending on scheduling
|
18
|
+
it may take up to a week to respond. If you do not get a response on
|
19
|
+
your initial email within a few days, please re-send your email or
|
20
|
+
reach out on other channels (such as yardoc@googlegroups.com) to
|
21
|
+
try to get a hold of a maintainer. Please do not include sensitive
|
22
|
+
material if you are reaching out through secondary channels unless
|
23
|
+
you first receive confirmation that it is okay.
|
24
|
+
|
25
|
+
Thank you for your help and cooperation in making YARD a stable and
|
26
|
+
safe piece of software.
|
data/bin/yard
CHANGED
File without changes
|
data/bin/yardoc
CHANGED
File without changes
|
data/bin/yri
CHANGED
File without changes
|
data/docs/GettingStarted.md
CHANGED
@@ -525,7 +525,7 @@ which is automatically detected by YARD if found in the root of your project
|
|
525
525
|
(any file starting with `README*`). You can specify extra files on the command
|
526
526
|
line (or in the `.yardopts` file) by listing them after the '-' separator:
|
527
527
|
|
528
|
-
yardoc lib/**/*.rb ext/**/*.c - LICENSE.txt
|
528
|
+
yardoc lib/**/*.rb ext/**/*.{c,rb} - LICENSE.txt
|
529
529
|
|
530
530
|
Note that the README will automatically be picked up, so you do not need to
|
531
531
|
specify it. If you don't want to modify the default file globs, you can ignore
|
data/lib/yard/autoload.rb
CHANGED
@@ -64,6 +64,11 @@ module YARD
|
|
64
64
|
# parsing phase. This allows YARD as well as any custom extension to
|
65
65
|
# analyze source and generate {CodeObjects} to be stored for later use.
|
66
66
|
module Handlers
|
67
|
+
# Shared logic between C and Ruby handlers.
|
68
|
+
module Common
|
69
|
+
autoload :MethodHandler, __p('handlers/common/method_handler')
|
70
|
+
end
|
71
|
+
|
67
72
|
# CRuby Handlers
|
68
73
|
# @since 0.8.0
|
69
74
|
module C
|
data/lib/yard/cli/i18n.rb
CHANGED
@@ -45,7 +45,7 @@ module YARD
|
|
45
45
|
opts.banner = "Usage: yard i18n [options] [source_files [- extra_files]]"
|
46
46
|
opts.top.list.clear
|
47
47
|
opts.separator "(if a list of source files is omitted, "
|
48
|
-
opts.separator " {lib,app}/**/*.rb ext/**/*.c is used.)"
|
48
|
+
opts.separator " {lib,app}/**/*.rb ext/**/*.{c,rb} is used.)"
|
49
49
|
opts.separator ""
|
50
50
|
opts.separator "Example: yard i18n -o yard.pot - FAQ LICENSE"
|
51
51
|
opts.separator " The above example outputs .pot file for files in"
|
data/lib/yard/cli/stats.rb
CHANGED
@@ -184,7 +184,7 @@ module YARD
|
|
184
184
|
opts = OptionParser.new
|
185
185
|
opts.banner = "Usage: yard stats [options] [source_files]"
|
186
186
|
|
187
|
-
opts.separator "(if a list of source files is omitted, lib/**/*.rb ext/**/*.c is used.)"
|
187
|
+
opts.separator "(if a list of source files is omitted, lib/**/*.rb ext/**/*.{c,rb} is used.)"
|
188
188
|
|
189
189
|
general_options(opts)
|
190
190
|
output_options(opts)
|
data/lib/yard/cli/yardoc.rb
CHANGED
@@ -294,8 +294,9 @@ module YARD
|
|
294
294
|
# Last minute modifications
|
295
295
|
self.files = Parser::SourceParser::DEFAULT_PATH_GLOB if files.empty?
|
296
296
|
files.delete_if {|x| x =~ /\A\s*\Z/ } # remove empty ones
|
297
|
-
readme = Dir.glob('README{,*[^~]}').
|
298
|
-
|
297
|
+
readme = Dir.glob('README{,*[^~]}').
|
298
|
+
sort_by {|r| [r.count('.'), r.index('.'), r] }.first
|
299
|
+
readme ||= Dir.glob(files.first).first if options.onefile && !files.empty?
|
299
300
|
options.readme ||= CodeObjects::ExtraFileObject.new(readme) if readme
|
300
301
|
options.files.unshift(options.readme).uniq! if options.readme
|
301
302
|
|
@@ -516,7 +517,7 @@ module YARD
|
|
516
517
|
opts.banner = "Usage: yard doc [options] [source_files [- extra_files]]"
|
517
518
|
|
518
519
|
opts.separator "(if a list of source files is omitted, "
|
519
|
-
opts.separator " {lib,app}/**/*.rb ext/**/*.c is used.)"
|
520
|
+
opts.separator " {lib,app}/**/*.rb ext/**/*.{c,rb} is used.)"
|
520
521
|
opts.separator ""
|
521
522
|
opts.separator "Example: yardoc -o documentation/ - FAQ LICENSE"
|
522
523
|
opts.separator " The above example outputs documentation for files in"
|
@@ -189,6 +189,10 @@ module YARD
|
|
189
189
|
def new(namespace, name, *args, &block)
|
190
190
|
raise ArgumentError, "invalid empty object name" if name.to_s.empty?
|
191
191
|
if namespace.is_a?(ConstantObject)
|
192
|
+
unless namespace.value =~ /\A#{NAMESPACEMATCH}\Z/
|
193
|
+
raise Parser::UndocumentableError, "constant mapping"
|
194
|
+
end
|
195
|
+
|
192
196
|
namespace = Proxy.new(namespace.namespace, namespace.value)
|
193
197
|
end
|
194
198
|
|
@@ -382,11 +386,14 @@ module YARD
|
|
382
386
|
# as a +String+ for the definition of the code object only (not the block)
|
383
387
|
def source=(statement)
|
384
388
|
if statement.respond_to?(:source)
|
385
|
-
self.signature = statement.first_line
|
386
389
|
@source = format_source(statement.source.strip)
|
387
390
|
else
|
388
391
|
@source = format_source(statement.to_s)
|
389
392
|
end
|
393
|
+
|
394
|
+
if statement.respond_to?(:signature)
|
395
|
+
self.signature = statement.signature
|
396
|
+
end
|
390
397
|
end
|
391
398
|
|
392
399
|
# The documentation string associated with the object
|
@@ -519,7 +526,12 @@ module YARD
|
|
519
526
|
if @namespace
|
520
527
|
reg_obj = Registry.at(path)
|
521
528
|
return if reg_obj && reg_obj.class == self.class
|
522
|
-
|
529
|
+
|
530
|
+
unless @namespace.is_a?(Proxy)
|
531
|
+
# remove prior objects from obj's children that match this one
|
532
|
+
@namespace.children.delete_if {|o| o.path == path }
|
533
|
+
@namespace.children << self
|
534
|
+
end
|
523
535
|
Registry.register(self)
|
524
536
|
end
|
525
537
|
end
|
@@ -113,14 +113,17 @@ module YARD::CodeObjects
|
|
113
113
|
end
|
114
114
|
contents
|
115
115
|
rescue ArgumentError => e
|
116
|
-
|
116
|
+
raise unless e.message =~ /invalid byte sequence/
|
117
|
+
|
118
|
+
if retried
|
117
119
|
# This should never happen.
|
118
120
|
log.warn "Could not read #{filename}, #{e.message}. You probably want to set `--charset`."
|
119
121
|
return ''
|
122
|
+
else
|
123
|
+
data.force_encoding('binary') if data.respond_to?(:force_encoding)
|
124
|
+
retried = true
|
125
|
+
retry
|
120
126
|
end
|
121
|
-
data.force_encoding('binary') if data.respond_to?(:force_encoding)
|
122
|
-
retried = true
|
123
|
-
retry
|
124
127
|
end
|
125
128
|
|
126
129
|
def translate(data)
|
@@ -58,6 +58,10 @@ module YARD
|
|
58
58
|
self.type = type
|
59
59
|
|
60
60
|
if @namespace.is_a?(ConstantObject)
|
61
|
+
unless @namespace.value =~ /\A#{NAMESPACEMATCH}\Z/
|
62
|
+
raise Parser::UndocumentableError, "constant mapping"
|
63
|
+
end
|
64
|
+
|
61
65
|
@origname = nil # forget these for a constant
|
62
66
|
@orignamespace = nil
|
63
67
|
@namespace = Proxy.new(@namespace.namespace, @namespace.value)
|
data/lib/yard/core_ext/module.rb
CHANGED
@@ -8,13 +8,4 @@ class Module
|
|
8
8
|
def class_name
|
9
9
|
name.split("::").last
|
10
10
|
end
|
11
|
-
|
12
|
-
# Returns the module namespace path minus the class/module name
|
13
|
-
#
|
14
|
-
# @example
|
15
|
-
# module A::B::C; namespace_name end # => "A::B"
|
16
|
-
# @return [String] the namespace minus the class/module name
|
17
|
-
def namespace_name
|
18
|
-
name.split("::")[0..-2].join("::")
|
19
|
-
end
|
20
11
|
end
|
data/lib/yard/docstring.rb
CHANGED
@@ -205,7 +205,7 @@ module YARD
|
|
205
205
|
# @since 0.7.0
|
206
206
|
# @todo Add Tags::Tag#to_raw and refactor
|
207
207
|
def to_raw
|
208
|
-
tag_data = tags.
|
208
|
+
tag_data = tags.map do |tag|
|
209
209
|
case tag
|
210
210
|
when Tags::OverloadTag
|
211
211
|
tag_text = "@#{tag.tag_name} #{tag.signature}\n"
|
@@ -271,7 +271,7 @@ module YARD
|
|
271
271
|
# @param [#to_s] name the tag name to return data for, or nil for all tags
|
272
272
|
# @return [Array<Tags::Tag>] the list of tags by the specified tag name
|
273
273
|
def tags(name = nil)
|
274
|
-
list = @tags + convert_ref_tags
|
274
|
+
list = stable_sort_by(@tags + convert_ref_tags, &:tag_name)
|
275
275
|
return list unless name
|
276
276
|
list.select {|tag| tag.tag_name.to_s == name.to_s }
|
277
277
|
end
|
@@ -374,5 +374,13 @@ module YARD
|
|
374
374
|
add_tag(*parser.tags)
|
375
375
|
parser.text
|
376
376
|
end
|
377
|
+
|
378
|
+
# A stable sort_by method.
|
379
|
+
#
|
380
|
+
# @param list [Enumerable] the list to sort.
|
381
|
+
# @return [Array] a stable sorted list.
|
382
|
+
def stable_sort_by(list)
|
383
|
+
list.each_with_index.sort_by {|tag, i| [yield(tag), i] }.map(&:first)
|
384
|
+
end
|
377
385
|
end
|
378
386
|
end
|
@@ -5,6 +5,7 @@ module YARD
|
|
5
5
|
module HandlerMethods
|
6
6
|
include Parser::C
|
7
7
|
include CodeObjects
|
8
|
+
include Common::MethodHandler
|
8
9
|
|
9
10
|
def handle_class(var_name, class_name, parent, in_module = nil)
|
10
11
|
parent = nil if parent == "0"
|
@@ -67,7 +68,7 @@ module YARD
|
|
67
68
|
register_visibility(obj, visibility)
|
68
69
|
find_method_body(obj, func_name)
|
69
70
|
obj.explicit = true
|
70
|
-
obj
|
71
|
+
add_predicate_return_tag(obj) if name =~ /\?$/
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
@@ -15,8 +15,13 @@ class YARD::Handlers::C::MethodHandler < YARD::Handlers::C::Base
|
|
15
15
|
\s*"([^"]+)",
|
16
16
|
\s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\(|\(\w+\))?(\w+)\)?,
|
17
17
|
\s*(-?\w+)\s*\)/xm
|
18
|
+
MATCH3 = /define_filetest_function\s*\(
|
19
|
+
\s*"([^"]+)",
|
20
|
+
\s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\(|\(\w+\))?(\w+)\)?,
|
21
|
+
\s*(-?\w+)\s*\)/xm
|
18
22
|
handles MATCH1
|
19
23
|
handles MATCH2
|
24
|
+
handles MATCH3
|
20
25
|
statement_class BodyStatement
|
21
26
|
|
22
27
|
process do
|
@@ -32,5 +37,9 @@ class YARD::Handlers::C::MethodHandler < YARD::Handlers::C::Base
|
|
32
37
|
statement.source.scan(MATCH2) do |name, func_name, _param_count|
|
33
38
|
handle_method("method", "rb_mKernel", name, func_name)
|
34
39
|
end
|
40
|
+
|
41
|
+
statement.source.scan(MATCH3) do |name, func_name, _param_count|
|
42
|
+
handle_method("singleton_method", "rb_cFile", name, func_name)
|
43
|
+
end
|
35
44
|
end
|
36
45
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module YARD::Handlers
|
4
|
+
module Common
|
5
|
+
# Shared functionality between Ruby and C method handlers.
|
6
|
+
module MethodHandler
|
7
|
+
# @param [MethodObject] obj
|
8
|
+
def add_predicate_return_tag(obj)
|
9
|
+
if obj.tag(:return) && (obj.tag(:return).types || []).empty?
|
10
|
+
obj.tag(:return).types = ['Boolean']
|
11
|
+
elsif obj.tag(:return).nil?
|
12
|
+
unless obj.tags(:overload).any? {|overload| overload.tag(:return) }
|
13
|
+
obj.add_tag(YARD::Tags::Tag.new(:return, "", "Boolean"))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -7,14 +7,15 @@ class YARD::Handlers::Ruby::AliasHandler < YARD::Handlers::Ruby::Base
|
|
7
7
|
process do
|
8
8
|
names = []
|
9
9
|
if statement.type == :alias
|
10
|
-
|
10
|
+
nodes = [:ident, :op, :kw, :const, :tstring_content, :string_content]
|
11
|
+
names = statement.map {|o| o.jump(*nodes).source }
|
11
12
|
elsif statement.call?
|
12
13
|
statement.parameters(false).each do |obj|
|
13
14
|
case obj.type
|
14
|
-
when :symbol_literal
|
15
|
+
when :symbol_literal
|
15
16
|
names << obj.jump(:ident, :op, :kw, :const).source
|
16
|
-
when :string_literal
|
17
|
-
names << obj.jump(:string_content).source
|
17
|
+
when :string_literal, :dyna_symbol
|
18
|
+
names << obj.jump(:string_content, :tstring_content).source
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
@@ -45,7 +45,7 @@ class YARD::Handlers::Ruby::AttributeHandler < YARD::Handlers::Ruby::Base
|
|
45
45
|
else
|
46
46
|
src = "def #{meth}"
|
47
47
|
full_src = "#{src}\n @#{name}\nend"
|
48
|
-
doc = "Returns the value of attribute #{name}"
|
48
|
+
doc = "Returns the value of attribute #{name}."
|
49
49
|
end
|
50
50
|
o.source ||= full_src
|
51
51
|
o.signature ||= src
|
@@ -20,11 +20,7 @@ class YARD::Handlers::Ruby::ConstantHandler < YARD::Handlers::Ruby::Base
|
|
20
20
|
|
21
21
|
def process_constant(statement)
|
22
22
|
name = statement[0].source
|
23
|
-
value =
|
24
|
-
statement[1].first.source.intern.inspect
|
25
|
-
else
|
26
|
-
statement[1].source
|
27
|
-
end
|
23
|
+
value = statement[1].source
|
28
24
|
obj = P(namespace, name)
|
29
25
|
if obj.is_a?(NamespaceObject) && obj.namespace == namespace
|
30
26
|
raise YARD::Parser::UndocumentableError, "constant for existing #{obj.type} #{obj}"
|