yard 0.9.36 → 0.9.40

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 (81) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +59 -1
  3. data/README.md +29 -25
  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 +18 -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/macro_object.rb +0 -1
  14. data/lib/yard/code_objects/proxy.rb +1 -1
  15. data/lib/yard/docstring_parser.rb +0 -1
  16. data/lib/yard/handlers/base.rb +23 -1
  17. data/lib/yard/handlers/processor.rb +1 -1
  18. data/lib/yard/handlers/rbs/attribute_handler.rb +43 -0
  19. data/lib/yard/handlers/rbs/base.rb +38 -0
  20. data/lib/yard/handlers/rbs/constant_handler.rb +18 -0
  21. data/lib/yard/handlers/rbs/method_handler.rb +327 -0
  22. data/lib/yard/handlers/rbs/mixin_handler.rb +20 -0
  23. data/lib/yard/handlers/rbs/namespace_handler.rb +26 -0
  24. data/lib/yard/handlers/ruby/attribute_handler.rb +7 -4
  25. data/lib/yard/handlers/ruby/constant_handler.rb +24 -6
  26. data/lib/yard/handlers/ruby/legacy/visibility_handler.rb +2 -1
  27. data/lib/yard/handlers/ruby/visibility_handler.rb +14 -1
  28. data/lib/yard/i18n/locale.rb +1 -1
  29. data/lib/yard/i18n/pot_generator.rb +1 -1
  30. data/lib/yard/logging.rb +116 -61
  31. data/lib/yard/open_struct.rb +67 -0
  32. data/lib/yard/parser/rbs/rbs_parser.rb +325 -0
  33. data/lib/yard/parser/rbs/statement.rb +75 -0
  34. data/lib/yard/parser/ruby/ast_node.rb +5 -4
  35. data/lib/yard/parser/ruby/legacy/irb/slex.rb +19 -1
  36. data/lib/yard/parser/ruby/legacy/ruby_lex.rb +20 -5
  37. data/lib/yard/parser/ruby/ruby_parser.rb +109 -24
  38. data/lib/yard/parser/source_parser.rb +5 -4
  39. data/lib/yard/registry_resolver.rb +7 -0
  40. data/lib/yard/rubygems/specification.rb +1 -1
  41. data/lib/yard/server/library_version.rb +1 -1
  42. data/lib/yard/server/templates/default/fulldoc/html/js/autocomplete.js +208 -12
  43. data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +1 -17
  44. data/lib/yard/server/templates/default/method_details/html/permalink.erb +4 -2
  45. data/lib/yard/server/templates/doc_server/library_list/html/headers.erb +3 -3
  46. data/lib/yard/server/templates/doc_server/library_list/html/library_list.erb +2 -3
  47. data/lib/yard/server/templates/doc_server/processing/html/processing.erb +22 -16
  48. data/lib/yard/tags/default_factory.rb +1 -0
  49. data/lib/yard/tags/directives.rb +7 -1
  50. data/lib/yard/tags/library.rb +3 -3
  51. data/lib/yard/tags/overload_tag.rb +2 -1
  52. data/lib/yard/tags/tag.rb +2 -1
  53. data/lib/yard/tags/types_explainer.rb +5 -4
  54. data/lib/yard/templates/engine.rb +0 -1
  55. data/lib/yard/templates/helpers/base_helper.rb +1 -1
  56. data/lib/yard/templates/helpers/html_helper.rb +21 -6
  57. data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +6 -1
  58. data/lib/yard/templates/helpers/markup/hybrid_markdown.rb +2125 -0
  59. data/lib/yard/templates/helpers/markup/rdoc_markup.rb +2 -0
  60. data/lib/yard/templates/helpers/markup_helper.rb +4 -2
  61. data/lib/yard/templates/template_options.rb +0 -1
  62. data/lib/yard/version.rb +1 -1
  63. data/po/ja.po +82 -82
  64. data/templates/default/fulldoc/html/css/full_list.css +3 -3
  65. data/templates/default/fulldoc/html/css/style.css +8 -15
  66. data/templates/default/fulldoc/html/full_list.erb +8 -5
  67. data/templates/default/fulldoc/html/js/app.js +546 -281
  68. data/templates/default/fulldoc/html/js/full_list.js +315 -189
  69. data/templates/default/fulldoc/html/setup.rb +10 -2
  70. data/templates/default/layout/html/headers.erb +1 -1
  71. data/templates/default/method/html/header.erb +3 -3
  72. data/templates/default/module/html/defines.erb +3 -3
  73. data/templates/default/module/html/inherited_methods.erb +1 -0
  74. data/templates/default/module/html/method_summary.erb +8 -0
  75. data/templates/default/module/setup.rb +20 -0
  76. data/templates/default/onefile/html/headers.erb +2 -0
  77. data/templates/default/onefile/html/layout.erb +3 -4
  78. data/templates/default/tags/html/example.erb +2 -2
  79. data/templates/guide/fulldoc/html/js/app.js +57 -26
  80. data/templates/guide/layout/html/layout.erb +9 -11
  81. metadata +19 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1f492861606b6ce24d390317f2a97ccbd67bbf73b8b964ea6f9e61bb4096d9e
4
- data.tar.gz: 1a4ec96bd604c8ab68cf6c971fc22aff400f2d8ed853d3b0b5fc222f4c8e7767
3
+ metadata.gz: f30a7254915dfc58291d8bdbf05f6e65bbb392d9c359bb0df535c5d290dbf2f8
4
+ data.tar.gz: bd261832603492535a89218415f59c84c3e5c732dd8a0cc25f5a294a0b2c98a5
5
5
  SHA512:
6
- metadata.gz: 04b727cb198fd9559a9314989fae7bcf60202531f5ab634d211780b5bbf15b60341d8a8f5fa6fd890c743c7d1b953e7b49d3c8e73997f3397b7344a70442fd29
7
- data.tar.gz: c3df5e59c450adfc6d6088bd7c6a6c64f4477c1de65eae7cbd21e1c4ca410d606179bc88c84ed084b22d7b3f8bf66cc67426e9c103558b0a25c5ab01c1900ab9
6
+ metadata.gz: 132b2b6ea721780a3f36001216fa16aade784e2936d89684249f92c3ddd2180f2820e24c339551ce33405779c627b82bb085978b6f3a785b1450f17204b00d88
7
+ data.tar.gz: e4410e47b0b7871241611b3328fa2e5219ba5632c4648e3d4f3d5ac66bf54986ac046bae935bc68911d905210159cc1dc70ca6aba0870056aef9ba36f70dbae3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,63 @@
1
1
  # main
2
2
 
3
+ # [0.9.40] - April 12th, 2026
4
+
5
+ [0.9.40]: https://github.com/lsegal/yard/compare/v0.9.39...v0.9.40
6
+
7
+ - Add support for Ruby .rbs files (docstrings included) (#1673)
8
+ - Add built-in hybrid RDoc/Markdown renderer (`HybridMarkdown`) requiring no external gems (#1674)
9
+ - Add support for `#-` as a comment-block separator. See Getting Started Guide.
10
+ - Add support for `commonmarker` version `>= 1.0`.
11
+ - Remove usage of jQuery in default templates. jQuery library is still packaged in templates for backward compatibility (#1675)
12
+ - Fix false self-referential mixin when bare name matches ancestor namespace (#1672)
13
+ - Fix bracket/brace map corruption from Ruby 3.0+ pattern matching deconstruction (#1671)
14
+ - Fix `@!scope class` on attributes (#1582, #1655, #1666)
15
+ - Fix `@!parse` directives not including source for block (#1665)
16
+ - Fix inherited methods not appearing in groups (#1656)
17
+
18
+ # [0.9.39] - April 8th, 2026
19
+
20
+ [0.9.39]: https://github.com/lsegal/yard/compare/v0.9.38...v0.9.39
21
+
22
+ - Add support for Ruby 4.0 (#1663)
23
+ - Add changelog URI to gemspec metadata (#1641)
24
+ - Fix issues with source ranges (#1642)
25
+ - Fix an issue loading relative links from file list in HTML template (#1660)
26
+ - Various test fixes (#1650, #1651)
27
+
28
+
29
+ # [0.9.38] - December 5th, 2025
30
+
31
+ [0.9.38]: https://github.com/lsegal/yard/compare/v0.9.37...v0.9.38
32
+
33
+ - Add support for complex constant assignment (#1599)
34
+ - Add support for Data type structs (#1600)
35
+ - Support multi method duck type syntax in type explainer (#1631)
36
+ - Improve Ruby 3.5 compatibility (#1616)
37
+ - Update documentation for various type annotations (#1615)
38
+ - JavaScript frontend updates (resizer, JS bugs, reduce console verbosity) for default template
39
+ - Fix beginless/endless range errors (#1549, #1625)
40
+ - Fix path structure in Templates.md documentation (#1588)
41
+ - Fix signature handling in overload (#1590)
42
+ - Fix handling of **nil with named block (#1623)
43
+ - Fix directives in empty class bodies (#1624)
44
+ - Fix parsing of array within array syntax (#1604)
45
+ - Fix parsing of visibility keywords in front of class methods (#1632)
46
+
47
+ # [0.9.37] - September 4th, 2024
48
+
49
+ [0.9.37]: https://github.com/lsegal/yard/compare/v0.9.36...v0.9.37
50
+
51
+ - Fix JavaScript errors in `--one-file` template (#1426)
52
+ - Fix heredoc parsing and add support for squiggly heredocs (#1315, #1495)
53
+ - Accessibility improvements to the default template (#1501)
54
+ - Improved YARD documentation (#1410, #1512, #1516, #1544)
55
+ - Fix error when parsing `@option` tags (#1515)
56
+ - Fix issue parsing UTF-8 filenames (#1517)
57
+ - Replace OpenStruct with optimized YARD::OpenStruct to avoid ostruct performance warnings (#1545)
58
+ - Add support for `private attr_*` syntax (#1541)
59
+ - Remove logger dependency (#1546)
60
+
3
61
  # [0.9.36] - February 29th, 2024
4
62
 
5
63
  [0.9.36]: https://github.com/lsegal/yard/compare/v0.9.35...v0.9.36
@@ -815,7 +873,7 @@ contributions to this version.
815
873
 
816
874
  [0.4.0]: https://github.com/lsegal/yard/compare/v0.2.3.5...v0.4.0
817
875
 
818
- - Added new templating engine based on [tadpole](http://github.com/lsegal/tadpole)
876
+ - Added new templating engine based on [tadpole](https://github.com/lsegal/tadpole)
819
877
  - Added YARD queries (`--query` CLI argument to yardoc)
820
878
  - Greatly expanded YARD documentation
821
879
  - 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,20 +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
- ```
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.
123
+
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`).
124
128
 
125
129
  ## Usage
126
130
 
127
131
  There are a couple of ways to use YARD. The first is via command-line, and the
128
132
  second is the Rake task.
129
133
 
130
- **1. yard Command-line Tool**
134
+ ### 1. yard Command-line Tool
131
135
 
132
136
  YARD comes packaged with a executable named `yard` which can control the many
133
137
  functions of YARD, including generating documentation, graphs running the YARD
@@ -140,7 +144,7 @@ $ yard --help
140
144
  Plugins can also add commands to the `yard` executable to provide extra
141
145
  functionality.
142
146
 
143
- ### Generating Documentation
147
+ #### Generating Documentation
144
148
 
145
149
  <span class="note">The `yardoc` executable is a shortcut for `yard doc`.</span>
146
150
 
@@ -185,9 +189,9 @@ Note that the README file can be specified with its own `--readme` switch.
185
189
  You can also add a `.yardopts` file to your project directory which lists the
186
190
  switches separated by whitespace (newlines or space) to pass to yardoc whenever
187
191
  it is run. A full overview of the `.yardopts` file can be found in
188
- {YARD::CLI::Yardoc}.
192
+ [YARD::CLI::Yardoc](https://rubydoc.info/gems/yard/YARD/CLI/Yardoc#label-Options+File+-28.yardopts-29).
189
193
 
190
- ### Queries
194
+ #### Queries
191
195
 
192
196
  The `yardoc` tool also supports a `--query` argument to only include objects
193
197
  that match a certain data or meta-data query. The query syntax is Ruby, though a
@@ -214,7 +218,7 @@ following two lines both check for the existence of a return and param tag:
214
218
 
215
219
  For more information about the query syntax, see the {YARD::Verifier} class.
216
220
 
217
- **2. Rake Task**
221
+ ### 2. Rake Task
218
222
 
219
223
  The second most obvious is to generate docs via a Rake task. You can do this by
220
224
  adding the following to your `Rakefile`:
@@ -240,7 +244,7 @@ environment variable:
240
244
  $ rake yard OPTS='--any --extra --opts'
241
245
  ```
242
246
 
243
- **3. `yri` RI Implementation**
247
+ ### 3. `yri` RI Implementation
244
248
 
245
249
  The yri binary will use the cached .yardoc database to give you quick ri-style
246
250
  access to your documentation. It's way faster than ri but currently does not
@@ -264,7 +268,7 @@ $ yard gems
264
268
  If you don't have sudo access, it will write these files to your `~/.yard`
265
269
  directory. `yri` will also cache lookups there.
266
270
 
267
- **4. `yard server` Documentation Server**
271
+ ### 4. `yard server` Documentation Server
268
272
 
269
273
  The `yard server` command serves documentation for a local project or all
270
274
  installed RubyGems. To serve documentation for a project you are working on,
@@ -278,14 +282,14 @@ And the project inside the current directory will be parsed (if the source has
278
282
  not yet been scanned by YARD) and served at
279
283
  [http://localhost:8808](http://localhost:8808).
280
284
 
281
- ### Live Reloading
285
+ #### Live Reloading
282
286
 
283
287
  If you want to serve documentation on a project while you document it so that
284
288
  you can preview the results, simply pass `--reload` (`-r`) to the above command
285
289
  and YARD will reload any changed files on each request. This will allow you to
286
290
  change any documentation in the source and refresh to see the new contents.
287
291
 
288
- ### Serving Gems
292
+ #### Serving Gems
289
293
 
290
294
  To serve documentation for all installed gems, call:
291
295
 
@@ -297,10 +301,10 @@ This will also automatically build documentation for any gems that have not been
297
301
  previously scanned. Note that in this case there will be a slight delay between
298
302
  the first request of a newly parsed gem.
299
303
 
300
- **5. `yard graph` Graphviz Generator**
304
+ ### 5. `yard graph` Graphviz Generator
301
305
 
302
306
  You can use `yard graph` to generate dot graphs of your code. This, of course,
303
- 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
304
308
  this will generate a graph of the classes and modules in the best UML2 notation
305
309
  that Graphviz can support, but without any methods listed. With the `--full`
306
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
@@ -298,6 +315,7 @@ module YARD
298
315
  autoload :DocstringParser, __p('docstring_parser')
299
316
  autoload :GemIndex, __p('gem_index')
300
317
  autoload :Logger, __p('logging')
318
+ autoload :OpenStruct, __p('open_struct')
301
319
  autoload :Options, __p('options')
302
320
  autoload :Registry, __p('registry')
303
321
  autoload :RegistryResolver, __p('registry_resolver')
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
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require 'ostruct'
3
2
 
4
3
  module YARD
5
4
  module CodeObjects
@@ -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
@@ -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
@@ -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