yard 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of yard might be problematic. Click here for more details.

Files changed (46) hide show
  1. data/ChangeLog +131 -0
  2. data/README.md +16 -12
  3. data/Rakefile +2 -1
  4. data/docs/GettingStarted.md +1 -107
  5. data/docs/Tags.md +250 -53
  6. data/docs/WhatsNew.md +13 -0
  7. data/lib/rubygems_plugin.rb +18 -17
  8. data/lib/yard.rb +1 -1
  9. data/lib/yard/autoload.rb +4 -0
  10. data/lib/yard/cli/yardoc.rb +5 -4
  11. data/lib/yard/cli/yri.rb +18 -3
  12. data/lib/yard/code_objects/base.rb +5 -4
  13. data/lib/yard/code_objects/class_object.rb +1 -1
  14. data/lib/yard/code_objects/constant_object.rb +1 -1
  15. data/lib/yard/code_objects/method_object.rb +3 -2
  16. data/lib/yard/code_objects/namespace_object.rb +3 -3
  17. data/lib/yard/code_objects/proxy.rb +4 -0
  18. data/lib/yard/docstring.rb +3 -2
  19. data/lib/yard/handlers/base.rb +1 -1
  20. data/lib/yard/handlers/ruby/class_condition_handler.rb +5 -1
  21. data/lib/yard/handlers/ruby/class_handler.rb +41 -1
  22. data/lib/yard/handlers/ruby/legacy/class_condition_handler.rb +5 -1
  23. data/lib/yard/handlers/ruby/legacy/class_handler.rb +44 -0
  24. data/lib/yard/handlers/ruby/struct_handler_methods.rb +128 -0
  25. data/lib/yard/parser/base.rb +55 -0
  26. data/lib/yard/parser/c_parser.rb +5 -1
  27. data/lib/yard/parser/ruby/ast_node.rb +4 -4
  28. data/lib/yard/parser/ruby/legacy/ruby_parser.rb +26 -0
  29. data/lib/yard/parser/ruby/legacy/statement_list.rb +0 -4
  30. data/lib/yard/parser/ruby/ruby_parser.rb +45 -2
  31. data/lib/yard/parser/source_parser.rb +69 -45
  32. data/lib/yard/serializers/file_system_serializer.rb +1 -1
  33. data/lib/yard/tags/default_factory.rb +1 -13
  34. data/lib/yard/tags/library.rb +3 -1
  35. data/lib/yard/templates/erb_cache.rb +5 -2
  36. data/lib/yard/templates/helpers/html_helper.rb +1 -0
  37. data/lib/yard/templates/template.rb +2 -1
  38. data/spec/cli/yardoc_spec.rb +6 -6
  39. data/spec/handlers/class_condition_handler_spec.rb +11 -0
  40. data/spec/handlers/class_handler_spec.rb +121 -0
  41. data/spec/handlers/examples/class_handler_001.rb.txt +19 -0
  42. data/spec/parser/base_spec.rb +25 -0
  43. data/spec/parser/source_parser_spec.rb +63 -0
  44. data/templates/default/layout/html/setup.rb +1 -1
  45. data/templates/default/tags/html/option.erb +1 -1
  46. metadata +21 -5
data/ChangeLog CHANGED
@@ -1,5 +1,85 @@
1
+ 2010-06-12 Loren Segal <lsegal@soen.ca>
2
+
3
+ * ChangeLog, README.md, docs/WhatsNew.md, lib/yard.rb, yard.gemspec: Release
4
+ 0.5.6
5
+
6
+ * lib/rubygems_plugin.rb: Don't generate yri index if has_rdoc == false
7
+
8
+ * lib/yard/handlers/ruby/class_condition_handler.rb,
9
+ spec/handlers/class_condition_handler_spec.rb: Fix failing class condition
10
+ handling case in 1.9
11
+
12
+ * lib/rubygems_plugin.rb, lib/yard/cli/yardoc.rb,
13
+ lib/yard/code_objects/base.rb, lib/yard/code_objects/class_object.rb,
14
+ lib/yard/code_objects/constant_object.rb,
15
+ lib/yard/code_objects/method_object.rb,
16
+ lib/yard/code_objects/namespace_object.rb, lib/yard/code_objects/proxy.rb,
17
+ lib/yard/docstring.rb, lib/yard/handlers/base.rb,
18
+ lib/yard/parser/ruby/ast_node.rb, lib/yard/parser/ruby/ruby_parser.rb,
19
+ lib/yard/serializers/file_system_serializer.rb,
20
+ lib/yard/tags/default_factory.rb, lib/yard/tags/library.rb,
21
+ lib/yard/templates/template.rb, templates/default/tags/html/option.erb: Fix a
22
+ boatload of Ruby warnings
23
+
24
+ * lib/rubygems_plugin.rb: Fix warnings in RubyGems plugin Closes gh-108
25
+
26
+ * spec/cli/yardoc_spec.rb: Fix Yardoc CLI specs for new read_binary encoding
27
+ fixes
28
+
29
+ * lib/yard/autoload.rb, lib/yard/parser/base.rb, lib/yard/parser/c_parser.rb,
30
+ lib/yard/parser/ruby/legacy/ruby_parser.rb,
31
+ lib/yard/parser/ruby/legacy/statement_list.rb,
32
+ lib/yard/parser/ruby/ruby_parser.rb, lib/yard/parser/source_parser.rb,
33
+ spec/parser/base_spec.rb, spec/parser/source_parser_spec.rb: Refactor
34
+ SourceParser and create API to extend YARD with custom source parsers using
35
+ YARD::Parser::SourceParser.register_parser_type Closes gh-101
36
+
37
+ 2010-06-11 Loren Segal <lsegal@soen.ca>
38
+
39
+ * lib/yard/parser/source_parser.rb: Add .cc as C source filename extension
40
+
41
+ * .../ruby/legacy/class_condition_handler.rb,
42
+ spec/handlers/class_condition_handler_spec.rb: Fixes handling of class
43
+ conditionals in the form "defined?(A) && defined?(B)"
44
+
45
+ 2010-06-05 Loren Segal <lsegal@soen.ca>
46
+
47
+ * lib/yard/cli/yardoc.rb, lib/yard/templates/erb_cache.rb,
48
+ lib/yard/templates/helpers/html_helper.rb,
49
+ templates/default/layout/html/setup.rb: Various encoding related template
50
+ fixes. Closes gh-131
51
+
52
+ 2010-05-26 Loren Segal <lsegal@soen.ca>
53
+
54
+ * lib/yard/cli/yri.rb: Don't use less on Windows (non-cygwin)
55
+
56
+ * lib/yard/cli/yri.rb: yri should fail gracefully when no arguments are
57
+ supplied
58
+
59
+ * Rakefile: Better rake support for windows
60
+
61
+ * lib/yard/parser/ruby/ruby_parser.rb, spec/parser/source_parser_spec.rb: Fix
62
+ handling of docstrings in 1.9 parser when there are comments before and on
63
+ the same line of a code object
64
+
65
+ * README.md, docs/GettingStarted.md, docs/Tags.md: Move tag list from
66
+ GettingStarted to Tags and document syntax
67
+
68
+ * README.md: Update README formatting
69
+
70
+ 2010-05-25 Loren Segal <lsegal@soen.ca>
71
+
72
+ * lib/yard/autoload.rb, lib/yard/handlers/ruby/class_handler.rb,
73
+ lib/yard/handlers/ruby/legacy/class_handler.rb,
74
+ lib/yard/handlers/ruby/struct_handler_methods.rb: Various documentation and
75
+ style refactorings
76
+
1
77
  2010-05-22 Loren Segal <lsegal@soen.ca>
2
78
 
79
+ * README.md: Fix release date/version in readme
80
+
81
+ * README.md: Fix contributors formatting in readme for github
82
+
3
83
  * ChangeLog, README.md, lib/yard.rb, yard.gemspec: Bump version to 0.5.5
4
84
 
5
85
  2010-05-21 Loren Segal <lsegal@soen.ca>
@@ -53,6 +133,11 @@
53
133
  lib/yard/code_objects/proxy.rb, spec/code_objects/class_object_spec.rb: Fixes
54
134
  an issue where mixins could appear twice in the class hierarchy
55
135
 
136
+ 2010-05-18 Michael Edgar <michael.j.edgar@dartmouth.edu>
137
+
138
+ * lib/yard/handlers/ruby/struct_handler_methods.rb: Made struct handler
139
+ directly add tags. Technical faux pas.
140
+
56
141
  2010-05-15 postmodern <postmodern.mod3@gmail.com>
57
142
 
58
143
  * lib/yard.rb: Only glob .rb files from yard/core_ext and do not strip the
@@ -71,6 +156,52 @@
71
156
  spec/parser/ruby/legacy/statement_list_spec.rb: Fill .block for 'else' and
72
157
  'elsif' statements in legacy parser.
73
158
 
159
+ 2010-05-09 Michael Edgar <michael.j.edgar@dartmouth.edu>
160
+
161
+ * lib/yard/handlers/ruby/legacy/class_handler.rb,
162
+ spec/handlers/class_handler_spec.rb,
163
+ spec/handlers/examples/class_handler_001.rb.txt: Added more specs for
164
+ attr_reader and attr_writer combinations.
165
+
166
+ * lib/yard/handlers/ruby/struct_handler_methods.rb,
167
+ spec/handlers/class_handler_spec.rb,
168
+ spec/handlers/examples/class_handler_001.rb.txt: Added some specs for the use
169
+ of attr_reader and attr_writer. Made them pass.
170
+
171
+ * lib/yard/handlers/ruby/struct_handler_methods.rb, lib/yard/tags/library.rb:
172
+ Added basic logic for the separation of reader/writer attributes. Specs pass,
173
+ but no new specs have been added.
174
+
175
+ * lib/yard/handlers/ruby/class_handler.rb,
176
+ lib/yard/handlers/ruby/legacy/class_handler.rb: Added support on the handler
177
+ side for defining constants for non-anonymous structs
178
+
179
+ * spec/handlers/class_handler_spec.rb: Added a spec to ensure that when a
180
+ non-anonymous struct is used, the appropriate constant is defined in
181
+ Struct::.
182
+
183
+ * lib/yard/handlers/ruby/class_handler.rb,
184
+ lib/yard/handlers/ruby/legacy/class_handler.rb: Added Ruby 1.8.x
185
+ compatibility, and fixed an error caused by OStruct.new (without parens).
186
+
187
+ * lib/yard/handlers/ruby/struct_handler_methods.rb, lib/yard/tags/library.rb,
188
+ spec/handlers/class_handler_spec.rb,
189
+ spec/handlers/examples/class_handler_001.rb.txt: Specifications added for the
190
+ @attr tag.
191
+
192
+ * lib/yard/handlers/ruby/class_handler.rb: Added basic support for
193
+ subclass-syntax with Structs. The newly-added specs pass.
194
+
195
+ * lib/yard/autoload.rb, lib/yard/handlers/ruby/struct_handler_methods.rb:
196
+ Added my struct_handler_methods.rb file from yard-struct, which will provide
197
+ shortcuts for adding attributes. This is a module (and not dropped into the
198
+ ClassHandler) because I want to reuse this code for the Constant-assignment
199
+ syntax as well.
200
+
201
+ * spec/handlers/class_handler_spec.rb,
202
+ spec/handlers/examples/class_handler_001.rb.txt: Added specs for the
203
+ superclass syntax for Struct usage.
204
+
74
205
  2010-05-04 Denis Defreyne <denis.defreyne@stoneship.org>
75
206
 
76
207
  * templates/default/docstring/html/private.erb,
data/README.md CHANGED
@@ -1,17 +1,18 @@
1
- YARD Release 0.5.4 "The Longest" (Mar 22nd 2010)
2
- ================================================
1
+ YARD: Yay! A Ruby Documentation Tool
2
+ ====================================
3
3
 
4
4
  **Homepage**: [http://yardoc.org](http://yardoc.org)
5
- **IRC**: **Join us on IRC in #yard on irc.freenode.net!**
5
+ **IRC**: [irc://irc.freenode.net/yard](irc.freenode.net / #yard)
6
6
  **Git**: [http://github.com/lsegal/yard](http://github.com/lsegal/yard)
7
7
  **Author**: Loren Segal
8
8
  **Contributors**: Nathan Weizenbaum, Yehuda Katz, Denis Defreyne, Postmodern,
9
- Michael Edgar
9
+ Michael Edgar
10
10
  **Copyright**: 2007-2010
11
11
  **License**: MIT License
12
+ **Latest Version**: 0.5.6 (codename "The Longest")
13
+ **Release Date**: May 22nd 2010
12
14
 
13
-
14
- SYNOPSIS
15
+ Synopsis
15
16
  --------
16
17
 
17
18
  YARD is a documentation generation tool for the Ruby programming language.

@@ -21,7 +22,7 @@ custom Ruby constructs such as custom class level definitions. Below is a

21
22
  summary of some of YARD's notable features.
22
23
 
23
24
 
24
- FEATURE LIST
25
+ Feature List
25
26
  ------------
26
27
 
27
28
  **1. RDoc/SimpleMarkup Formatting Compatibility**: YARD is made to be compatible

@@ -37,7 +38,7 @@ important information about objects, such as what parameters they take and what
37
38
  they are expected to be, what type a
method should return, what exceptions it can
38
39
  raise, if it is deprecated, etc.. It also allows information to be better (and more
39
40
  consistently) organized
during the output generation phase. You can find a list
40
- of tags in the {file:GettingStarted.md#taglist GettingStarted.md} file.
41
+ of tags in the {file:Tags.md#taglist Tags.md} file.
41
42
 
42
43
  YARD also supports an optional "types" declarations for certain tags.

43
44
  This allows the developer to document type signatures for ruby methods and

@@ -46,7 +47,6 @@ describing this data in the body of the description, a developer may formally

46
47
  declare the parameter or return type(s) in a single line. Consider the

47
48
  following Yardoc'd method:

48
49
 
49
- ##
50
50
  # Reverses the contents of a String or IO object.
51
51
  #
52
52
  # @param [String, #read] contents the contents to reverse
@@ -97,7 +97,7 @@ exploiting this raw data format would be to write tools that can auto generate
97
97
  test cases, for example, or show possible unhandled exceptions in code.

98
98
 
99
99
 
100
- USAGE
100
+ Usage
101
101
  -----
102
102
 
103
103
  There are a couple of ways to use YARD. The first is via command-line, and the
@@ -221,9 +221,13 @@ More options can be seen by typing `yard-graph --help`, but here is an example:
221
221
  $ yard-graph --protected --full --dependencies
222
222
 
223
223
 
224
- CHANGELOG
224
+ Changelog
225
225
  ---------
226
226
 
227
+ - **June.12.10**: 0.5.6 release
228
+ - Bug fixes for RubyGems plugin, `has_rdoc=false` should now work
229
+ - New API for registering custom parsers. See {file:WhatsNew.md}
230
+
227
231
  - **May.22.10**: 0.5.5 release
228
232
  - Various bug fixes
229
233
 
@@ -293,7 +297,7 @@ CHANGELOG
293
297
  power of YARD and what to expect from the syntax (Yardoc style meta tags).
294
298
 
295
299
 
296
- COPYRIGHT
300
+ Copyright
297
301
  ---------
298
302
 
299
303
  YARD &copy; 2007-2010 by [Loren Segal](mailto:lsegal@soen.ca). YARD is
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/lib/yard'
2
+ require 'rbconfig'
2
3
 
3
- WINDOWS = (RUBY_PLATFORM =~ /win32|cygwin/ ? true : false) rescue false
4
+ WINDOWS = (Config::CONFIG['host_os'] =~ /mingw|win32|cygwin/ ? true : false) rescue false
4
5
  SUDO = WINDOWS ? '' : 'sudo'
5
6
 
6
7
  task :default => :specs
@@ -110,116 +110,10 @@ Symbols:
110
110
 
111
111
  # @param [Array<String, Symbol>] list the list of strings and symbols.
112
112
 
113
- <a name="taglist"></a>
114
113
  List of Tags
115
114
  ------------
116
115
 
117
- A list of common tags and example usage is below:
118
-
119
- * `@abstract`: Marks a class/module/method as abstract with optional
120
- implementor information.
121
-
122
- @abstract Subclass and override {#run} to implement a custom Threadable class.
123
-
124
- * `@author`: List the author(s) of a class/method
125
-
126
- @author Full Name
127
-
128
- * `@deprecated`: Marks a method/class as deprecated with an optional
129
- reason.
130
-
131
- @deprecated Describe the reason or provide alt. references here
132
-
133
- * `@example`: Show an example snippet of code for an object. The
134
- first line is an optional title.
135
-
136
- @example Reverse a string
137
- "mystring.reverse" #=> "gnirtsym"
138
-
139
- * `@option`: Describe an options hash in a method. The tag takes the
140
- name of the options parameter first, followed by optional types,
141
- the option key name, an optional default value for the key and a
142
- description of the option.
143
-
144
- # @param [Hash] opts the options to create a message with.
145
- # @option opts [String] :subject The subject
146
- # @option opts [String] :from ('nobody') From address
147
- # @option opts [String] :to Recipient email
148
- # @option opts [String] :body ('') The email's body
149
- def send_email(opts = {})
150
- end
151
-
152
- * `@overload`: Describe that your method can be used in various
153
- contexts with various parameters or return types. The first
154
- line should declare the new method signature, and the following
155
- indented tag data will be a new documentation string with its
156
- own tags adding metadata for such an overload.
157
-
158
- # @overload set(key, value)
159
- # Sets a value on key
160
- # @param [Symbol] key describe key param
161
- # @param [Object] value describe value param
162
- # @overload set(value)
163
- # Sets a value on the default key `:foo`
164
- # @param [Object] value describe value param
165
- def set(*args)
166
- end
167
-
168
- * `@param`: Defines method parameters
169
-
170
- @param [optional, types, ...] argname description
171
-
172
- * `@private`: Defines an object as private. This exists for classes,
173
- modules and constants that do not obey Ruby's visibility rules. For
174
- instance, an inner class might be considered "private", though Ruby
175
- would make no such distinction. By declaring the @private tag, the
176
- class can be hidden from documentation by using the `--no-private`
177
- command-line switch to yardoc (see {file:README.md}).
178
-
179
- @private
180
-
181
- * `@raise`: Describes an Exception that a method may throw
182
-
183
- @raise [ExceptionClass] description
184
-
185
- * `@return`: Describes return value of method
186
-
187
- @return [optional, types, ...] description
188
-
189
- * `@see`: "See Also" references for an object. Accepts URLs or
190
- other code objects with an optional description at the end.
191
-
192
- @see http://example.com Description of URL
193
- @see SomeOtherClass#method
194
-
195
- * `@since`: Lists the version the feature/object was first added
196
-
197
- @since 1.2.4
198
-
199
- * `@todo`: Marks a TODO note in the object being documented
200
-
201
- @todo Add support for Jabberwocky service
202
- There is an open source Jabberwocky library available
203
- at http://somesite.com that can be integrated easily
204
- into the project.
205
-
206
- * `@version`: Lists the version of a class, module or method
207
-
208
- @version 1.0
209
-
210
- * `@yield`: Describes the block. Use types to list the parameter
211
- names the block yields.
212
-
213
- # for block {|a, b, c| ... }
214
- @yield [a, b, c] Description of block
215
-
216
- * `@yieldparam`: Defines parameters yielded by a block
217
-
218
- @yieldparam [optional, types, ...] argname description
219
-
220
- * `@yieldreturn`: Defines return type of a block
221
-
222
- @yieldreturn [optional, types, ...] description
116
+ A list of tags can be found in {file:Tags.md#taglist}
223
117
 
224
118
  Other Extended Syntax
225
119
  ---------------------
data/docs/Tags.md CHANGED
@@ -1,5 +1,5 @@
1
- Tags Architecture
2
- =================
1
+ Tags Overview
2
+ =============
3
3
 
4
4
  Tags represent the metadata that can be added to documentation through the `@tag`
5
5
  style syntax:
@@ -12,9 +12,249 @@ The above example adds metadata under the name `tagname` to the Foo class object
12
12
 
13
13
  Tags are the best way to add arbitrary metadata when documenting an object in a
14
14
  way to access it later without having to parse the entire comment string. The
15
- rest of the document will describe how to access the tag metadata and how to extend
16
- YARD to support custom tags or override existing tags to the {YARD::Tags::Library}
17
- class.
15
+ rest of the document will describe the tag syntax, how to access the tag
16
+ metadata and how to extend YARD to support custom tags or override existing tags.
17
+
18
+ Tag Syntax
19
+ ----------
20
+
21
+ Tags begin with "@tagname" at the start of a comment line. Tags can span multiple
22
+ lines if the subsequent lines are indented by more than one space. The following
23
+ syntax is valid:
24
+
25
+ # @tagname This is
26
+ # tag data
27
+ # but this is not
28
+
29
+ In the above example, "@tagname" will have the text *"This is tag data"*.
30
+
31
+ If a tag's data begins with `(see NAME)` it is considered a "reference tag".
32
+ The syntax and semantics of a reference tag are discussed in the section below
33
+ titled "[Reference Tags](#reftags)"
34
+
35
+ Although custom tags can be parsed in any way, the built-in tags follow a few
36
+ common syntax structures by convention in order to simplify the syntax. The
37
+ following syntaxes are available:
38
+
39
+ ### Freeform Data
40
+
41
+ This syntax has no special syntax, it is simply a tagname followed by any
42
+ data.
43
+
44
+ @tagname data here
45
+
46
+ ### Freeform Data With Title
47
+
48
+ Occasionally a freeform tag may reserve the first line for a title (or some
49
+ other associative identifier) and treat only the subsequent indented lines as
50
+ the tag data. Two examples are the `@example` and `@overload` tags. In the case
51
+ of `@example` the first line is a title, and in the case of `@overload` the
52
+ first line is the method signature for the overload. Here is an example of both:
53
+
54
+ @example Reverse a string
55
+ "hello world".reverse
56
+
57
+ @overload request(method = :get, url = 'http://example.com')
58
+ Performs a request on +url+
59
+ @param [Symbol] method the request method
60
+ @param [String] url the URL to perform the request on
61
+ @return [String] the result body (no headers)
62
+
63
+ ### Data With Optional Type Information
64
+
65
+ This syntax optionally contains type information to be associated with the
66
+ tag. Type information is specified as a freeform list of Ruby types, duck
67
+ types or literal values. The following is a valid tag with type information:
68
+
69
+ @return [String, #read] a string or object that responds to #read
70
+
71
+ ### Data With Name and Optional Type Information
72
+
73
+ A special case of the above data with optional type information is the case
74
+ of tags like `@param`, where the data is further associated with a key. In
75
+ the case of `@param` the key is an argument name in the method. The following
76
+ shows how this can be used:
77
+
78
+ @param [String] url the URL to perform the request on
79
+
80
+ Note that "url" in the above example is the key name. The syntax is of the form:
81
+
82
+ @tagname [types] <name> <description>
83
+
84
+ As mentioned, types are optional, so the following is also valid:
85
+
86
+ @param url the URL to perform the request on
87
+
88
+
89
+ <a name="taglist"></a>
90
+ List of Available Tags
91
+ ----------------------
92
+
93
+ YARD supplies the following built-in tags:
94
+
95
+ * `@abstract`: Marks a class/module/method as abstract with optional
96
+ implementor information.
97
+
98
+ @abstract Subclass and override {#run} to implement a custom Threadable class.
99
+
100
+ * `@attr`: Declares an attribute from the docstring of a class. Meant to be
101
+ used on Struct classes (classes that inherit Struct).
102
+
103
+ @attr [Types] attribute_name a full description of the attribute
104
+
105
+ * `@attr_reader`: Declares a readonly attribute from the docstring of a class.
106
+ Meant to be used on Struct classes (classes that inherit Struct). See `@attr`.
107
+
108
+ @attr_reader [Types] name description of a readonly attribute
109
+
110
+ * `@attr_writer`: Declares a writeonly attribute from the docstring of class.
111
+ Meant to be used on Struct classes (classes that inherit Struct). See `@attr`.
112
+
113
+ @attr_writer [Types] name description of writeonly attribute
114
+
115
+ * `@author`: List the author(s) of a class/method
116
+
117
+ @author Full Name
118
+
119
+ * `@deprecated`: Marks a method/class as deprecated with an optional
120
+ reason.
121
+
122
+ @deprecated Describe the reason or provide alt. references here
123
+
124
+ * `@example`: Show an example snippet of code for an object. The
125
+ first line is an optional title.
126
+
127
+ @example Reverse a string
128
+ "mystring.reverse" #=> "gnirtsym"
129
+
130
+ * `@option`: Describe an options hash in a method. The tag takes the
131
+ name of the options parameter first, followed by optional types,
132
+ the option key name, an optional default value for the key and a
133
+ description of the option.
134
+
135
+ # @param [Hash] opts the options to create a message with.
136
+ # @option opts [String] :subject The subject
137
+ # @option opts [String] :from ('nobody') From address
138
+ # @option opts [String] :to Recipient email
139
+ # @option opts [String] :body ('') The email's body
140
+ def send_email(opts = {})
141
+ end
142
+
143
+ * `@overload`: Describe that your method can be used in various
144
+ contexts with various parameters or return types. The first
145
+ line should declare the new method signature, and the following
146
+ indented tag data will be a new documentation string with its
147
+ own tags adding metadata for such an overload.
148
+
149
+ # @overload set(key, value)
150
+ # Sets a value on key
151
+ # @param [Symbol] key describe key param
152
+ # @param [Object] value describe value param
153
+ # @overload set(value)
154
+ # Sets a value on the default key `:foo`
155
+ # @param [Object] value describe value param
156
+ def set(*args)
157
+ end
158
+
159
+ * `@param`: Defines method parameters
160
+
161
+ @param [optional, types, ...] argname description
162
+
163
+ * `@private`: Defines an object as private. This exists for classes,
164
+ modules and constants that do not obey Ruby's visibility rules. For
165
+ instance, an inner class might be considered "private", though Ruby
166
+ would make no such distinction. By declaring the @private tag, the
167
+ class can be hidden from documentation by using the `--no-private`
168
+ command-line switch to yardoc (see {file:README.md}).
169
+
170
+ @private
171
+
172
+ * `@raise`: Describes an Exception that a method may throw
173
+
174
+ @raise [ExceptionClass] description
175
+
176
+ * `@return`: Describes return value of method
177
+
178
+ @return [optional, types, ...] description
179
+
180
+ * `@see`: "See Also" references for an object. Accepts URLs or
181
+ other code objects with an optional description at the end.
182
+
183
+ @see http://example.com Description of URL
184
+ @see SomeOtherClass#method
185
+
186
+ * `@since`: Lists the version the feature/object was first added
187
+
188
+ @since 1.2.4
189
+
190
+ * `@todo`: Marks a TODO note in the object being documented
191
+
192
+ @todo Add support for Jabberwocky service
193
+ There is an open source Jabberwocky library available
194
+ at http://somesite.com that can be integrated easily
195
+ into the project.
196
+
197
+ * `@version`: Lists the version of a class, module or method
198
+
199
+ @version 1.0
200
+
201
+ * `@yield`: Describes the block. Use types to list the parameter
202
+ names the block yields.
203
+
204
+ # for block {|a, b, c| ... }
205
+ @yield [a, b, c] Description of block
206
+
207
+ * `@yieldparam`: Defines parameters yielded by a block
208
+
209
+ @yieldparam [optional, types, ...] argname description
210
+
211
+ * `@yieldreturn`: Defines return type of a block
212
+
213
+ @yieldreturn [optional, types, ...] description
214
+
215
+
216
+ <a name="reftags"></a>
217
+ Reference Tags
218
+ --------------
219
+
220
+ Although attempt is made in YARD to leave as many of the syntax details as
221
+ possible to the factory provider, there is a special tag syntax for referencing
222
+ tags created in other objects so that they can be reused again. This is common
223
+ when an object describes a return type or parameters that are passed through to
224
+ other methods. In such a case, it is more manageable to use the reference tag
225
+ syntax. Consider the following example:
226
+
227
+ class User
228
+ # @param [String] username the nam of the user to add
229
+ # @param [Number] uid the user ID
230
+ # @param [Number] gid the group ID
231
+ def initialize(username, uid, gid)
232
+ end
233
+ end
234
+
235
+ module UserHelper
236
+ # @param (see User#initialize)
237
+ def add_user(username, uid, gid)
238
+ User.new(username, uid, gid)
239
+ end
240
+
241
+ # @param username (see User#initialize)
242
+ def add_root_user(username)
243
+ User.new(username, 0, 0)
244
+ end
245
+ end
246
+
247
+ Because the UserHelper module methods delegate directly to `User.new`, copying
248
+ the documentation details would be unmaintainable. In this case, the (see METHODNAME)
249
+ syntax is used to reference the tags from the User constructor to the helper methods.
250
+ For the first method, all `@param` tags are referenced in one shot, but the second
251
+ method only references one of the tags by adding `username` before the reference.
252
+
253
+ Reference tags are represented by the {YARD::Tags::RefTag} class and are created
254
+ directly during parsing by {YARD::Docstring}.
255
+
256
+ Programmatic API
257
+ ================
18
258
 
19
259
  Accessing Tag Information
20
260
  -------------------------
@@ -49,8 +289,8 @@ tag that stores simple text like our `@tagname` tag above, use:
49
289
 
50
290
  This will now allow YARD to add the metadata from `@tagname` to the docstring.
51
291
 
52
- The Tag Factory Architecture
53
- ============================
292
+ Tag Factory Architecture
293
+ ------------------------
54
294
 
55
295
  Recognizing a tag is one part of the process. Parsing the tag contents is the
56
296
  second step. YARD has a tag architecture that allows developers to add or completely
@@ -61,8 +301,7 @@ class diagram:
61
301
 
62
302
  ![Tags Architecture Class Diagram](images/tags-class-diagram.png)
63
303
 
64
- DefaultFactory
65
- --------------
304
+ ### DefaultFactory
66
305
 
67
306
  By default, YARD has a few standard syntaxes that can be parsed for tags. These
68
307
  are all implemented by the {YARD::Tags::DefaultFactory} class. These syntaxes
@@ -102,8 +341,7 @@ the type declaration syntax to be in the form:
102
341
  This can be done by simply implementing a new factory that parses the data in
103
342
  this form.
104
343
 
105
- Implementing a Factory
106
- ----------------------
344
+ ### Implementing a Factory
107
345
 
108
346
  Factories should implement the method `parse_tag` as well as any `parse_tag_SUFFIX`
109
347
  method where SUFFIX refers to the suffix added when declaring the tag. For example,
@@ -131,51 +369,10 @@ unmodified raw text:
131
369
  Note that this method would be invoked for a tag declared with the `:with_raw_text`
132
370
  suffix.
133
371
 
134
- Changing the Factory
135
- --------------------
372
+ ### Changing the Factory
136
373
 
137
374
  To change the factory, set the {YARD::Tags::Library.default_factory} attribute:
138
375
 
139
376
  YARD::Tags::Library.default_factory = MyFactory
140
377
 
141
378
  This must be done before any parsing is done, or the factory will not be used.
142
-
143
- <a name="reftags"></a>
144
- Reference Tags
145
- --------------
146
-
147
- Although attempt is made in YARD to leave as many of the syntax details as
148
- possible to the factory provider, there is a special tag syntax for referencing
149
- tags created in other objects so that they can be reused again. This is common
150
- when an object describes a return type or parameters that are passed through to
151
- other methods. In such a case, it is more manageable to use the reference tag
152
- syntax. Consider the following example:
153
-
154
- class User
155
- # @param [String] username the nam of the user to add
156
- # @param [Number] uid the user ID
157
- # @param [Number] gid the group ID
158
- def initialize(username, uid, gid)
159
- end
160
- end
161
-
162
- module UserHelper
163
- # @param (see User#initialize)
164
- def add_user(username, uid, gid)
165
- User.new(username, uid, gid)
166
- end
167
-
168
- # @param username (see User#initialize)
169
- def add_root_user(username)
170
- User.new(username, 0, 0)
171
- end
172
- end
173
-
174
- Because the UserHelper module methods delegate directly to `User.new`, copying
175
- the documentation details would be unmaintainable. In this case, the (see METHODNAME)
176
- syntax is used to reference the tags from the User constructor to the helper methods.
177
- For the first method, all `@param` tags are referenced in one shot, but the second
178
- method only references one of the tags by adding `username` before the reference.
179
-
180
- Reference tags are represented by the {YARD::Tags::RefTag} class and are created
181
- directly during parsing by {YARD::Docstring}.