class RDoc::Example
RDoc::Example provides example Ruby code objects for demonstrating RDoc’s documentation capabilities.
This class is used by:
-
bin/console for interactive exploration of RDoc objects
-
Testing cross-reference link generation
-
Demonstrating Ruby-specific directives like :call-seq:, :args:, :yields:
For comprehensive RDoc markup documentation, see doc/markup_reference/rdoc.rdoc.
Constants
- EXAMPLE_CONSTANT
-
Exampleconstant.
Attributes
Example attribute.
Example attribute.
Public Class Methods
Source
# File doc/rdoc/example.rb, line 25 def self.singleton_method_example(foo, bar); end
Example singleton method.
Public Instance Methods
Source
# File doc/rdoc/example.rb, line 76 def args_example(foo, bar) # :args: baz nil end
The :args: directive overrides the actual arguments found in the Ruby code.
The actual signature is +args_example(foo, bar)+, but the directive makes it appear as +args_example(baz)+.
Source
# File doc/rdoc/example.rb, line 66 def call_seq_example nil end
The :call-seq: directive overrides the actual calling sequence found in the Ruby code.
-
It can specify anything at all.
-
It can have multiple calling sequences.
Note that the “arrow” is two characters, hyphen and right angle-bracket, which is made into a single character in the HTML.
Here is the :call-seq: directive given for this method:
:call-seq: call_seq_example(foo, bar) Can be anything -> bar Also anything more -> baz or bat
Source
# File doc/rdoc/example.rb, line 98 def derived_docs_example(foo, bar) yield 'baz' end
This method is documented only by RDoc’s derived documentation, except for these comments.
RDoc automatically extracts:
-
Method name
-
Arguments
-
Yielded values
Source
# File doc/rdoc/example.rb, line 31 def instance_method_example(foo, bar) yield 'baz' end
Example instance method.
This method demonstrates how RDoc documents instance methods, including arguments and yield parameters.
Source
# File doc/rdoc/example.rb, line 86 def yields_example(foo, bar) # :yields: 'bat' yield 'baz' end
The :yields: directive overrides the actual yield found in the Ruby code.
The actual yield is +‘baz’+, but the directive makes it appear as +‘bat’+.