yard 0.9.26 → 0.9.37

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +104 -8
  3. data/LEGAL +29 -1
  4. data/LICENSE +1 -1
  5. data/README.md +9 -2
  6. data/docs/Tags.md +1 -1
  7. data/docs/WhatsNew.md +2 -2
  8. data/lib/yard/autoload.rb +3 -1
  9. data/lib/yard/cli/command.rb +1 -1
  10. data/lib/yard/cli/stats.rb +4 -1
  11. data/lib/yard/cli/yardoc.rb +5 -3
  12. data/lib/yard/code_objects/base.rb +5 -1
  13. data/lib/yard/code_objects/macro_object.rb +0 -1
  14. data/lib/yard/config.rb +5 -1
  15. data/lib/yard/docstring_parser.rb +1 -2
  16. data/lib/yard/handlers/processor.rb +0 -1
  17. data/lib/yard/handlers/ruby/attribute_handler.rb +1 -1
  18. data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +1 -1
  19. data/lib/yard/handlers/ruby/method_handler.rb +2 -2
  20. data/lib/yard/handlers/ruby/mixin_handler.rb +15 -6
  21. data/lib/yard/handlers/ruby/module_function_handler.rb +15 -3
  22. data/lib/yard/handlers/ruby/visibility_handler.rb +13 -1
  23. data/lib/yard/i18n/locale.rb +1 -1
  24. data/lib/yard/i18n/message.rb +2 -2
  25. data/lib/yard/i18n/messages.rb +1 -1
  26. data/lib/yard/i18n/pot_generator.rb +1 -1
  27. data/lib/yard/logging.rb +116 -61
  28. data/lib/yard/open_struct.rb +67 -0
  29. data/lib/yard/options.rb +1 -1
  30. data/lib/yard/parser/ruby/ast_node.rb +9 -2
  31. data/lib/yard/parser/ruby/legacy/ruby_lex.rb +19 -4
  32. data/lib/yard/parser/ruby/ruby_parser.rb +9 -3
  33. data/lib/yard/parser/source_parser.rb +4 -5
  34. data/lib/yard/registry_resolver.rb +2 -1
  35. data/lib/yard/server/commands/base.rb +1 -1
  36. data/lib/yard/server/commands/library_command.rb +9 -9
  37. data/lib/yard/server/commands/static_file_helpers.rb +1 -2
  38. data/lib/yard/server/http_utils.rb +512 -0
  39. data/lib/yard/server/rack_adapter.rb +13 -5
  40. data/lib/yard/tags/default_factory.rb +1 -0
  41. data/lib/yard/tags/directives.rb +10 -2
  42. data/lib/yard/tags/tag.rb +3 -2
  43. data/lib/yard/tags/types_explainer.rb +1 -1
  44. data/lib/yard/templates/engine.rb +0 -1
  45. data/lib/yard/templates/helpers/html_helper.rb +5 -2
  46. data/lib/yard/templates/helpers/markup_helper.rb +2 -1
  47. data/lib/yard/templates/helpers/method_helper.rb +3 -1
  48. data/lib/yard/templates/template.rb +3 -1
  49. data/lib/yard/templates/template_options.rb +0 -1
  50. data/lib/yard/version.rb +1 -1
  51. data/lib/yard.rb +6 -0
  52. data/po/ja.po +19 -19
  53. data/templates/default/fulldoc/html/css/full_list.css +3 -3
  54. data/templates/default/fulldoc/html/css/style.css +6 -0
  55. data/templates/default/fulldoc/html/frames.erb +9 -4
  56. data/templates/default/fulldoc/html/full_list.erb +5 -2
  57. data/templates/default/fulldoc/html/js/app.js +294 -264
  58. data/templates/default/fulldoc/html/js/full_list.js +30 -4
  59. data/templates/default/fulldoc/html/setup.rb +10 -2
  60. data/templates/default/layout/html/footer.erb +1 -1
  61. data/templates/default/onefile/html/headers.erb +2 -0
  62. data/templates/default/tags/html/example.erb +2 -2
  63. data/templates/default/tags/html/option.erb +1 -1
  64. metadata +5 -41
  65. data/.dockerignore +0 -2
  66. data/.gitattributes +0 -4
  67. data/.github/FUNDING.yml +0 -3
  68. data/.github/ISSUE_TEMPLATE.md +0 -33
  69. data/.github/PULL_REQUEST_TEMPLATE.md +0 -12
  70. data/.github/workflows/ci.yml +0 -42
  71. data/.github/workflows/gem.yml +0 -27
  72. data/.gitignore +0 -14
  73. data/.rspec +0 -2
  74. data/.rubocop.yml +0 -112
  75. data/.travis.yml +0 -49
  76. data/CODE_OF_CONDUCT.md +0 -15
  77. data/CONTRIBUTING.md +0 -140
  78. data/Dockerfile.samus +0 -28
  79. data/Gemfile +0 -33
  80. data/Rakefile +0 -39
  81. data/SECURITY.md +0 -26
  82. data/benchmarks/builtins_vs_eval.rb +0 -24
  83. data/benchmarks/concat_vs_join.rb +0 -13
  84. data/benchmarks/erb_vs_erubis.rb +0 -54
  85. data/benchmarks/format_args.rb +0 -47
  86. data/benchmarks/generation.rb +0 -38
  87. data/benchmarks/marshal_vs_dbm.rb +0 -64
  88. data/benchmarks/parsing.rb +0 -46
  89. data/benchmarks/pathname_vs_string.rb +0 -51
  90. data/benchmarks/rdoc_vs_yardoc.rb +0 -11
  91. data/benchmarks/registry_store_types.rb +0 -49
  92. data/benchmarks/ri_vs_yri.rb +0 -19
  93. data/benchmarks/ripper_parser.rb +0 -13
  94. data/benchmarks/splat_vs_flatten.rb +0 -13
  95. data/benchmarks/template_erb.rb +0 -23
  96. data/benchmarks/template_format.rb +0 -7
  97. data/benchmarks/template_profile.rb +0 -18
  98. data/benchmarks/yri_cache.rb +0 -20
  99. data/samus.json +0 -49
  100. data/tasks/update_error_map.rake +0 -53
  101. data/yard.gemspec +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b26148831eae874a1a8f704e19bb86e0f3924ba3482337edfe70d1a1c320a00b
4
- data.tar.gz: 60d089381ca93b8b7b732317eafe7da0f56fbd727effaca34a52d1040a217e09
3
+ metadata.gz: 0774d1772b133075737690acbc502767f6fef28d3765a14929074259248f3981
4
+ data.tar.gz: '068103b3caf24a6c6071a6c9b0f52bd58641fd0c03e22220fb2d1b09a104385c'
5
5
  SHA512:
6
- metadata.gz: 6e298247ed74a5db2d7f561feaaa6d84a19914c91bc4b9b7e701fa1e33efd7d07e9284eab6c6aad03b61e89268bb105e01a5dcd88beccaf212507cee794d161d
7
- data.tar.gz: 9207539dc74b76b2f02a384ed97bafafc13a2b42dab3cb5130d927bc3a6c53976e802856d2be6c6f566f7811ca33eaa5c2c52a1357df8d950402fa2d949d7005
6
+ metadata.gz: 64a799b2f45d7ad6aad8684c805344f242c8e2f8ef1c60a43094bc237bccd449ee1c93c60c0f54a36f05a79e5b652636d7170dce85941b1f74a4bcc173c92c21
7
+ data.tar.gz: b19ba690f1a244b0c7df5c1524f77355323fa9164e9496c609f258b3d0691c0a3d807cd985f20f335884ba1d8e97193149d4a7b9e1eebd9ed3a43431492a1ce3
data/CHANGELOG.md CHANGED
@@ -1,13 +1,109 @@
1
1
  # main
2
2
 
3
- # 0.9.26 - December 26th, 2020
3
+ # [0.9.37] - September 4th, 2024
4
+
5
+ [0.9.37]: https://github.com/lsegal/yard/compare/v0.9.36...v0.9.37
6
+
7
+ - Fix JavaScript errors in `--one-file` template (#1426)
8
+ - Fix heredoc parsing and add support for squiggly heredocs (#1315, #1495)
9
+ - Accessibility improvements to the default template (#1501)
10
+ - Improved YARD documentation (#1410, #1512, #1516, #1544)
11
+ - Fix error when parsing `@option` tags (#1515)
12
+ - Fix issue parsing UTF-8 filenames (#1517)
13
+ - Replace OpenStruct with optimized YARD::OpenStruct to avoid ostruct performance warnings (#1545)
14
+ - Add support for `private attr_*` syntax (#1541)
15
+ - Remove logger dependency (#1546)
16
+
17
+ # [0.9.36] - February 29th, 2024
18
+
19
+ [0.9.36]: https://github.com/lsegal/yard/compare/v0.9.35...v0.9.36
20
+
21
+ - Further XSS fixes for generated frameset pages (#1538)
22
+ - Improve tests for Ruby 3.3 compatibility (#1519, #1531)
23
+ - Documentation improvements (#1524)
24
+
25
+ # [0.9.35] - February 28th, 2024
26
+
27
+ [0.9.35]: https://github.com/lsegal/yard/compare/v0.9.34...v0.9.35
28
+
29
+ - Fix possible XSS on generated YARD frameset pages (thanks to @RedYetiDev for finding and patching) (2069e2b).
30
+ - Fix errors when using `@option` on non-method objects (#1508)
31
+ - Support Ruby 3.3 changes in Ripper parser (#1510)
32
+
33
+ # [0.9.34] - April 12nd, 2023
34
+
35
+ [0.9.34]: https://github.com/lsegal/yard/compare/v0.9.33...v0.9.34
36
+
37
+ - Add changelog to yard.gemspec
38
+ - Fix fork behavior in `yard server --fork`
39
+
40
+ # [0.9.33] - April 11st, 2023
41
+
42
+ [0.9.33]: https://github.com/lsegal/yard/compare/v0.9.32...v0.9.33
43
+
44
+ - Ensure .yardopts is present in gem package (internal YARD documentation change)
45
+
46
+ # 0.9.32 - April 9th, 2023
47
+
48
+ [0.9.32]: https://github.com/lsegal/yard/compare/v0.9.31...v0.9.32
49
+
50
+ - Fix issue with custom Rack::Request attributes in `yard server`
51
+
52
+ # [0.9.31] - April 9th, 2023
53
+
54
+ [0.9.31]: https://github.com/lsegal/yard/compare/v0.9.30...v0.9.31
55
+
56
+ - Remove dependency on webrick in YARD::Server::Commands::StaticFileHelpers
57
+
58
+ # [0.9.30] - April 9th, 2023
59
+
60
+ [0.9.30]: https://github.com/lsegal/yard/compare/v0.9.29...v0.9.30
61
+
62
+ - Hot release fix to correct issue with gem packaging missing templates (#1490)
63
+
64
+ # [0.9.29] - April 8th, 2023
65
+
66
+ [0.9.29]: https://github.com/lsegal/yard/compare/v0.9.28...v0.9.29
67
+
68
+ - Enable table support for CommonMarker (#1443)
69
+ - Parser performance improvements (#1452, #1453, #1454, #1455)
70
+ - Fix autoload of RipperParser (#1460)
71
+ - Remove dependency on webrick for better Ruby 3.1+ support
72
+ - Improvements for mixin resolution (#1467, #1468)
73
+
74
+ # [0.9.28] - June 1st, 2022
75
+
76
+ [0.9.28]: https://github.com/lsegal/yard/compare/v0.9.27...v0.9.28
77
+
78
+ - Safe load config YAML files (#1385)
79
+ - Handle empty string constants (#1415)
80
+ - Pre-emptively support removal of `Object#taint` in Ruby 3.2 (#1419)
81
+ - Fix Ruby 3.1 forward args Ripper change (#1431)
82
+
83
+ # [0.9.27] - November 29th, 2021
84
+
85
+ [0.9.27]: https://github.com/lsegal/yard/compare/v0.9.26...v0.9.27
86
+
87
+ - Add support for Ruby 3.0 endless method definitions. (#1376, #1381)
88
+ - Add existence check for README file (#1367)
89
+ - Support module_function decorator (#1365)
90
+ - Add CommonMarker markup support (`-m commonmarker`) (#1157, #1388)
91
+ - Fix nested array parsing (#1389)
92
+ - Add WEBrick as a runtime dependency for Ruby 3.0 support (#1400)
93
+ - Support `fail_on_warning` option in `yard stats` command (#1392)
94
+ - Better integration with Sorbet (#1401)
95
+ - Handle include mixins on complex paths (#1386)
96
+ - Fix `@!scope` maintaining state in lone comment blocks (#1411)
97
+ - Remove support for Travis CI
98
+
99
+ # [0.9.26] - December 26th, 2020
4
100
 
5
101
  [0.9.26]: https://github.com/lsegal/yard/compare/v0.9.25...v0.9.26
6
102
 
7
103
  - Add support for Ruby 3.0 and fix tests
8
104
  - Fix support for `frozen_string_literal: false` magic comments (#1363)
9
105
 
10
- # 0.9.25 - May 3rd, 2020
106
+ # [0.9.25] - May 3rd, 2020
11
107
 
12
108
  [0.9.25]: https://github.com/lsegal/yard/compare/v0.9.24...v0.9.25
13
109
 
@@ -22,7 +118,7 @@
22
118
  - Omit spec files in gem package (#1307)
23
119
  - README updates (#1322)
24
120
 
25
- # 0.9.24 - January 8th, 2020
121
+ # [0.9.24] - January 8th, 2020
26
122
 
27
123
  [0.9.24]: https://github.com/lsegal/yard/compare/v0.9.23...v0.9.24
28
124
 
@@ -30,20 +126,20 @@
30
126
  cache is changed.
31
127
  - Fix issue where Registry fails to resolve first-time lookups on instance methods.
32
128
 
33
- # 0.9.23 - January 5th, 2020
129
+ # [0.9.23] - January 5th, 2020
34
130
 
35
131
  [0.9.23]: https://github.com/lsegal/yard/compare/v0.9.22...v0.9.23
36
132
 
37
133
  - Fix issues with double encoded code blocks when highlighted from an extra
38
134
  file.
39
135
 
40
- # 0.9.22 - December 31st, 2019
136
+ # [0.9.22] - December 31st, 2019
41
137
 
42
138
  [0.9.22]: https://github.com/lsegal/yard/compare/v0.9.21...v0.9.22
43
139
 
44
140
  - Revert jquery update in last release since it requires more changes. (#1298)
45
141
 
46
- # 0.9.21 - December 31st, 2019
142
+ # [0.9.21] - December 31st, 2019
47
143
 
48
144
  [0.9.21]: https://github.com/lsegal/yard/compare/v0.9.20...v0.9.21
49
145
 
@@ -59,7 +155,7 @@
59
155
  - Update jquery to 3.4.1 (#1294)
60
156
  - Test fixes (#1244)
61
157
 
62
- # 0.9.20 - June 27th, 2019
158
+ # [0.9.20] - June 27th, 2019
63
159
 
64
160
  [0.9.20]: https://github.com/lsegal/yard/compare/v0.9.19...v0.9.20
65
161
 
@@ -69,7 +165,7 @@
69
165
  `yard server` host under certain conditions. Thanks to CuongMX from
70
166
  Viettel Cyber Security for discovering this vulnerability.
71
167
 
72
- # 0.9.19 - April 2nd, 2019
168
+ # [0.9.19] - April 2nd, 2019
73
169
 
74
170
  [0.9.19]: https://github.com/lsegal/yard/compare/v0.9.16...v0.9.19
75
171
 
data/LEGAL CHANGED
@@ -4,7 +4,7 @@ LEGAL NOTICE INFORMATION
4
4
  All the files in this distribution are covered under either the MIT
5
5
  license (see the file LICENSE) except some files mentioned below.
6
6
 
7
- lib/parser/ruby/legacy/ruby_lex.rb:
7
+ lib/yard/parser/ruby/legacy/ruby_lex.rb:
8
8
 
9
9
  This file is under the Ruby license. YARD uses a modified version of it.
10
10
 
@@ -64,3 +64,31 @@ lib/parser/ruby/legacy/ruby_lex.rb:
64
64
  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
65
65
  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
66
66
  PURPOSE.
67
+
68
+ lib/yard/server/http_utils.rb:
69
+
70
+ This file is vendored and slightly modified from WEBrick because it was
71
+ removed from Ruby core in Ruby 3.x.
72
+
73
+ Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
74
+
75
+ Redistribution and use in source and binary forms, with or without
76
+ modification, are permitted provided that the following conditions
77
+ are met:
78
+ 1. Redistributions of source code must retain the above copyright
79
+ notice, this list of conditions and the following disclaimer.
80
+ 2. Redistributions in binary form must reproduce the above copyright
81
+ notice, this list of conditions and the following disclaimer in the
82
+ documentation and/or other materials provided with the distribution.
83
+
84
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
85
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
86
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
87
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
88
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
89
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
90
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
91
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
92
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
93
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
94
+ SUCH DAMAGE.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2007-2018 Loren Segal
1
+ Copyright (c) 2007-2022 Loren Segal
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Documentation](https://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://rubydoc.org/gems/yard/frames)
6
6
 
7
7
  [![Gem Version](https://badge.fury.io/rb/yard.svg)](http://github.com/lsegal/yard/releases)
8
- [![Build Status](https://travis-ci.org/lsegal/yard.svg?branch=main)](https://travis-ci.org/lsegal/yard)
8
+ [![Unit Tests](https://github.com/lsegal/yard/actions/workflows/ci.yml/badge.svg)](https://github.com/lsegal/yard/actions/workflows/ci.yml)
9
9
  [![Coverage Status](https://coveralls.io/repos/github/lsegal/yard/badge.svg)](https://coveralls.io/github/lsegal/yard)
10
10
  [![License](https://img.shields.io/badge/license-MIT-yellowgreen.svg)](#license)
11
11
 
@@ -122,6 +122,13 @@ HTML. If running `which rdoc` turns up empty, install RDoc by issuing:
122
122
  $ sudo apt-get install rdoc
123
123
  ```
124
124
 
125
+ ### Markdown parser
126
+
127
+ When rendering markdown, yard will use one of several possible markdown providers,
128
+ [in order of priority](https://github.com/lsegal/yard/blob/e833aac7a01510245dd4ae1d1d18b046c8293c2d/lib/yard/templates/helpers/markup_helper.rb#L26-L33).
129
+ If you are experiencing rendering bugs (example [1](https://github.com/lsegal/yard/issues/1410) [2](https://github.com/lsegal/yard/issues/1543)), try adding one of the
130
+ gems further up in the list to your Gemfile.
131
+
125
132
  ## Usage
126
133
 
127
134
  There are a couple of ways to use YARD. The first is via command-line, and the
@@ -185,7 +192,7 @@ Note that the README file can be specified with its own `--readme` switch.
185
192
  You can also add a `.yardopts` file to your project directory which lists the
186
193
  switches separated by whitespace (newlines or space) to pass to yardoc whenever
187
194
  it is run. A full overview of the `.yardopts` file can be found in
188
- {YARD::CLI::Yardoc}.
195
+ [YARD::CLI::Yardoc](https://rubydoc.info/gems/yard/YARD/CLI/Yardoc#label-Options+File+-28.yardopts-29).
189
196
 
190
197
  ### Queries
191
198
 
data/docs/Tags.md CHANGED
@@ -206,7 +206,7 @@ also be a list of types separated by commas.
206
206
  An order dependent list is a set of types surrounded by "()" and separated by
207
207
  commas. This list must contain exactly those types in exactly the order specified.
208
208
  For instance, an Array containing a String, Fixnum and Hash in that order (and
209
- having exactly those 3 elements) would be listed as: `Array<(String, Fixnum, Hash)>`.
209
+ having exactly those 3 elements) would be listed as: `Array(String, Fixnum, Hash)`.
210
210
 
211
211
  #### Literals
212
212
 
data/docs/WhatsNew.md CHANGED
@@ -92,7 +92,7 @@ methods are defined dynamically and not associated with any code.
92
92
  #### New `@!parse` directive to parse Ruby code
93
93
 
94
94
  A new {tag:!parse} directive was added that allows a developer to have
95
- YARD parse code that might not necessarily be parseable in its original
95
+ YARD parse code that might not necessarily be parsable in its original
96
96
  form. This is useful when using `instance_eval` and other dynamic
97
97
  meta-programming techniques to define methods or perform functionality.
98
98
  For instance, a common case of the "self.included" callback in module
@@ -1204,7 +1204,7 @@ that is actually being employed. Here's an example:
1204
1204
  # @overload def to_html(html, autolink = true)
1205
1205
  # This docstring describes the specific overload only.
1206
1206
  # @param [String] html the HTML
1207
- # @param [Boolean] autolink whether or not to atuomatically link
1207
+ # @param [Boolean] autolink whether or not to automatically link
1208
1208
  # URL references
1209
1209
  # @overload def to_html(html, opts = {})
1210
1210
  # @param [String] html the HTML
data/lib/yard/autoload.rb CHANGED
@@ -170,7 +170,6 @@ module YARD
170
170
 
171
171
  module Ruby # Ruby parsing components.
172
172
  module Legacy # Handles Ruby parsing in Ruby 1.8.
173
- autoload :RipperParser, __p('parser/ruby/legacy/ruby_parser')
174
173
  autoload :RubyParser, __p('parser/ruby/legacy/ruby_parser')
175
174
  autoload :RubyToken, __p('parser/ruby/legacy/ruby_lex')
176
175
  autoload :Statement, __p('parser/ruby/legacy/statement')
@@ -180,6 +179,7 @@ module YARD
180
179
 
181
180
  autoload :AstNode, __p('parser/ruby/ast_node')
182
181
  autoload :RubyParser, __p('parser/ruby/ruby_parser')
182
+ autoload :RipperParser, __p('parser/ruby/ruby_parser')
183
183
  autoload :TokenResolver, __p('parser/ruby/token_resolver')
184
184
  end
185
185
 
@@ -236,6 +236,7 @@ module YARD
236
236
  autoload :FinishRequest, __p('server/adapter')
237
237
  autoload :LibraryVersion, __p('server/library_version')
238
238
  autoload :NotFoundError, __p('server/adapter')
239
+ autoload :HTTPUtils, __p('server/http_utils')
239
240
  autoload :RackAdapter, __p('server/rack_adapter')
240
241
  autoload :RackMiddleware, __p('server/rack_adapter')
241
242
  autoload :Router, __p('server/router')
@@ -297,6 +298,7 @@ module YARD
297
298
  autoload :DocstringParser, __p('docstring_parser')
298
299
  autoload :GemIndex, __p('gem_index')
299
300
  autoload :Logger, __p('logging')
301
+ autoload :OpenStruct, __p('open_struct')
300
302
  autoload :Options, __p('options')
301
303
  autoload :Registry, __p('registry')
302
304
  autoload :RegistryResolver, __p('registry_resolver')
@@ -70,7 +70,7 @@ module YARD
70
70
  load(file)
71
71
  rescue LoadError => load_exception
72
72
  log.error "The file `#{file}' could not be loaded:\n#{load_exception}"
73
- exit
73
+ exit 1
74
74
  end
75
75
 
76
76
  # Callback when an unrecognize option is parsed
@@ -43,6 +43,8 @@ module YARD
43
43
 
44
44
  print_statistics
45
45
  print_undocumented_objects
46
+
47
+ abort if fail_on_warning && log.warned
46
48
  end
47
49
 
48
50
  # Prints statistics for different object types
@@ -223,7 +225,8 @@ module YARD
223
225
  end
224
226
 
225
227
  opts.on('--query QUERY', "Only includes objects that match a specific query") do |query|
226
- options[:verifier].add_expressions(query.taint)
228
+ query.taint if query.respond_to?(:taint)
229
+ options[:verifier].add_expressions(query)
227
230
  end
228
231
  end
229
232
  end
@@ -295,9 +295,10 @@ module YARD
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
297
  readme = Dir.glob('README{,*[^~]}').
298
+ select {|f| extra_file_valid?(f)}.
298
299
  sort_by {|r| [r.count('.'), r.index('.'), r] }.first
299
300
  readme ||= Dir.glob(files.first).first if options.onefile && !files.empty?
300
- options.readme ||= CodeObjects::ExtraFileObject.new(readme) if readme
301
+ options.readme ||= CodeObjects::ExtraFileObject.new(readme) if readme && extra_file_valid?(readme)
301
302
  options.files.unshift(options.readme).uniq! if options.readme
302
303
 
303
304
  Tags::Library.visible_tags -= hidden_tags
@@ -333,7 +334,7 @@ module YARD
333
334
  private
334
335
 
335
336
  # Generates output for objects
336
- # @param [Hash, nil] checksums if supplied, a list of checkums for files.
337
+ # @param [Hash, nil] checksums if supplied, a list of checksums for files.
337
338
  # @return [void]
338
339
  # @since 0.5.1
339
340
  def run_generate(checksums)
@@ -649,7 +650,8 @@ module YARD
649
650
 
650
651
  opts.on('--query QUERY', "Only show objects that match a specific query") do |query|
651
652
  next if YARD::Config.options[:safe_mode]
652
- options.verifier.add_expressions(query.taint)
653
+ query.taint if query.respond_to?(:taint)
654
+ options.verifier.add_expressions(query)
653
655
  end
654
656
 
655
657
  opts.on('--title TITLE', 'Add a specific title to HTML documents') do |title|
@@ -303,6 +303,7 @@ module YARD
303
303
  # definitions with docstrings first.
304
304
  #
305
305
  # @return [String] a filename
306
+ # @return [nil] if there is no file associated with the object
306
307
  def file
307
308
  @files.first ? @files.first[0] : nil
308
309
  end
@@ -434,7 +435,10 @@ module YARD
434
435
  #
435
436
  # @return [Symbol] the type of code object this represents
436
437
  def type
437
- self.class.name.split('::').last.gsub(/Object$/, '').downcase.to_sym
438
+ obj_name = self.class.name.split('::').last
439
+ obj_name.gsub!(/Object$/, '')
440
+ obj_name.downcase!
441
+ obj_name.to_sym
438
442
  end
439
443
 
440
444
  # Represents the unique path of the object. The default implementation
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require 'ostruct'
3
2
 
4
3
  module YARD
5
4
  module CodeObjects
data/lib/yard/config.rb CHANGED
@@ -236,7 +236,11 @@ module YARD
236
236
  def self.read_config_file
237
237
  if File.file?(CONFIG_FILE)
238
238
  require 'yaml'
239
- YAML.load_file(CONFIG_FILE)
239
+ if YAML.respond_to?(:safe_load_file)
240
+ YAML.safe_load_file(CONFIG_FILE, permitted_classes: [SymbolHash, Symbol])
241
+ else
242
+ YAML.load_file(CONFIG_FILE)
243
+ end
240
244
  else
241
245
  {}
242
246
  end
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require 'ostruct'
3
2
 
4
3
  module YARD
5
4
  # Parses text and creates a {Docstring} object to represent documentation
@@ -8,7 +7,7 @@ module YARD
8
7
  #
9
8
  # == Subclassing Notes
10
9
  #
11
- # The DocstringParser can be subclassed and subtituted during parsing by
10
+ # The DocstringParser can be subclassed and substituted during parsing by
12
11
  # setting the {Docstring.default_parser} attribute with the name of the
13
12
  # subclass. This allows developers to change the way docstrings are
14
13
  # parsed, allowing for completely different docstring syntaxes.
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require 'ostruct'
3
2
 
4
3
  module YARD
5
4
  module Handlers
@@ -52,7 +52,7 @@ class YARD::Handlers::Ruby::AttributeHandler < YARD::Handlers::Ruby::Base
52
52
  register(o)
53
53
  o.docstring = doc if o.docstring.blank?(false)
54
54
 
55
- # Regsiter the object explicitly
55
+ # Register the object explicitly
56
56
  namespace.attributes[scope][name][type] = o
57
57
  else
58
58
  obj = namespace.children.find {|other| other.name == meth.to_sym && other.scope == scope }
@@ -51,7 +51,7 @@ class YARD::Handlers::Ruby::Legacy::AttributeHandler < YARD::Handlers::Ruby::Leg
51
51
  register(o)
52
52
  o.docstring = doc if o.docstring.blank?(false)
53
53
 
54
- # Regsiter the object explicitly
54
+ # Register the object explicitly
55
55
  namespace.attributes[scope][name][type] = o
56
56
  else
57
57
  obj = namespace.children.find {|other| other.name == meth.to_sym && other.scope == scope }
@@ -67,7 +67,7 @@ class YARD::Handlers::Ruby::MethodHandler < YARD::Handlers::Ruby::Base
67
67
  end
68
68
 
69
69
  def format_args
70
- args = statement.parameters
70
+ return [] unless args = statement.parameters
71
71
 
72
72
  params = []
73
73
 
@@ -97,7 +97,7 @@ class YARD::Handlers::Ruby::MethodHandler < YARD::Handlers::Ruby::Base
97
97
  params << ['**' + args.double_splat_param.source, nil]
98
98
  end
99
99
 
100
- params << ['&' + args.block_param.source, nil] if args.block_param
100
+ params << ['&' + args.block_param.source, nil] if args.block_param && !args.args_forward
101
101
 
102
102
  params
103
103
  end
@@ -26,22 +26,31 @@ class YARD::Handlers::Ruby::MixinHandler < YARD::Handlers::Ruby::Base
26
26
  raise YARD::Parser::UndocumentableError unless mixin.ref?
27
27
  raise YARD::Parser::UndocumentableError if mixin.first.type == :ident
28
28
 
29
- case obj = Proxy.new(namespace, mixin.source)
30
- when ConstantObject # If a constant is included, use its value as the real object
31
- obj = Proxy.new(namespace, obj.value, :module)
29
+ if mixin.type == :var_ref && mixin[0] == s(:kw, "self")
30
+ obj = namespace
32
31
  else
33
- obj = Proxy.new(namespace, mixin.source, :module)
32
+ case obj = Proxy.new(namespace, mixin.source)
33
+ when ConstantObject # If a constant is included, use its value as the real object
34
+ obj = Proxy.new(namespace, obj.value, :module)
35
+ else
36
+ obj = Proxy.new(namespace, mixin.source, :module)
37
+ end
34
38
  end
35
39
 
36
40
  rec = recipient(mixin)
37
- return if rec.nil? || rec.mixins(scope).include?(obj)
41
+ return if rec.nil?
42
+
43
+ ensure_loaded!(rec)
44
+ return if rec.mixins(scope).include?(obj)
38
45
 
39
46
  shift = statement.method_name(true) == :include ? :unshift : :push
40
47
  rec.mixins(scope).send(shift, obj)
41
48
  end
42
49
 
43
50
  def recipient(mixin)
44
- if statement[0].type == :var_ref && statement[0][0] != s(:kw, "self")
51
+ if statement[0].type == :const_path_ref || statement[0].type == :top_const_ref
52
+ Proxy.new(namespace, statement[0].source)
53
+ elsif statement[0].type == :var_ref && statement[0][0] != s(:kw, "self")
45
54
  statement[0][0].type == :const ?
46
55
  Proxy.new(namespace, statement.namespace.source) :
47
56
  nil
@@ -2,6 +2,8 @@
2
2
  # Handles module_function calls to turn methods into public class methods.
3
3
  # Also creates a private instance copy of the method.
4
4
  class YARD::Handlers::Ruby::ModuleFunctionHandler < YARD::Handlers::Ruby::Base
5
+ include YARD::Handlers::Ruby::DecoratorHandlerMethods
6
+
5
7
  handles method_call(:module_function)
6
8
  namespace_only
7
9
 
@@ -13,15 +15,25 @@ class YARD::Handlers::Ruby::ModuleFunctionHandler < YARD::Handlers::Ruby::Base
13
15
  when :fcall, :command
14
16
  statement[1].traverse do |node|
15
17
  case node.type
18
+ when :def
19
+ process_decorator do |instance_method|
20
+ make_module_function(instance_method, namespace)
21
+ end
22
+ break
16
23
  when :symbol; name = node.first.source
17
24
  when :string_content; name = node.source
18
25
  else next
19
26
  end
27
+
20
28
  instance_method = MethodObject.new(namespace, name)
21
- class_method = MethodObject.new(namespace, name, :module)
22
- instance_method.copy_to(class_method)
23
- class_method.visibility = :public
29
+ make_module_function(instance_method, namespace)
24
30
  end
25
31
  end
26
32
  end
33
+
34
+ def make_module_function(instance_method, namespace)
35
+ class_method = MethodObject.new(namespace, instance_method.name, :module)
36
+ instance_method.copy_to(class_method)
37
+ class_method.visibility = :public
38
+ end
27
39
  end
@@ -13,10 +13,22 @@ class YARD::Handlers::Ruby::VisibilityHandler < YARD::Handlers::Ruby::Base
13
13
  case statement.type
14
14
  when :var_ref, :vcall
15
15
  self.visibility = ident.first.to_sym
16
- when :fcall, :command
16
+ when :command
17
+ if RUBY_VERSION >= '3.' && is_attribute_method?(statement.parameters.first)
18
+ parse_block(statement.parameters.first, visibility: ident.first.to_sym)
19
+ return
20
+ end
21
+ process_decorator do |method|
22
+ method.visibility = ident.first if method.respond_to? :visibility=
23
+ end
24
+ when :fcall
17
25
  process_decorator do |method|
18
26
  method.visibility = ident.first if method.respond_to? :visibility=
19
27
  end
20
28
  end
21
29
  end
30
+
31
+ def is_attribute_method?(node)
32
+ node.type == :command && node.jump(:ident).first.to_s =~ /^attr_(accessor|writer|reader)$/
33
+ end
22
34
  end
@@ -57,7 +57,7 @@ module YARD
57
57
  end
58
58
 
59
59
  # @param [String] message the translation target message.
60
- # @return [String] translated message. If tarnslation isn't
60
+ # @return [String] translated message. If translation isn't
61
61
  # registered, the +message+ is returned.
62
62
  def translate(message)
63
63
  @messages[message] || message
@@ -8,7 +8,7 @@ module YARD
8
8
  #
9
9
  # @since 0.8.1
10
10
  class Message
11
- # @return [String] the message ID of the trnslation target message.
11
+ # @return [String] the message ID of the translation target message.
12
12
  attr_reader :id
13
13
 
14
14
  # @return [Set] the set of locations. Location is an array of
@@ -18,7 +18,7 @@ module YARD
18
18
  # @return [Set] the set of comments for the messages.
19
19
  attr_reader :comments
20
20
 
21
- # Creates a trasnlate target message for message ID +id+.
21
+ # Creates a translate target message for message ID +id+.
22
22
  #
23
23
  # @param [String] id the message ID of the translate target message.
24
24
  def initialize(id)
@@ -28,7 +28,7 @@ module YARD
28
28
  @messages[id]
29
29
  end
30
30
 
31
- # Registers a {Message}, the mssage ID of which is +id+. If
31
+ # Registers a {Message}, the message ID of which is +id+. If
32
32
  # corresponding +Message+ is already registered, the previously
33
33
  # registered object is returned.
34
34
  #
@@ -113,7 +113,7 @@ module YARD
113
113
  #
114
114
  # Locations of the +Message+ are used to generate the reference
115
115
  # line that is started with "#: ". +relative_base_path+ passed
116
- # when the generater is created is prepended to each path in location.
116
+ # when the generator is created is prepended to each path in location.
117
117
  #
118
118
  # Comments of the +Message+ are used to generate the
119
119
  # translator-comment line that is started with "# ".