yard 0.9.36 → 0.9.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +82 -1
- data/README.md +29 -25
- data/docs/GettingStarted.md +41 -15
- data/docs/Parser.md +17 -42
- data/docs/Tags.md +5 -5
- data/docs/Templates.md +5 -4
- data/docs/WhatsNew.md +59 -7
- data/docs/templates/default/yard_tags/html/setup.rb +1 -1
- data/lib/yard/autoload.rb +18 -0
- data/lib/yard/cli/diff.rb +7 -2
- data/lib/yard/code_objects/base.rb +1 -1
- data/lib/yard/code_objects/extra_file_object.rb +1 -0
- data/lib/yard/code_objects/macro_object.rb +0 -1
- data/lib/yard/code_objects/proxy.rb +1 -1
- data/lib/yard/docstring_parser.rb +0 -1
- data/lib/yard/handlers/base.rb +23 -1
- data/lib/yard/handlers/processor.rb +1 -1
- data/lib/yard/handlers/rbs/attribute_handler.rb +79 -0
- data/lib/yard/handlers/rbs/base.rb +38 -0
- data/lib/yard/handlers/rbs/constant_handler.rb +18 -0
- data/lib/yard/handlers/rbs/method_handler.rb +327 -0
- data/lib/yard/handlers/rbs/mixin_handler.rb +20 -0
- data/lib/yard/handlers/rbs/namespace_handler.rb +26 -0
- data/lib/yard/handlers/ruby/attribute_handler.rb +7 -4
- data/lib/yard/handlers/ruby/constant_handler.rb +24 -6
- data/lib/yard/handlers/ruby/legacy/visibility_handler.rb +2 -1
- data/lib/yard/handlers/ruby/visibility_handler.rb +14 -1
- data/lib/yard/i18n/locale.rb +1 -1
- data/lib/yard/i18n/pot_generator.rb +1 -1
- data/lib/yard/logging.rb +116 -61
- data/lib/yard/open_struct.rb +67 -0
- data/lib/yard/parser/rbs/rbs_parser.rb +325 -0
- data/lib/yard/parser/rbs/statement.rb +75 -0
- data/lib/yard/parser/ruby/ast_node.rb +5 -4
- data/lib/yard/parser/ruby/legacy/irb/slex.rb +19 -1
- data/lib/yard/parser/ruby/legacy/ruby_lex.rb +20 -5
- data/lib/yard/parser/ruby/ruby_parser.rb +109 -24
- data/lib/yard/parser/source_parser.rb +5 -4
- data/lib/yard/registry_resolver.rb +7 -0
- data/lib/yard/rubygems/specification.rb +1 -1
- data/lib/yard/server/commands/base.rb +1 -1
- data/lib/yard/server/library_version.rb +1 -1
- data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +168 -88
- data/lib/yard/server/templates/default/fulldoc/html/js/autocomplete.js +203 -12
- data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +1 -17
- data/lib/yard/server/templates/default/method_details/html/permalink.erb +4 -2
- data/lib/yard/server/templates/doc_server/library_list/html/headers.erb +3 -3
- data/lib/yard/server/templates/doc_server/library_list/html/library_list.erb +2 -3
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +22 -16
- data/lib/yard/tags/default_factory.rb +1 -0
- data/lib/yard/tags/directives.rb +7 -1
- data/lib/yard/tags/library.rb +3 -3
- data/lib/yard/tags/overload_tag.rb +2 -1
- data/lib/yard/tags/tag.rb +2 -1
- data/lib/yard/tags/types_explainer.rb +5 -4
- data/lib/yard/templates/engine.rb +0 -1
- data/lib/yard/templates/helpers/base_helper.rb +1 -1
- data/lib/yard/templates/helpers/html_helper.rb +21 -6
- data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +6 -1
- data/lib/yard/templates/helpers/markup/hybrid_markdown.rb +2147 -0
- data/lib/yard/templates/helpers/markup/rdoc_markup.rb +2 -0
- data/lib/yard/templates/helpers/markup_helper.rb +4 -2
- data/lib/yard/templates/template_options.rb +0 -1
- data/lib/yard/version.rb +1 -1
- data/po/ja.po +82 -82
- data/templates/default/fulldoc/html/css/common.css +1 -1
- data/templates/default/fulldoc/html/css/full_list.css +201 -53
- data/templates/default/fulldoc/html/css/style.css +991 -399
- data/templates/default/fulldoc/html/full_list.erb +8 -5
- data/templates/default/fulldoc/html/js/app.js +799 -312
- data/templates/default/fulldoc/html/js/full_list.js +332 -214
- data/templates/default/fulldoc/html/setup.rb +10 -2
- data/templates/default/layout/html/headers.erb +1 -1
- data/templates/default/layout/html/layout.erb +3 -1
- data/templates/default/method/html/header.erb +3 -3
- data/templates/default/module/html/defines.erb +3 -3
- data/templates/default/module/html/inherited_methods.erb +1 -0
- data/templates/default/module/html/method_summary.erb +8 -0
- data/templates/default/module/setup.rb +20 -0
- data/templates/default/onefile/html/headers.erb +2 -0
- data/templates/default/onefile/html/layout.erb +3 -4
- data/templates/default/tags/html/example.erb +2 -2
- data/templates/guide/fulldoc/html/css/style.css +347 -97
- data/templates/guide/fulldoc/html/js/app.js +61 -33
- data/templates/guide/layout/html/layout.erb +69 -72
- metadata +19 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 92d411c4d39cc74df916cbac8719ebd7ac6ed1fb17b37022148f584440bda554
|
|
4
|
+
data.tar.gz: 9582c48d6c1949c055e22035f325abc957ec31900613f5b04307f7f27fc011a4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d566d6989e868b3bc4959037309c9c07a89608f07a39ad2719ead8765fca6ab3ae6240bfe7d56394ad47c8d75c5999d02313f6f7eaedb056a2ea584750d15cc1
|
|
7
|
+
data.tar.gz: 641e462842732b47a67ff95eda6cfdb0373de7b2f487ceb7aa827815c0f8201fa55639979f7df17ec4d12864de60c4cc631fc7921cc787b20a04f5493cd86033
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,86 @@
|
|
|
1
1
|
# main
|
|
2
2
|
|
|
3
|
+
# [0.9.43] - April 17th, 2026
|
|
4
|
+
|
|
5
|
+
[0.9.43]: https://github.com/lsegal/yard/compare/v0.9.42...v0.9.43
|
|
6
|
+
|
|
7
|
+
- Fix attribute registration in .rbs files (#1583)
|
|
8
|
+
|
|
9
|
+
# [0.9.42] - April 16th, 2026
|
|
10
|
+
|
|
11
|
+
[0.9.42]: https://github.com/lsegal/yard/compare/v0.9.41...v0.9.42
|
|
12
|
+
|
|
13
|
+
- Fix alternating rows when loading a module in default HTML templates with subelements in the nav frame
|
|
14
|
+
- Fix reliability of keypresses and copy/paste in search box (#1174)
|
|
15
|
+
- Fix regression in `yard server` search box styling
|
|
16
|
+
- Fix possible path traversal with document_root (`--docroot`) set in `yard server` ([GHSA-xfhh-rx56-rxcr](https://github.com/lsegal/yard/security/advisories/GHSA-xfhh-rx56-rxcr))
|
|
17
|
+
|
|
18
|
+
# [0.9.41] - April 14th, 2026
|
|
19
|
+
|
|
20
|
+
[0.9.41]: https://github.com/lsegal/yard/compare/v0.9.40...v0.9.41
|
|
21
|
+
|
|
22
|
+
- Add support for `rdoc-image:...` syntax in HybridMarkup (#1676)
|
|
23
|
+
- Add support for colon suffix code blocks in HybridMarkup (rdoc compatibility)
|
|
24
|
+
- Fix responsiveness and state issues with nav frame links in `yard server`
|
|
25
|
+
|
|
26
|
+
# [0.9.40] - April 12th, 2026
|
|
27
|
+
|
|
28
|
+
[0.9.40]: https://github.com/lsegal/yard/compare/v0.9.39...v0.9.40
|
|
29
|
+
|
|
30
|
+
- Add support for Ruby .rbs files (docstrings included) (#1673)
|
|
31
|
+
- Add built-in hybrid RDoc/Markdown renderer (`HybridMarkdown`) requiring no external gems (#1674)
|
|
32
|
+
- Add support for `#-` as a comment-block separator. See Getting Started Guide.
|
|
33
|
+
- Add support for `commonmarker` version `>= 1.0`.
|
|
34
|
+
- Remove usage of jQuery in default templates. jQuery library is still packaged in templates for backward compatibility (#1675)
|
|
35
|
+
- Fix false self-referential mixin when bare name matches ancestor namespace (#1672)
|
|
36
|
+
- Fix bracket/brace map corruption from Ruby 3.0+ pattern matching deconstruction (#1671)
|
|
37
|
+
- Fix `@!scope class` on attributes (#1582, #1655, #1666)
|
|
38
|
+
- Fix `@!parse` directives not including source for block (#1665)
|
|
39
|
+
- Fix inherited methods not appearing in groups (#1656)
|
|
40
|
+
|
|
41
|
+
# [0.9.39] - April 8th, 2026
|
|
42
|
+
|
|
43
|
+
[0.9.39]: https://github.com/lsegal/yard/compare/v0.9.38...v0.9.39
|
|
44
|
+
|
|
45
|
+
- Add support for Ruby 4.0 (#1663)
|
|
46
|
+
- Add changelog URI to gemspec metadata (#1641)
|
|
47
|
+
- Fix issues with source ranges (#1642)
|
|
48
|
+
- Fix an issue loading relative links from file list in HTML template (#1660)
|
|
49
|
+
- Various test fixes (#1650, #1651)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
# [0.9.38] - December 5th, 2025
|
|
53
|
+
|
|
54
|
+
[0.9.38]: https://github.com/lsegal/yard/compare/v0.9.37...v0.9.38
|
|
55
|
+
|
|
56
|
+
- Add support for complex constant assignment (#1599)
|
|
57
|
+
- Add support for Data type structs (#1600)
|
|
58
|
+
- Support multi method duck type syntax in type explainer (#1631)
|
|
59
|
+
- Improve Ruby 3.5 compatibility (#1616)
|
|
60
|
+
- Update documentation for various type annotations (#1615)
|
|
61
|
+
- JavaScript frontend updates (resizer, JS bugs, reduce console verbosity) for default template
|
|
62
|
+
- Fix beginless/endless range errors (#1549, #1625)
|
|
63
|
+
- Fix path structure in Templates.md documentation (#1588)
|
|
64
|
+
- Fix signature handling in overload (#1590)
|
|
65
|
+
- Fix handling of **nil with named block (#1623)
|
|
66
|
+
- Fix directives in empty class bodies (#1624)
|
|
67
|
+
- Fix parsing of array within array syntax (#1604)
|
|
68
|
+
- Fix parsing of visibility keywords in front of class methods (#1632)
|
|
69
|
+
|
|
70
|
+
# [0.9.37] - September 4th, 2024
|
|
71
|
+
|
|
72
|
+
[0.9.37]: https://github.com/lsegal/yard/compare/v0.9.36...v0.9.37
|
|
73
|
+
|
|
74
|
+
- Fix JavaScript errors in `--one-file` template (#1426)
|
|
75
|
+
- Fix heredoc parsing and add support for squiggly heredocs (#1315, #1495)
|
|
76
|
+
- Accessibility improvements to the default template (#1501)
|
|
77
|
+
- Improved YARD documentation (#1410, #1512, #1516, #1544)
|
|
78
|
+
- Fix error when parsing `@option` tags (#1515)
|
|
79
|
+
- Fix issue parsing UTF-8 filenames (#1517)
|
|
80
|
+
- Replace OpenStruct with optimized YARD::OpenStruct to avoid ostruct performance warnings (#1545)
|
|
81
|
+
- Add support for `private attr_*` syntax (#1541)
|
|
82
|
+
- Remove logger dependency (#1546)
|
|
83
|
+
|
|
3
84
|
# [0.9.36] - February 29th, 2024
|
|
4
85
|
|
|
5
86
|
[0.9.36]: https://github.com/lsegal/yard/compare/v0.9.35...v0.9.36
|
|
@@ -815,7 +896,7 @@ contributions to this version.
|
|
|
815
896
|
|
|
816
897
|
[0.4.0]: https://github.com/lsegal/yard/compare/v0.2.3.5...v0.4.0
|
|
817
898
|
|
|
818
|
-
- Added new templating engine based on [tadpole](
|
|
899
|
+
- Added new templating engine based on [tadpole](https://github.com/lsegal/tadpole)
|
|
819
900
|
- Added YARD queries (`--query` CLI argument to yardoc)
|
|
820
901
|
- Greatly expanded YARD documentation
|
|
821
902
|
- Added plugin support
|
data/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# YARD: Yay! A Ruby Documentation Tool
|
|
2
2
|
|
|
3
|
-
[](
|
|
4
|
-
[](
|
|
5
|
-
[](
|
|
3
|
+
[](https://yardoc.org)
|
|
4
|
+
[](https://github.com/lsegal/yard)
|
|
5
|
+
[](https://rubydoc.org/gems/yard/frames)
|
|
6
6
|
|
|
7
|
-
[](
|
|
7
|
+
[](https://github.com/lsegal/yard/releases)
|
|
8
8
|
[](https://github.com/lsegal/yard/actions/workflows/ci.yml)
|
|
9
9
|
[](https://coveralls.io/github/lsegal/yard)
|
|
10
10
|
[](#license)
|
|
@@ -19,10 +19,10 @@ summary of some of YARD's notable features.
|
|
|
19
19
|
|
|
20
20
|
## Feature List
|
|
21
21
|
|
|
22
|
-
**1. RDoc/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
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
|
-
|
|
122
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
192
|
+
[YARD::CLI::Yardoc](https://rubydoc.info/gems/yard/YARD/CLI/Yardoc#label-Options+File+-28.yardopts-29).
|
|
189
193
|
|
|
190
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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](
|
|
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`
|
data/docs/GettingStarted.md
CHANGED
|
@@ -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.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
[
|
|
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](
|
|
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 `{
|
|
415
|
+
### Linking URLs `{https://...}`
|
|
390
416
|
|
|
391
417
|
URLs are also linked using this `{...}` syntax:
|
|
392
418
|
|
|
393
|
-
{
|
|
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]:
|
|
676
|
-
[yard-rspec]:
|
|
677
|
-
[rspec]:
|
|
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/Parser.md
CHANGED
|
@@ -55,49 +55,10 @@ You can also provide the parser type explicitly as the second argument:
|
|
|
55
55
|
Note that these two methods are aliased as {YARD.parse} and {YARD.parse_string} for
|
|
56
56
|
convenience.
|
|
57
57
|
|
|
58
|
-
##
|
|
59
|
-
|
|
60
|
-
To implement a custom parser, subclass {YARD::Parser::Base}. Documentation on which
|
|
61
|
-
abstract methods should be implemented are documented in that class. After the class
|
|
62
|
-
is implemented, it is registered with the {YARD::Parser::SourceParser} factory class
|
|
63
|
-
to be called when a file of the right extension needs to be parsed, or when a user
|
|
64
|
-
selects that parser type explicitly. To register your new parser class, call the
|
|
65
|
-
method {YARD::Parser::SourceParser.register_parser_type}:
|
|
66
|
-
|
|
67
|
-
SourceParser.register_parser_type(:my_parser, MyParser, 'my_parser_ext')
|
|
68
|
-
|
|
69
|
-
The last argument can be a single extension, a list of extensions (Array), a single Regexp, or a
|
|
70
|
-
list of Regexps. Do not include the '.' in the extension.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
## The Two Ruby Parser Types
|
|
74
|
-
|
|
75
|
-
When parsing Ruby, the SourceParser can either instantiate the new {YARD::Parser::Ruby::RubyParser}
|
|
76
|
-
class or the {YARD::Parser::Ruby::Legacy::StatementList} class. The first of the
|
|
77
|
-
two, although faster, more robust and more efficient, is only available for
|
|
78
|
-
Ruby 1.9. The legacy parser parser is available in both 1.8.x and 1.9, if
|
|
79
|
-
compatibility is required. The choice of parser will affect which handlers
|
|
80
|
-
ultimately get used, since new handlers can only use the new parser and the
|
|
81
|
-
same requirement applies to the legacy parser & handlers.
|
|
82
|
-
|
|
83
|
-
## Switching to Legacy Parser
|
|
84
|
-
|
|
85
|
-
By default, running YARD under Ruby 1.9 will automatically select the new parser
|
|
86
|
-
and new handlers by extension. Although YARD supports both handler styles, plugins
|
|
87
|
-
may choose to only implement one of the two (though this is not recommended). If
|
|
88
|
-
only the legacy handlers are implemented, the `SourceParser` class should force
|
|
89
|
-
the use of the legacy parser by setting the `parser_type` attribute as such:
|
|
58
|
+
## RubyParser
|
|
90
59
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
The default value is `:ruby`. Note that this cannot be forced the other way around,
|
|
94
|
-
a parser type of `:ruby` cannot be set under Ruby 1.8.x as the new parser is not
|
|
95
|
-
supported under 1.8.
|
|
96
|
-
|
|
97
|
-
## RubyParser (the New Parser)
|
|
98
|
-
|
|
99
|
-
The new Ruby parser uses the Ripper library that is packaged as part of stdlib
|
|
100
|
-
in Ruby 1.9. Because of this, it can generate an AST from a string of Ruby input
|
|
60
|
+
The Ruby parser uses the Ripper library that is packaged as part of stdlib.
|
|
61
|
+
Because of this, it can generate an AST from a string of Ruby input
|
|
101
62
|
that is similar to the style of other sexp libraries (such as ParseTree). Each
|
|
102
63
|
node generated in the tree is of the base type {YARD::Parser::Ruby::AstNode},
|
|
103
64
|
which has some subclasses for common node types.
|
|
@@ -163,6 +124,20 @@ to quickly get at a node of a specific type in such a situation:
|
|
|
163
124
|
Multiple types can be searched for at once. If none are found, the original root
|
|
164
125
|
node is returned so that it may be chained.
|
|
165
126
|
|
|
127
|
+
## Implementing and Registering a Custom Parser
|
|
128
|
+
|
|
129
|
+
To implement a custom parser, subclass {YARD::Parser::Base}. Documentation on which
|
|
130
|
+
abstract methods should be implemented are documented in that class. After the class
|
|
131
|
+
is implemented, it is registered with the {YARD::Parser::SourceParser} factory class
|
|
132
|
+
to be called when a file of the right extension needs to be parsed, or when a user
|
|
133
|
+
selects that parser type explicitly. To register your new parser class, call the
|
|
134
|
+
method {YARD::Parser::SourceParser.register_parser_type}:
|
|
135
|
+
|
|
136
|
+
SourceParser.register_parser_type(:my_parser, MyParser, 'my_parser_ext')
|
|
137
|
+
|
|
138
|
+
The last argument can be a single extension, a list of extensions (Array), a single Regexp, or a
|
|
139
|
+
list of Regexps. Do not include the '.' in the extension.
|
|
140
|
+
|
|
166
141
|
## The Legacy Parser
|
|
167
142
|
|
|
168
143
|
The goal of the legacy parser is much the same as the new parser, but it is far
|
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="
|
|
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` — used when a method returns
|
|
217
|
-
values. Note that if your method returns both
|
|
218
|
-
the `Boolean` conventional type
|
|
216
|
+
* `true`, `false`, `nil`, `:foo` — 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` — 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
|
-
|--
|
|
284
|
-
| |--
|
|
285
|
-
| | |--
|
|
286
|
-
| |--
|
|
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](
|
|
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](
|
|
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](
|
|
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](
|
|
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](
|
|
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
|
|
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
|
-
[
|
|
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?
|
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')
|