yard 0.9.16 → 0.9.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.yardopts +0 -0
- data/CHANGELOG.md +15 -1
- data/README.md +1 -1
- data/Rakefile +10 -15
- 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 +6 -1
- data/lib/yard/code_objects/extra_file_object.rb +7 -4
- 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/dsl_handler_methods.rb +3 -2
- data/lib/yard/handlers/ruby/method_handler.rb +3 -7
- data/lib/yard/parser/source_parser.rb +1 -1
- data/lib/yard/server/commands/display_file_command.rb +1 -1
- data/lib/yard/templates/helpers/html_helper.rb +5 -1
- data/lib/yard/version.rb +6 -4
- data/spec/cli/yardoc_spec.rb +48 -1
- data/spec/code_objects/base_spec.rb +10 -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/examples.txt +1883 -1874
- data/spec/handlers/c/method_handler_spec.rb +2 -0
- data/spec/parser/c_parser_spec.rb +13 -0
- data/spec/parser/examples/file.c.txt +28 -0
- data/spec/templates/helpers/html_helper_spec.rb +34 -0
- data/spec/templates/method_spec.rb +2 -2
- data/templates/default/fulldoc/html/js/app.js +11 -0
- data/templates/default/onefile/html/setup.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d7949e77d4f4c14b0bbc3991d7163ea80c5c2d9ab76a89050aaa0552ad0b8e83
|
|
4
|
+
data.tar.gz: b171a72e40b0eb28fa6271cf27f9c1683779c4f106568e892966110b8c07d451
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c2db6fc8d24102bcada8b33f8a8ced0a4e56ceede8e9d6a80a090e15a21009e0edb12af3204ed1b57238b9f1ab3bbabf9fc14ecf5ebad63c55380bad01938fc1
|
|
7
|
+
data.tar.gz: 9540bfe07bf2c9efc2c3318d6e24101888690bb38c76d561527839413b0ade25df36c4503d5cf86f69e48e1073de9b0fd02906c37883aba3fd8332b2087a9b9b
|
data/.yardopts
CHANGED
|
File without changes
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# master
|
|
2
2
|
|
|
3
|
+
# 0.9.19 - April 2nd, 2019
|
|
4
|
+
|
|
5
|
+
[0.9.19]: https://github.com/lsegal/yard/compare/v0.9.16...v0.9.19
|
|
6
|
+
|
|
7
|
+
- Fixed bug in browser back button (#1071, #1228)
|
|
8
|
+
- Fixed handling of ArgumentError in ExtraFileObject (#1198)
|
|
9
|
+
- Fixed double return tag displaying on boolean methods (#1226)
|
|
10
|
+
- Removed unused `Module#namespace_name` function (#1229)
|
|
11
|
+
- Fixed parsing order of README files. YARD will now prefer README over
|
|
12
|
+
README.md over README.x.md or README-x.md (and the like). READMEs will now
|
|
13
|
+
also be ordered by filename; the first README is still chosen unless
|
|
14
|
+
`--readme` is provided.
|
|
15
|
+
- Updated AsciiDoc markup support to use non-deprecated calls.
|
|
16
|
+
|
|
3
17
|
# [0.9.16] - August 11th, 2018
|
|
4
18
|
|
|
5
19
|
[0.9.16]: https://github.com/lsegal/yard/compare/v0.9.15...v0.9.16
|
|
@@ -193,7 +207,7 @@ contributions to this version.
|
|
|
193
207
|
to `default/fulldoc/html`, specifically the index or navigation lists.
|
|
194
208
|
- Added support for Ruby 2.1+ decorator style method declaration syntax. YARD now
|
|
195
209
|
supports:
|
|
196
|
-
|
|
210
|
+
private def foo(x, y) end
|
|
197
211
|
- Metadata headers in extra files can now be escaped from rendering by enclosing them
|
|
198
212
|
in HTML comment blocks (`<!--\n @metadata here... \n-->`). Ensure that the opening
|
|
199
213
|
comment tag is alone on the first line of the file to use this functionality.
|
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
|
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,20 @@ rescue LoadError
|
|
|
36
23
|
nil # noop
|
|
37
24
|
end
|
|
38
25
|
|
|
26
|
+
desc "Check code style with Rubocop"
|
|
39
27
|
task :rubocop do
|
|
40
28
|
sh "rubocop"
|
|
41
29
|
end
|
|
42
30
|
|
|
43
|
-
|
|
31
|
+
desc "Generate documentation for Yard, and fail if there are any warnings"
|
|
32
|
+
task :test_doc do
|
|
33
|
+
sh "ruby bin/yard --fail-on-warning #{"--no-progress" if ENV["CI"]}"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
task :default => [:rubocop, :spec, :test_doc]
|
|
44
37
|
|
|
45
38
|
YARD::Rake::YardocTask.new do |t|
|
|
46
39
|
t.options += ['--title', "YARD #{YARD::VERSION} Documentation"]
|
|
47
40
|
end
|
|
41
|
+
|
|
42
|
+
Samus::Rake::DockerReleaseTask.new
|
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"
|
|
@@ -519,7 +519,12 @@ module YARD
|
|
|
519
519
|
if @namespace
|
|
520
520
|
reg_obj = Registry.at(path)
|
|
521
521
|
return if reg_obj && reg_obj.class == self.class
|
|
522
|
-
|
|
522
|
+
|
|
523
|
+
unless @namespace.is_a?(Proxy)
|
|
524
|
+
# remove prior objects from obj's children that match this one
|
|
525
|
+
@namespace.children.delete_if {|o| o.path == path }
|
|
526
|
+
@namespace.children << self
|
|
527
|
+
end
|
|
523
528
|
Registry.register(self)
|
|
524
529
|
end
|
|
525
530
|
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)
|
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,8 +7,9 @@ module YARD
|
|
|
7
7
|
include Parser
|
|
8
8
|
|
|
9
9
|
IGNORE_METHODS = Hash[*%w(alias alias_method autoload attr attr_accessor
|
|
10
|
-
attr_reader attr_writer extend include public private
|
|
11
|
-
private_constant
|
|
10
|
+
attr_reader attr_writer extend include module_function public private
|
|
11
|
+
protected private_constant private_class_method public_class_method).
|
|
12
|
+
map {|n| [n, true] }.flatten]
|
|
12
13
|
|
|
13
14
|
def handle_comments
|
|
14
15
|
return if IGNORE_METHODS[caller_method]
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
# Handles a method definition
|
|
3
3
|
class YARD::Handlers::Ruby::MethodHandler < YARD::Handlers::Ruby::Base
|
|
4
|
+
include YARD::Handlers::Common::MethodHandler
|
|
5
|
+
|
|
4
6
|
handles :def, :defs
|
|
5
7
|
|
|
6
8
|
process do
|
|
@@ -39,13 +41,7 @@ class YARD::Handlers::Ruby::MethodHandler < YARD::Handlers::Ruby::Base
|
|
|
39
41
|
extended method_added method_removed method_undefined).include?(meth)
|
|
40
42
|
obj.add_tag(YARD::Tags::Tag.new(:private, nil))
|
|
41
43
|
elsif meth.to_s =~ /\?$/
|
|
42
|
-
|
|
43
|
-
obj.tag(:return).types = ['Boolean']
|
|
44
|
-
elsif obj.tag(:return).nil?
|
|
45
|
-
unless obj.tags(:overload).any? {|overload| overload.tag(:return) }
|
|
46
|
-
obj.add_tag(YARD::Tags::Tag.new(:return, "", "Boolean"))
|
|
47
|
-
end
|
|
48
|
-
end
|
|
44
|
+
add_predicate_return_tag(obj)
|
|
49
45
|
end
|
|
50
46
|
|
|
51
47
|
if obj.has_tag?(:option)
|
|
@@ -68,7 +68,7 @@ module YARD
|
|
|
68
68
|
|
|
69
69
|
# The default glob of files to be parsed.
|
|
70
70
|
# @since 0.9.0
|
|
71
|
-
DEFAULT_PATH_GLOB = ["{lib,app}/**/*.rb", "ext/**/*.{c,cc,cxx,cpp}"]
|
|
71
|
+
DEFAULT_PATH_GLOB = ["{lib,app}/**/*.rb", "ext/**/*.{c,cc,cxx,cpp,rb}"]
|
|
72
72
|
|
|
73
73
|
# Byte order marks for various encodings
|
|
74
74
|
# @since 0.7.0
|
|
@@ -11,7 +11,7 @@ module YARD
|
|
|
11
11
|
def run
|
|
12
12
|
filename = File.cleanpath(File.join(library.source_path, path))
|
|
13
13
|
raise NotFoundError unless File.file?(filename)
|
|
14
|
-
if filename =~ /\.(jpe?g|gif|png|bmp)$/i
|
|
14
|
+
if filename =~ /\.(jpe?g|gif|png|bmp|svg)$/i
|
|
15
15
|
headers['Content-Type'] = StaticFileCommand::DefaultMimeTypes[$1.downcase] || 'text/html'
|
|
16
16
|
render File.read_binary(filename)
|
|
17
17
|
else
|
|
@@ -11,6 +11,9 @@ module YARD
|
|
|
11
11
|
# @private
|
|
12
12
|
URLMATCH = /[^\w\s~!\*'\(\):;@&=\$,\[\]<>-]/
|
|
13
13
|
|
|
14
|
+
# @private
|
|
15
|
+
ASCIIDOC_ATTRIBUTES = {"env" => "yard", "env-yard" => ""}.freeze
|
|
16
|
+
|
|
14
17
|
# @group Escaping Template Data
|
|
15
18
|
|
|
16
19
|
# Escapes HTML entities
|
|
@@ -97,7 +100,8 @@ module YARD
|
|
|
97
100
|
# @param [String] text input Asciidoc text
|
|
98
101
|
# @return [String] output HTML
|
|
99
102
|
def html_markup_asciidoc(text)
|
|
100
|
-
|
|
103
|
+
options = {:attributes => ASCIIDOC_ATTRIBUTES}
|
|
104
|
+
markup_class(:asciidoc).convert(text, options)
|
|
101
105
|
end
|
|
102
106
|
|
|
103
107
|
# Converts Textile to HTML
|
data/lib/yard/version.rb
CHANGED
data/spec/cli/yardoc_spec.rb
CHANGED
|
@@ -184,9 +184,22 @@ RSpec.describe YARD::CLI::Yardoc do
|
|
|
184
184
|
@yardoc.run(arg)
|
|
185
185
|
end
|
|
186
186
|
|
|
187
|
+
# This example relies on processing Yard's own documentation, and with
|
|
188
|
+
# --fail-on-warning option on, will raise a SystemExit error if building
|
|
189
|
+
# that documentation produces any one warning.
|
|
190
|
+
#
|
|
191
|
+
# Unless handled, it will cause immediate and abnormal process exit,
|
|
192
|
+
# without running remaining tests, and with non-successful exit status.
|
|
193
|
+
#
|
|
194
|
+
# While suppressing exceptions is generally a bad practice and against this
|
|
195
|
+
# project's style guide, here it is well advocated,
|
|
196
|
+
# hence Lint/HandleExceptions cop is disabled.
|
|
187
197
|
should_accept('--fail-on-warning') do |arg|
|
|
188
198
|
expect(YARD).to receive(:parse)
|
|
189
|
-
|
|
199
|
+
begin
|
|
200
|
+
@yardoc.run(arg)
|
|
201
|
+
rescue SystemExit # rubocop:disable Lint/HandleExceptions
|
|
202
|
+
end
|
|
190
203
|
end
|
|
191
204
|
end
|
|
192
205
|
|
|
@@ -634,6 +647,12 @@ RSpec.describe YARD::CLI::Yardoc do
|
|
|
634
647
|
expect(@yardoc.options.readme).to eq CodeObjects::ExtraFileObject.new('lib/foo.rb', '')
|
|
635
648
|
end
|
|
636
649
|
|
|
650
|
+
it "uses no readme if files is empty and no readme is specified when using --one-file" do
|
|
651
|
+
expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return []
|
|
652
|
+
@yardoc.parse_arguments '--one-file', ''
|
|
653
|
+
expect(@yardoc.options.readme).to be_nil
|
|
654
|
+
end
|
|
655
|
+
|
|
637
656
|
it "uses readme it exists when using --one-file" do
|
|
638
657
|
expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return ['README']
|
|
639
658
|
expect(File).to receive(:read).with('README').and_return('')
|
|
@@ -641,6 +660,34 @@ RSpec.describe YARD::CLI::Yardoc do
|
|
|
641
660
|
expect(@yardoc.options.readme).to eq CodeObjects::ExtraFileObject.new('README', '')
|
|
642
661
|
end
|
|
643
662
|
|
|
663
|
+
it "selects readme with no file extension over readme with file extension" do
|
|
664
|
+
expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return ['README.md', 'README-DEV', 'README']
|
|
665
|
+
expect(File).to receive(:read).with('README').and_return('')
|
|
666
|
+
@yardoc.parse_arguments
|
|
667
|
+
expect(@yardoc.options.readme).to eq CodeObjects::ExtraFileObject.new('README', '')
|
|
668
|
+
end
|
|
669
|
+
|
|
670
|
+
it "selects readme with no suffix over readme with hyphenated suffix" do
|
|
671
|
+
expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return ['README-fr.md', 'README.long-extension', 'README-de.md']
|
|
672
|
+
expect(File).to receive(:read).with('README.long-extension').and_return('')
|
|
673
|
+
@yardoc.parse_arguments
|
|
674
|
+
expect(@yardoc.options.readme).to eq CodeObjects::ExtraFileObject.new('README.long-extension', '')
|
|
675
|
+
end
|
|
676
|
+
|
|
677
|
+
it "selects readme with no suffix over readme with dotted suffix" do
|
|
678
|
+
expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return ['README.fr.md', 'README.md', 'README.de.md']
|
|
679
|
+
expect(File).to receive(:read).with('README.md').and_return('')
|
|
680
|
+
@yardoc.parse_arguments
|
|
681
|
+
expect(@yardoc.options.readme).to eq CodeObjects::ExtraFileObject.new('README.md', '')
|
|
682
|
+
end
|
|
683
|
+
|
|
684
|
+
it "selects first readme from lexically sorted list" do
|
|
685
|
+
expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return ['README-fr.md', 'README-de.md']
|
|
686
|
+
expect(File).to receive(:read).with('README-de.md').and_return('')
|
|
687
|
+
@yardoc.parse_arguments
|
|
688
|
+
expect(@yardoc.options.readme).to eq CodeObjects::ExtraFileObject.new('README-de.md', '')
|
|
689
|
+
end
|
|
690
|
+
|
|
644
691
|
it "does not allow US-ASCII charset when using --one-file" do
|
|
645
692
|
ienc = Encoding.default_internal
|
|
646
693
|
eenc = Encoding.default_external
|
|
@@ -121,6 +121,16 @@ RSpec.describe YARD::CodeObjects::Base do
|
|
|
121
121
|
expect(obj.children).to include(obj2)
|
|
122
122
|
end
|
|
123
123
|
|
|
124
|
+
# @bug gh-1209
|
|
125
|
+
it "removes prior defined objects at the same path from namespace's children" do
|
|
126
|
+
Registry.clear
|
|
127
|
+
obj = ModuleObject.new(:root, :YARD)
|
|
128
|
+
ConstantObject.new(obj, :Testing)
|
|
129
|
+
ClassObject.new(obj, :Testing)
|
|
130
|
+
expect(obj.children.map {|o| o.type.to_sym }).to eq [:class]
|
|
131
|
+
expect(Registry.at('YARD::Testing').type).to eq :class
|
|
132
|
+
end
|
|
133
|
+
|
|
124
134
|
it "properly re-indents source starting from 0 indentation" do
|
|
125
135
|
obj = CodeObjects::Base.new(nil, :test)
|
|
126
136
|
obj.source = <<-eof
|
|
@@ -6,10 +6,4 @@ RSpec.describe Module do
|
|
|
6
6
|
expect(YARD::CodeObjects::Base.class_name).to eq "Base"
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
|
-
|
|
10
|
-
describe "#namespace" do
|
|
11
|
-
it "returns everything before the class name" do
|
|
12
|
-
expect(YARD::CodeObjects::Base.namespace_name).to eq "YARD::CodeObjects"
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
9
|
end
|
|
@@ -241,6 +241,24 @@ eof
|
|
|
241
241
|
alias bar foo
|
|
242
242
|
eof
|
|
243
243
|
end
|
|
244
|
+
|
|
245
|
+
it "does not warn on matching param with inline method modifier" do
|
|
246
|
+
expect(log).to_not receive(:warn)
|
|
247
|
+
YARD.parse_string <<-eof
|
|
248
|
+
# @param [Numeric] a
|
|
249
|
+
# @return [Numeric]
|
|
250
|
+
private_class_method def self.foo(a); a + 1; end
|
|
251
|
+
eof
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
it "warns on mismatching param with inline method modifier" do
|
|
255
|
+
expect(log).to receive(:warn).with(/@param tag has unknown parameter name: notaparam/)
|
|
256
|
+
YARD.parse_string <<-eof
|
|
257
|
+
# @param [Numeric] notaparam
|
|
258
|
+
# @return [Numeric]
|
|
259
|
+
private_class_method def self.foo(a); a + 1; end
|
|
260
|
+
eof
|
|
261
|
+
end
|
|
244
262
|
end
|
|
245
263
|
|
|
246
264
|
describe "after_parse (see)" do
|
data/spec/docstring_spec.rb
CHANGED
|
@@ -296,6 +296,15 @@ RSpec.describe YARD::Docstring do
|
|
|
296
296
|
expect(doc.to_raw).to eq doc.all
|
|
297
297
|
end
|
|
298
298
|
|
|
299
|
+
it "is stable sorting tags" do
|
|
300
|
+
expected = Docstring.new("123\n@param x\n@param y\n@version A")
|
|
301
|
+
doc = Docstring.new("123")
|
|
302
|
+
doc.add_tag(Tags::Tag.new('version', 'A'))
|
|
303
|
+
doc.add_tag(Tags::Tag.new('param', 'x'))
|
|
304
|
+
doc.add_tag(Tags::Tag.new('param', 'y'))
|
|
305
|
+
expect(doc.to_raw).to eq expected.all
|
|
306
|
+
end
|
|
307
|
+
|
|
299
308
|
# @bug gh-563
|
|
300
309
|
it "handles full @option tags" do
|
|
301
310
|
doc = Docstring.new("@option foo [String] bar (nil) baz")
|