yard 0.9.37 → 0.9.41

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.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +52 -1
  3. data/README.md +27 -30
  4. data/docs/GettingStarted.md +41 -15
  5. data/docs/Tags.md +5 -5
  6. data/docs/Templates.md +5 -4
  7. data/docs/WhatsNew.md +59 -7
  8. data/docs/templates/default/yard_tags/html/setup.rb +1 -1
  9. data/lib/yard/autoload.rb +17 -0
  10. data/lib/yard/cli/diff.rb +7 -2
  11. data/lib/yard/code_objects/base.rb +1 -1
  12. data/lib/yard/code_objects/extra_file_object.rb +1 -0
  13. data/lib/yard/code_objects/proxy.rb +1 -1
  14. data/lib/yard/handlers/base.rb +23 -1
  15. data/lib/yard/handlers/processor.rb +1 -0
  16. data/lib/yard/handlers/rbs/attribute_handler.rb +43 -0
  17. data/lib/yard/handlers/rbs/base.rb +38 -0
  18. data/lib/yard/handlers/rbs/constant_handler.rb +18 -0
  19. data/lib/yard/handlers/rbs/method_handler.rb +327 -0
  20. data/lib/yard/handlers/rbs/mixin_handler.rb +20 -0
  21. data/lib/yard/handlers/rbs/namespace_handler.rb +26 -0
  22. data/lib/yard/handlers/ruby/attribute_handler.rb +7 -4
  23. data/lib/yard/handlers/ruby/constant_handler.rb +24 -6
  24. data/lib/yard/handlers/ruby/legacy/visibility_handler.rb +2 -1
  25. data/lib/yard/handlers/ruby/visibility_handler.rb +1 -0
  26. data/lib/yard/i18n/locale.rb +1 -1
  27. data/lib/yard/i18n/pot_generator.rb +1 -1
  28. data/lib/yard/parser/rbs/rbs_parser.rb +325 -0
  29. data/lib/yard/parser/rbs/statement.rb +75 -0
  30. data/lib/yard/parser/ruby/ast_node.rb +5 -4
  31. data/lib/yard/parser/ruby/legacy/irb/slex.rb +19 -1
  32. data/lib/yard/parser/ruby/legacy/ruby_lex.rb +1 -1
  33. data/lib/yard/parser/ruby/ruby_parser.rb +109 -24
  34. data/lib/yard/parser/source_parser.rb +3 -2
  35. data/lib/yard/registry_resolver.rb +7 -0
  36. data/lib/yard/rubygems/specification.rb +1 -1
  37. data/lib/yard/server/library_version.rb +1 -1
  38. data/lib/yard/server/templates/default/fulldoc/html/js/autocomplete.js +208 -12
  39. data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +1 -17
  40. data/lib/yard/server/templates/default/method_details/html/permalink.erb +4 -2
  41. data/lib/yard/server/templates/doc_server/library_list/html/headers.erb +3 -3
  42. data/lib/yard/server/templates/doc_server/library_list/html/library_list.erb +2 -3
  43. data/lib/yard/server/templates/doc_server/processing/html/processing.erb +22 -16
  44. data/lib/yard/tags/directives.rb +7 -0
  45. data/lib/yard/tags/library.rb +3 -3
  46. data/lib/yard/tags/overload_tag.rb +2 -1
  47. data/lib/yard/tags/tag.rb +1 -1
  48. data/lib/yard/tags/types_explainer.rb +5 -4
  49. data/lib/yard/templates/helpers/base_helper.rb +1 -1
  50. data/lib/yard/templates/helpers/html_helper.rb +21 -6
  51. data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +6 -1
  52. data/lib/yard/templates/helpers/markup/hybrid_markdown.rb +2147 -0
  53. data/lib/yard/templates/helpers/markup/rdoc_markup.rb +2 -0
  54. data/lib/yard/templates/helpers/markup_helper.rb +4 -2
  55. data/lib/yard/version.rb +1 -1
  56. data/po/ja.po +82 -82
  57. data/templates/default/fulldoc/html/css/style.css +33 -15
  58. data/templates/default/fulldoc/html/full_list.erb +4 -4
  59. data/templates/default/fulldoc/html/js/app.js +567 -271
  60. data/templates/default/fulldoc/html/js/full_list.js +341 -211
  61. data/templates/default/layout/html/headers.erb +1 -1
  62. data/templates/default/layout/html/layout.erb +2 -1
  63. data/templates/default/method/html/header.erb +3 -3
  64. data/templates/default/module/html/defines.erb +3 -3
  65. data/templates/default/module/html/inherited_methods.erb +1 -0
  66. data/templates/default/module/html/method_summary.erb +8 -0
  67. data/templates/default/module/setup.rb +20 -0
  68. data/templates/default/onefile/html/layout.erb +3 -4
  69. data/templates/guide/fulldoc/html/js/app.js +57 -26
  70. data/templates/guide/layout/html/layout.erb +9 -11
  71. metadata +18 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0774d1772b133075737690acbc502767f6fef28d3765a14929074259248f3981
4
- data.tar.gz: '068103b3caf24a6c6071a6c9b0f52bd58641fd0c03e22220fb2d1b09a104385c'
3
+ metadata.gz: b498d65eea07bb8fc6b7f6e43b210a66d2a7b37ff19159ca4312d254b006ff36
4
+ data.tar.gz: be2ebd8ff2e23d88afd7adebeb7520b4ece385c3faac5a564c91eb7137185034
5
5
  SHA512:
6
- metadata.gz: 64a799b2f45d7ad6aad8684c805344f242c8e2f8ef1c60a43094bc237bccd449ee1c93c60c0f54a36f05a79e5b652636d7170dce85941b1f74a4bcc173c92c21
7
- data.tar.gz: b19ba690f1a244b0c7df5c1524f77355323fa9164e9496c609f258b3d0691c0a3d807cd985f20f335884ba1d8e97193149d4a7b9e1eebd9ed3a43431492a1ce3
6
+ metadata.gz: 40cb9115aafad9eb4b31dbc4f80d6bb3afe77d0935e4a52c435895a679730cccc1d0f53c2c2c54a908881e7bcf96c2585d1c638d8738d1b75834c164b3c2e825
7
+ data.tar.gz: 363ac81a03972f3e3d86f917d3db3db8beb50ae813a52f80104fcc9d57073d9717c203b0b885d34218bdc0739f20fc1f9b7ad5fd390f7672c6f0fb1e890b9a0a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,56 @@
1
1
  # main
2
2
 
3
+ # [0.9.41] - April 14th, 2026
4
+
5
+ [0.9.41]: https://github.com/lsegal/yard/compare/v0.9.40...v0.9.41
6
+
7
+ - Add support for `rdoc-image:...` syntax in HybridMarkup (#1676)
8
+ - Add support for colon suffix code blocks in HybridMarkup (rdoc compatibility)
9
+ - Fix responsiveness and state issues with nav frame links in `yard server`
10
+ # [0.9.40] - April 12th, 2026
11
+
12
+ [0.9.40]: https://github.com/lsegal/yard/compare/v0.9.39...v0.9.40
13
+
14
+ - Add support for Ruby .rbs files (docstrings included) (#1673)
15
+ - Add built-in hybrid RDoc/Markdown renderer (`HybridMarkdown`) requiring no external gems (#1674)
16
+ - Add support for `#-` as a comment-block separator. See Getting Started Guide.
17
+ - Add support for `commonmarker` version `>= 1.0`.
18
+ - Remove usage of jQuery in default templates. jQuery library is still packaged in templates for backward compatibility (#1675)
19
+ - Fix false self-referential mixin when bare name matches ancestor namespace (#1672)
20
+ - Fix bracket/brace map corruption from Ruby 3.0+ pattern matching deconstruction (#1671)
21
+ - Fix `@!scope class` on attributes (#1582, #1655, #1666)
22
+ - Fix `@!parse` directives not including source for block (#1665)
23
+ - Fix inherited methods not appearing in groups (#1656)
24
+
25
+ # [0.9.39] - April 8th, 2026
26
+
27
+ [0.9.39]: https://github.com/lsegal/yard/compare/v0.9.38...v0.9.39
28
+
29
+ - Add support for Ruby 4.0 (#1663)
30
+ - Add changelog URI to gemspec metadata (#1641)
31
+ - Fix issues with source ranges (#1642)
32
+ - Fix an issue loading relative links from file list in HTML template (#1660)
33
+ - Various test fixes (#1650, #1651)
34
+
35
+
36
+ # [0.9.38] - December 5th, 2025
37
+
38
+ [0.9.38]: https://github.com/lsegal/yard/compare/v0.9.37...v0.9.38
39
+
40
+ - Add support for complex constant assignment (#1599)
41
+ - Add support for Data type structs (#1600)
42
+ - Support multi method duck type syntax in type explainer (#1631)
43
+ - Improve Ruby 3.5 compatibility (#1616)
44
+ - Update documentation for various type annotations (#1615)
45
+ - JavaScript frontend updates (resizer, JS bugs, reduce console verbosity) for default template
46
+ - Fix beginless/endless range errors (#1549, #1625)
47
+ - Fix path structure in Templates.md documentation (#1588)
48
+ - Fix signature handling in overload (#1590)
49
+ - Fix handling of **nil with named block (#1623)
50
+ - Fix directives in empty class bodies (#1624)
51
+ - Fix parsing of array within array syntax (#1604)
52
+ - Fix parsing of visibility keywords in front of class methods (#1632)
53
+
3
54
  # [0.9.37] - September 4th, 2024
4
55
 
5
56
  [0.9.37]: https://github.com/lsegal/yard/compare/v0.9.36...v0.9.37
@@ -829,7 +880,7 @@ contributions to this version.
829
880
 
830
881
  [0.4.0]: https://github.com/lsegal/yard/compare/v0.2.3.5...v0.4.0
831
882
 
832
- - Added new templating engine based on [tadpole](http://github.com/lsegal/tadpole)
883
+ - Added new templating engine based on [tadpole](https://github.com/lsegal/tadpole)
833
884
  - Added YARD queries (`--query` CLI argument to yardoc)
834
885
  - Greatly expanded YARD documentation
835
886
  - Added plugin support
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # YARD: Yay! A Ruby Documentation Tool
2
2
 
3
- [![Homepage](https://img.shields.io/badge/home-yardoc.org-blue.svg)](http://yardoc.org)
4
- [![GitHub](https://img.shields.io/badge/github-lsegal/yard-blue.svg)](http://github.com/lsegal/yard)
5
- [![Documentation](https://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://rubydoc.org/gems/yard/frames)
3
+ [![Homepage](https://img.shields.io/badge/home-yardoc.org-blue.svg)](https://yardoc.org)
4
+ [![GitHub](https://img.shields.io/badge/github-lsegal/yard-blue.svg)](https://github.com/lsegal/yard)
5
+ [![Documentation](https://img.shields.io/badge/docs-rdoc.info-blue.svg)](https://rubydoc.org/gems/yard/frames)
6
6
 
7
- [![Gem Version](https://badge.fury.io/rb/yard.svg)](http://github.com/lsegal/yard/releases)
7
+ [![Gem Version](https://badge.fury.io/rb/yard.svg)](https://github.com/lsegal/yard/releases)
8
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)
@@ -19,10 +19,10 @@ summary of some of YARD's notable features.
19
19
 
20
20
  ## Feature List
21
21
 
22
- **1. RDoc/SimpleMarkup Formatting Compatibility**: YARD is made to be compatible
23
- with RDoc formatting. In fact, YARD does no processing on RDoc documentation
24
- strings, and leaves this up to the output generation tool to decide how to
25
- render the documentation.
22
+ **1. Builtin RDoc/Markdown Hybrid Support**: YARD ships with a builtin markup
23
+ renderer that supports both RDoc and Markdown formatting out of the box—no
24
+ external gem required. You can freely mix RDoc-style and Markdown-style
25
+ documentation without installing any additional libraries.
26
26
 
27
27
  **2. Yardoc Meta-tag Formatting Like Python, Java, Objective-C and other
28
28
  languages**: YARD uses a '@tag' style definition syntax for meta tags alongside
@@ -114,27 +114,24 @@ $ gem install yard
114
114
  Alternatively, if you've checked the source out directly, you can call
115
115
  `rake install` from the root project directory.
116
116
 
117
- **Important Note for Debian/Ubuntu users:** there's a possible chance your Ruby
118
- install lacks RDoc, which is occasionally used by YARD to convert markup to
119
- HTML. If running `which rdoc` turns up empty, install RDoc by issuing:
117
+ ### Markup rendering
120
118
 
121
- ```sh
122
- $ sudo apt-get install rdoc
123
- ```
124
-
125
- ### Markdown parser
119
+ YARD includes a builtin renderer that handles both RDoc and Markdown markup
120
+ types without any external dependencies. To switch the default markup type,
121
+ pass `-m markdown` (or `-m rdoc`) to `yard doc`, or add it to your `.yardopts`
122
+ file.
126
123
 
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.
124
+ For optional extra rendering features (e.g. GitHub-Flavoured Markdown fenced
125
+ code blocks, tables, or specific Markdown extensions), you can install an
126
+ additional provider gem such as `redcarpet`, `commonmarker`, or `kramdown` and
127
+ select it explicitly with `-M PROVIDER` (e.g. `yard doc -m markdown -M redcarpet`).
131
128
 
132
129
  ## Usage
133
130
 
134
131
  There are a couple of ways to use YARD. The first is via command-line, and the
135
132
  second is the Rake task.
136
133
 
137
- **1. yard Command-line Tool**
134
+ ### 1. yard Command-line Tool
138
135
 
139
136
  YARD comes packaged with a executable named `yard` which can control the many
140
137
  functions of YARD, including generating documentation, graphs running the YARD
@@ -147,7 +144,7 @@ $ yard --help
147
144
  Plugins can also add commands to the `yard` executable to provide extra
148
145
  functionality.
149
146
 
150
- ### Generating Documentation
147
+ #### Generating Documentation
151
148
 
152
149
  <span class="note">The `yardoc` executable is a shortcut for `yard doc`.</span>
153
150
 
@@ -194,7 +191,7 @@ switches separated by whitespace (newlines or space) to pass to yardoc whenever
194
191
  it is run. A full overview of the `.yardopts` file can be found in
195
192
  [YARD::CLI::Yardoc](https://rubydoc.info/gems/yard/YARD/CLI/Yardoc#label-Options+File+-28.yardopts-29).
196
193
 
197
- ### Queries
194
+ #### Queries
198
195
 
199
196
  The `yardoc` tool also supports a `--query` argument to only include objects
200
197
  that match a certain data or meta-data query. The query syntax is Ruby, though a
@@ -221,7 +218,7 @@ following two lines both check for the existence of a return and param tag:
221
218
 
222
219
  For more information about the query syntax, see the {YARD::Verifier} class.
223
220
 
224
- **2. Rake Task**
221
+ ### 2. Rake Task
225
222
 
226
223
  The second most obvious is to generate docs via a Rake task. You can do this by
227
224
  adding the following to your `Rakefile`:
@@ -247,7 +244,7 @@ environment variable:
247
244
  $ rake yard OPTS='--any --extra --opts'
248
245
  ```
249
246
 
250
- **3. `yri` RI Implementation**
247
+ ### 3. `yri` RI Implementation
251
248
 
252
249
  The yri binary will use the cached .yardoc database to give you quick ri-style
253
250
  access to your documentation. It's way faster than ri but currently does not
@@ -271,7 +268,7 @@ $ yard gems
271
268
  If you don't have sudo access, it will write these files to your `~/.yard`
272
269
  directory. `yri` will also cache lookups there.
273
270
 
274
- **4. `yard server` Documentation Server**
271
+ ### 4. `yard server` Documentation Server
275
272
 
276
273
  The `yard server` command serves documentation for a local project or all
277
274
  installed RubyGems. To serve documentation for a project you are working on,
@@ -285,14 +282,14 @@ And the project inside the current directory will be parsed (if the source has
285
282
  not yet been scanned by YARD) and served at
286
283
  [http://localhost:8808](http://localhost:8808).
287
284
 
288
- ### Live Reloading
285
+ #### Live Reloading
289
286
 
290
287
  If you want to serve documentation on a project while you document it so that
291
288
  you can preview the results, simply pass `--reload` (`-r`) to the above command
292
289
  and YARD will reload any changed files on each request. This will allow you to
293
290
  change any documentation in the source and refresh to see the new contents.
294
291
 
295
- ### Serving Gems
292
+ #### Serving Gems
296
293
 
297
294
  To serve documentation for all installed gems, call:
298
295
 
@@ -304,10 +301,10 @@ This will also automatically build documentation for any gems that have not been
304
301
  previously scanned. Note that in this case there will be a slight delay between
305
302
  the first request of a newly parsed gem.
306
303
 
307
- **5. `yard graph` Graphviz Generator**
304
+ ### 5. `yard graph` Graphviz Generator
308
305
 
309
306
  You can use `yard graph` to generate dot graphs of your code. This, of course,
310
- requires [Graphviz](http://www.graphviz.org) and the `dot` binary. By default
307
+ requires [Graphviz](https://www.graphviz.org) and the `dot` binary. By default
311
308
  this will generate a graph of the classes and modules in the best UML2 notation
312
309
  that Graphviz can support, but without any methods listed. With the `--full`
313
310
  option, methods and attributes will be listed. There is also a `--dependencies`
@@ -61,15 +61,41 @@ Using tags we can add semantic metadata to our code without worrying about
61
61
  presentation. YARD will handle presentation for us when we decide to generate
62
62
  documentation later.
63
63
 
64
+ ### Disconnecting Comment Blocks
65
+
66
+ YARD attaches a comment block to the next relevant object by default. That is
67
+ usually what you want, but file headers are a common exception. If you keep a
68
+ copyright notice, license note or general file-level description at the top of
69
+ the file, it can accidentally become the docstring for the first class or
70
+ module unless you explicitly break the block.
71
+
72
+ To disconnect the block, end the header with an attached `#-` line:
73
+
74
+ # Copyright (c) Example Corp
75
+ # Shared support code for the client layer.
76
+ #-
77
+
78
+ class Client
79
+ end
80
+
81
+ In this example, the header comment is not attached to `Client`.
82
+
83
+ This only works with `#-`. If you write `# -` with a space before the hyphen,
84
+ YARD treats it as a normal comment line and it remains part of the docstring.
85
+
64
86
  ## Which Markup Format?
65
87
 
66
- YARD does not impose a specific markup. The above example uses standard RDoc
67
- markup formatting, but YARD also supports textile and markdown via the
68
- command-line switch or `.yardopts` file (see below). This means that you are
69
- free to use whatever formatting you like. This guide is actually written
70
- using markdown. YARD, however, does add a few important syntaxes that are
71
- processed no matter which markup formatting you use, such as tag support
72
- and inter-document linking. These syntaxes are discussed below.
88
+ YARD does not impose a specific markup format. YARD ships with a builtin
89
+ renderer that supports both RDoc and Markdown out of the box—no external gem
90
+ required. You can use either format (or switch between them) without installing
91
+ anything extra. YARD also supports textile, asciidoc, and other formats via
92
+ optional gems.
93
+
94
+ To select a markup format, use the command-line switch `-m FORMAT` or add
95
+ `--markup FORMAT` to your `.yardopts` file. This guide is written in Markdown.
96
+ YARD adds a few important syntaxes that are processed regardless of which
97
+ markup format you choose, such as tag support and inter-document linking.
98
+ These syntaxes are discussed below.
73
99
 
74
100
  ## Adding Tags to Documentation
75
101
 
@@ -182,7 +208,7 @@ Symbols:
182
208
  We mentioned that these type fields are "mostly" free-form. In truth, they
183
209
  are defined "by convention". To view samples of common type specifications
184
210
  and recommended conventions for writing type specifications, see
185
- [http://yardoc.org/types.html](http://yardoc.org/types.html). Note that these
211
+ [https://yardoc.org/types.html](https://yardoc.org/types.html). Note that these
186
212
  conventions may change every now and then, although we are working on a more
187
213
  "formal" type specification proposal.
188
214
 
@@ -200,7 +226,7 @@ YARD will automatically wire up the correct method types and information
200
226
  by simply defining documentation in the `@return` tag. For example,
201
227
  the following declaration will show the correct information for the
202
228
  `waveform` attribute, both for the getter's return type and the
203
- setter's value parameter type:
229
+ setter's value parameter type:
204
230
 
205
231
  # @return [Numeric] the amplitude of the waveform
206
232
  attr_accessor :amplitude
@@ -248,7 +274,7 @@ The most common is the `attr_accessor` method, which of course has built-in
248
274
  support in YARD. However, frameworks and libraries often expose custom
249
275
  methods that perform similar metaprogramming tasks, and it is often useful
250
276
  to document their functionality in your application. Consider the `property`
251
- method in a project like [DataMapper](http://datamapper.org), which creates
277
+ method in a project like [DataMapper](https://datamapper.org), which creates
252
278
  a typed attribute for a database model. The code might look like:
253
279
 
254
280
  class Post
@@ -386,11 +412,11 @@ If you want to use a Hash, prefix the first { with "!":
386
412
 
387
413
  # !{ :some_key => 'value' }
388
414
 
389
- ### Linking URLs `{http://...}`
415
+ ### Linking URLs `{https://...}`
390
416
 
391
417
  URLs are also linked using this `{...}` syntax:
392
418
 
393
- {http://example.com Optional Title}
419
+ {https://example.com Optional Title}
394
420
  {mailto:email@example.com}
395
421
 
396
422
  ### Linking Files `{file:...}`
@@ -672,8 +698,8 @@ not exist, so you may need to create it.
672
698
  You may find some useful YARD plugins on [RubyGems][RubyGemsQuery] or with
673
699
  a [Google advanced query][GoogleAdvancedQuery].
674
700
 
675
- [graphviz]:http://www.graphviz.org
676
- [yard-rspec]:http://github.com/lsegal/yard-spec-plugin
677
- [rspec]:http://rspec.info
701
+ [graphviz]:https://www.graphviz.org
702
+ [yard-rspec]:https://github.com/lsegal/yard-spec-plugin
703
+ [rspec]:https://rspec.info
678
704
  [GoogleAdvancedQuery]:https://www.google.com/search?q=site%3Arubygems.org+intitle%3A%22yard-%22+OR+intitle%3A%22yard_%22
679
705
  [RubyGemsQuery]:https://rubygems.org/search?utf8=%E2%9C%93&query=name%3A+yard
data/docs/Tags.md CHANGED
@@ -141,7 +141,7 @@ a set of conventions for how to list types is described below.
141
141
 
142
142
  <p class="note">
143
143
  A list of examples of common type listings and what they translate into is
144
- available at <a href="http://yardoc.org/types">http://yardoc.org/types</a>.
144
+ available at <a href="https://yardoc.org/types">https://yardoc.org/types</a>.
145
145
  </p>
146
146
 
147
147
  Typically, a type list contains a list of classes or modules that are associated
@@ -213,9 +213,10 @@ having exactly those 3 elements) would be listed as: `Array(String, Fixnum, Hash
213
213
  Some literals are accepted by virtue of being Ruby literals, but also by YARD
214
214
  conventions. Here is a non-exhaustive list of certain accepted literal values:
215
215
 
216
- * `true`, `false`, `nil` &mdash; used when a method returns these explicit literal
217
- values. Note that if your method returns both `true` or `false`, you should use
218
- the `Boolean` conventional type instead.
216
+ * `true`, `false`, `nil`, `:foo` &mdash; used when a method returns
217
+ these explicit literal values. Note that if your method returns both
218
+ `true` or `false`, you should use the `Boolean` conventional type
219
+ instead.
219
220
  * `self` &mdash; has the same meaning as Ruby's "self" keyword in the context of
220
221
  parameters or return types. Recommended mostly for {tag:return} tags that are
221
222
  chainable.
@@ -280,4 +281,3 @@ Note that you might not need a tag title if you are hiding it. The title
280
281
  part can be omitted.
281
282
 
282
283
  {yard:include_tags}
283
-
data/docs/Templates.md CHANGED
@@ -280,10 +280,11 @@ seen above by creating such a path in our '/path/to/mytemplates' custom template
280
280
  path:
281
281
 
282
282
  /path/to/mytemplates/:
283
- |-- class
284
- | |-- html
285
- | | |-- customsection.erb
286
- | |-- setup.rb
283
+ |--default
284
+ | |-- class
285
+ | | |-- html
286
+ | | | |-- customsection.erb
287
+ | | |-- setup.rb
287
288
 
288
289
  The `setup.rb` file would look like:
289
290
 
data/docs/WhatsNew.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # @title What's New?
2
2
 
3
+ # What's New in 0.9.x?
4
+
5
+ ## Support for Ruby Signature Files (.rbs) (0.9.40)
6
+
7
+ YARD now supports parsing Ruby signature files (.rbs) with full docstring support. This means you can write your documentation in `.rbs` files and have it show up in generated documentation, and use `.rbs` files alongside `.rb` sources to supplement type and API information.
8
+
9
+ ## New built-in Markdown renderer (0.9.40)
10
+
11
+ YARD now ships with a built-in Markdown renderer (`YARD::Templates::Helpers::Markup::HybridMarkdown`)
12
+ that requires **no external gems**. It supports a practical subset of GitHub Flavored Markdown (GFM)
13
+ as well as common RDoc markup forms, including:
14
+
15
+ - Headings (`#`, `=`)
16
+ - Fenced code blocks (`` ``` `` and `~~~`) as well as RDoc formatted `+text+` blocks.
17
+ - Tables, blockquotes, and thematic breaks
18
+ - Ordered and unordered lists (including RDoc-style)
19
+ - Inline emphasis, code, links, and images
20
+ - HTML passthrough blocks
21
+
22
+ This renderer is the **default** for both the `rdoc` and `markdown` markup types—no gem
23
+ installation required. If an optional provider gem (e.g. `redcarpet`, `kramdown`,
24
+ `commonmarker`) is installed and selected, YARD will use it instead for extra features such
25
+ as custom extensions or stricter spec compliance.
26
+
27
+ ## `#-` comment block separators (0.9.40)
28
+
29
+ YARD now recognizes a trailing `#-` line as a separator between comment
30
+ blocks. This is useful when you want to keep a file header comment at the top
31
+ of a Ruby file without having that header attach itself to the first class,
32
+ module or method in the file.
33
+
34
+ For example:
35
+
36
+ # Copyright (c) Example Corp
37
+ # This file defines support code shared by the client.
38
+ #-
39
+
40
+ class Client
41
+ end
42
+
43
+ In the example above, the file header stays disconnected from `Client`.
44
+ Note that `# -` does **not** act as a separator; only an attached `#-`
45
+ line has this behavior.
46
+
47
+ ## Ruby 4.x support (0.9.39)
48
+
49
+ Added support for Ruby 4.x along with new syntaxes.
50
+
51
+ ## Other changes
52
+
53
+ See the [CHANGELOG](CHANGELOG.md) for a full list of changes in 0.9.x.
54
+
3
55
  # What's New in 0.8.x?
4
56
 
5
57
  1. **Directives (new behavioural tag syntax)** (0.8.0)
@@ -171,7 +223,7 @@ only mixins inside of a "Foo::Bar" namespace by doing:
171
223
  YARD now ships with the beginnings of internationalization support
172
224
  for translating documentation into multiple languages. The
173
225
  `yard i18n` command now allows you to generate ".pot" and ultimately
174
- ".po" files for translation with [gettext](http://www.gnu.org/software/gettext).
226
+ ".po" files for translation with [gettext](https://www.gnu.org/software/gettext).
175
227
 
176
228
  Note that this tool is a small step in the larger transition for
177
229
  proper I18n support in YARD. We still have to add proper gettext
@@ -283,7 +335,7 @@ above example would be:
283
335
  But note that `--query` does not work when YARD is in "safe mode"
284
336
  due to security concerns, whereas `--api` works in either mode.
285
337
  This enables `--api` to function on remote documentation sites like
286
- [rubydoc.info](http://rubydoc.info).
338
+ [rubydoc.info](https://rubydoc.info).
287
339
 
288
340
  ## Added `--non-transitive-tag` to disable transitive tag (0.8.3)
289
341
 
@@ -307,7 +359,7 @@ with `yard server -B PORT` or `yard server --bind PORT`.
307
359
 
308
360
  Support for the AsciiDoc markup type is now introduced using the `asciidoc`
309
361
  markup type (`yard doc -m asciidoc`). Requires the
310
- [asciidoctor](http://rubygems.org/gems/asciidoctor) RubyGem library to be
362
+ [asciidoctor](https://rubygems.org/gems/asciidoctor) RubyGem library to be
311
363
  installed before running YARD.
312
364
 
313
365
  ## Added `yard markups` command to list available markup types (0.8.6)
@@ -645,7 +697,7 @@ templates. To serve documentation for installed gems:
645
697
  will do this for you on-the-fly. It is therefore possible to speed up your
646
698
  gem installs by using `gem install GEMNAME --no-rdoc` without repercussion.
647
699
  You can also add this switch to your `~/.gemrc` file so that you don't need
648
- to re-type it each time. See [this link](http://stackoverflow.com/questions/1789376/how-do-i-make-no-ri-no-rdoc-the-default-for-gem-install)
700
+ to re-type it each time. See [this link](https://stackoverflow.com/questions/1789376/how-do-i-make-no-ri-no-rdoc-the-default-for-gem-install)
649
701
  for exact instructions.</span>
650
702
 
651
703
  ## Groups support for method listing (0.6.0)
@@ -718,7 +770,7 @@ regular diffing tells you which lines have been added/removed in a file,
718
770
  object diffing allows you to see what classes/methods/modules have been
719
771
  added/removed between versions of a codebase.
720
772
 
721
- For an overview of how to use `yard diff`, see [YARD Object Oriented Diffing](http://gnuu.org/2010/06/26/yard-object-oriented-diffing/).
773
+ For an overview of how to use `yard diff`, see [YARD Object Oriented Diffing](https://gnuu.org/2010/06/26/yard-object-oriented-diffing/).
722
774
 
723
775
  ## `yard stats` to display statistics and undocumented objects (0.6.0)
724
776
 
@@ -902,7 +954,7 @@ Support for documenting native Ruby C code (0.5.0)
902
954
 
903
955
  It is now possible to document native Ruby extensions with YARD with a new
904
956
  C parser mostly borrowed from RDoc. This enables the ability to document
905
- Ruby's core and stdlibs which will be hosted on http://yardoc.org/docs. In
957
+ Ruby's core and stdlibs which will be hosted on https://yardoc.org/docs. In
906
958
  addition, the .yardoc dump for the Ruby-core classes will become available
907
959
  as an installable gem for yri support (see #3).
908
960
 
@@ -1144,7 +1196,7 @@ Default rake task is now `rake yard`
1144
1196
  Not a big change, but anyone using the default "rake yardoc" task should
1145
1197
  update their scripts:
1146
1198
 
1147
- [http://github.com/lsegal/yard/commit/ad38a68dd73898b06bd5d0a1912b7d815878fae0](http://github.com/lsegal/yard/commit/ad38a68dd73898b06bd5d0a1912b7d815878fae0)
1199
+ [https://github.com/lsegal/yard/commit/ad38a68dd73898b06bd5d0a1912b7d815878fae0](https://github.com/lsegal/yard/commit/ad38a68dd73898b06bd5d0a1912b7d815878fae0)
1148
1200
 
1149
1201
 
1150
1202
  What's New in 0.2.3.x?
@@ -22,5 +22,5 @@ def tag_signature(tag)
22
22
  else
23
23
  "description"
24
24
  end
25
- signature + h(extra).gsub(/\n/, "<br/>&nbsp;&nbsp;&nbsp;")
25
+ signature + h(extra).gsub(/\n/, "<br>&nbsp;&nbsp;&nbsp;")
26
26
  end
data/lib/yard/autoload.rb CHANGED
@@ -69,6 +69,16 @@ module YARD
69
69
  autoload :MethodHandler, __p('handlers/common/method_handler')
70
70
  end
71
71
 
72
+ # RBS type signature handlers
73
+ module RBS
74
+ autoload :Base, __p('handlers/rbs/base')
75
+ autoload :AttributeHandler, __p('handlers/rbs/attribute_handler')
76
+ autoload :ConstantHandler, __p('handlers/rbs/constant_handler')
77
+ autoload :MethodHandler, __p('handlers/rbs/method_handler')
78
+ autoload :MixinHandler, __p('handlers/rbs/mixin_handler')
79
+ autoload :NamespaceHandler, __p('handlers/rbs/namespace_handler')
80
+ end
81
+
72
82
  # CRuby Handlers
73
83
  # @since 0.8.0
74
84
  module C
@@ -183,6 +193,12 @@ module YARD
183
193
  autoload :TokenResolver, __p('parser/ruby/token_resolver')
184
194
  end
185
195
 
196
+ # RBS type signature parser
197
+ module RBS
198
+ autoload :RbsParser, __p('parser/rbs/rbs_parser')
199
+ autoload :Statement, __p('parser/rbs/statement')
200
+ end
201
+
186
202
  autoload :Base, __p('parser/base')
187
203
  autoload :ParserSyntaxError, __p('parser/source_parser')
188
204
  autoload :SourceParser, __p('parser/source_parser')
@@ -271,6 +287,7 @@ module YARD
271
287
  module Templates
272
288
  module Helpers # Namespace for template helpers
273
289
  module Markup # Namespace for markup providers
290
+ autoload :HybridMarkdown, __p('templates/helpers/markup/hybrid_markdown')
274
291
  autoload :RDocMarkup, __p('templates/helpers/markup/rdoc_markup')
275
292
  autoload :RDocMarkdown, __p('templates/helpers/markup/rdoc_markdown')
276
293
  end
data/lib/yard/cli/diff.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  require 'tmpdir'
3
3
  require 'fileutils'
4
4
  require 'open-uri'
5
+ require 'open3'
5
6
 
6
7
  module YARD
7
8
  module CLI
@@ -108,7 +109,11 @@ module YARD
108
109
  FileUtils.mkdir_p(tmpdir)
109
110
  FileUtils.cp_r('.', tmpdir)
110
111
  Dir.chdir(tmpdir)
111
- log.info("git says: " + `git reset --hard #{commit}`.chomp)
112
+ out, status = Open3.capture2e('git', 'reset', '--hard', commit)
113
+ log.info("git says: " + out.chomp)
114
+ unless status.success?
115
+ raise "git reset --hard #{commit.inspect} failed with exit status #{status.exitstatus}: #{out}"
116
+ end
112
117
  generate_yardoc(tmpdir)
113
118
  ensure
114
119
  Dir.chdir(@old_path)
@@ -158,7 +163,7 @@ module YARD
158
163
  end
159
164
 
160
165
  # Remote gemfile from rubygems.org
161
- url = "http://rubygems.org/downloads/#{gemfile}"
166
+ url = "https://rubygems.org/downloads/#{gemfile}"
162
167
  log.info "Searching for remote gem file #{url}"
163
168
  begin
164
169
  # Note: In Ruby 2.4.x, URI.open is a private method. After
@@ -228,7 +228,7 @@ module YARD
228
228
  # @example Create class Z inside namespace X::Y
229
229
  # CodeObjects::Base.new(P("X::Y"), :Z) # or
230
230
  # CodeObjects::Base.new(Registry.root, "X::Y")
231
- # @param [NamespaceObject] namespace the namespace the object belongs in,
231
+ # @param [NamespaceObject, :root, nil] namespace the namespace the object belongs in,
232
232
  # {Registry.root} or :root should be provided if it is associated with
233
233
  # the top level namespace.
234
234
  # @param [Symbol, String] name the name (or complex path) of the object.
@@ -127,6 +127,7 @@ module YARD::CodeObjects
127
127
  end
128
128
 
129
129
  def translate(data)
130
+ return data if locale.nil?
130
131
  text = YARD::I18n::Text.new(data, :have_header => true)
131
132
  text.translate(YARD::Registry.locale(locale))
132
133
  end
@@ -201,7 +201,7 @@ module YARD
201
201
 
202
202
  private
203
203
 
204
- # @note this method fixes a bug in 1.9.2: http://gist.github.com/437136
204
+ # @note this method fixes a bug in 1.9.2: https://gist.github.com/437136
205
205
  def to_ary; nil end
206
206
 
207
207
  # Attempts to find the object that this unresolved object
@@ -462,6 +462,18 @@ module YARD
462
462
  end
463
463
  end
464
464
 
465
+ if docstring.is_a?(String)
466
+ if (m = docstring.match(/^\s*@!?visibility\s+(public|private|protected)\b/m))
467
+ vis_sym = m[1].to_sym
468
+
469
+ if object.nil?
470
+ globals.visibility_origin = :directive
471
+ elsif object.is_a?(CodeObjects::MethodObject)
472
+ object.visibility = vis_sym
473
+ end
474
+ end
475
+ end
476
+
465
477
  register_transitive_tags(object)
466
478
  end
467
479
 
@@ -511,7 +523,17 @@ module YARD
511
523
  def register_visibility(object, visibility = self.visibility)
512
524
  return unless object.respond_to?(:visibility=)
513
525
  return if object.is_a?(NamespaceObject)
514
- object.visibility = visibility
526
+
527
+ if object.is_a?(CodeObjects::MethodObject)
528
+ origin = globals.visibility_origin
529
+ if origin == :keyword
530
+ object.visibility = visibility if object.scope == scope
531
+ else
532
+ object.visibility = visibility
533
+ end
534
+ else
535
+ object.visibility = visibility
536
+ end
515
537
  end
516
538
 
517
539
  # Registers the same method information on the module function, if
@@ -35,6 +35,7 @@ module YARD
35
35
  register_handler_namespace :ruby, Ruby
36
36
  register_handler_namespace :ruby18, Ruby::Legacy
37
37
  register_handler_namespace :c, C
38
+ register_handler_namespace :rbs, RBS
38
39
 
39
40
  # @return [String] the filename
40
41
  attr_accessor :file