cheatsheets/rdoc.md

151 lines
2.4 KiB
Markdown
Raw Permalink Normal View History

2013-10-14 02:36:58 +00:00
---
2012-03-16 06:14:31 +00:00
title: Rdoc
2015-11-24 05:11:34 +00:00
category: Markup
2013-10-14 02:36:58 +00:00
---
2012-03-16 06:14:31 +00:00
### Basic RDoc format
2018-03-03 00:06:54 +00:00
```rb
# Foo.
#
# @example
#
# y
# g
#
# @param [String] param_name The xx and xx.
#
# @see https://example.com/
2018-03-03 00:06:54 +00:00
#
# @return [true] if so
```
2012-03-16 06:14:31 +00:00
2021-05-20 01:57:24 +00:00
### Hash parameters
```rb
# @param [Hash] opts the options to create a message with.
# @option opts [String] :subject The subject
# @option opts [String] :from ('nobody') From address
# @option opts [String] :to Recipient email
# @option opts [String] :body ('') The email's body
2021-05-20 01:57:24 +00:00
```
### Parameter types
```rb
# @param (see User#initialize)
# @param [OptionParser] opts the option parser object
# @param [Array<String>] args the arguments passed from input. This
# array will be modified.
# @param [Array<String, Symbol>] list the list of strings and symbols.
# @param [Hash<Symbol, String>] a hash with symbol keys and string values
#
# The options parsed out of the commandline.
# Default options are:
# :format => :dot
```
### Exceptions
```rb
# @raise [AccountBalanceError] if the account does not have
# sufficient funds to perform the transaction
```
2015-05-19 16:33:23 +00:00
### Inline
2018-03-03 00:06:54 +00:00
```markdown
2017-08-27 15:27:41 +00:00
*bold*
_emphasized_
+code+
```
2015-05-19 16:33:23 +00:00
```markdown
{ObjectName#method optional title}
{Class::CONSTANT My constant's title}
{#method_inside_current_namespace}
```
2018-03-03 00:06:54 +00:00
```markdown
https://www.example.com/
2017-08-27 15:27:41 +00:00
See Models::User@Examples
{Google}[https://google.com/]
2017-08-27 15:27:41 +00:00
```
2015-05-19 16:33:23 +00:00
### Skip
2017-08-27 15:27:41 +00:00
```rb
def input # :nodoc:
```
```rb
module MyModule # :nodoc: all
```
2015-05-19 16:33:23 +00:00
2017-08-27 15:27:41 +00:00
### Definition lists
2018-03-03 00:06:54 +00:00
```rb
2017-08-27 15:27:41 +00:00
# == Definition lists
#
# list:: hi.
# +foo+:: parameterized
```
2018-03-03 00:06:54 +00:00
```rb
2017-08-27 15:27:41 +00:00
# == Definition lists
# [foo] also
# [bar] like this
```
2015-05-19 16:33:23 +00:00
### Return types
2018-03-03 00:06:54 +00:00
```rb
# @return [String]
# @return [String, nil] the name
```
2015-05-19 16:33:23 +00:00
### Callseq
2018-03-03 00:06:54 +00:00
```rb
# :call-seq:
# ARGF.readlines(sep=$/) -> array
# ARGF.readlines(limit) -> array
# ARGF.readlines(sep, limit) -> array
#
# ARGF.to_a(sep=$/) -> array
# ARGF.to_a(limit) -> array
# ARGF.to_a(sep, limit) -> array
```
2015-05-19 16:33:23 +00:00
### Category
2018-03-03 00:06:54 +00:00
```rb
# :category: Utilities
```
2015-05-19 16:33:23 +00:00
### Sections
2017-08-27 15:27:41 +00:00
```rb
# :section: Expiry methods
# methods relating to expiring
2015-05-19 16:33:23 +00:00
2017-08-27 15:27:41 +00:00
def expire!
def expired?
...
```
2015-05-19 16:33:23 +00:00
### Using tomdoc
2018-03-03 00:06:54 +00:00
```rb
2017-08-27 15:27:41 +00:00
# :markup: TomDoc
```
2018-03-03 00:06:54 +00:00
Place this at the beginning of the file.
2017-08-27 15:27:41 +00:00
## Also see
{: .-one-column}
2015-05-19 16:33:23 +00:00
2022-05-18 05:48:54 +00:00
* <https://docs.ruby-lang.org/en/2.1.0/RDoc/Markup.html>
* <https://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md>
* <https://rubydoc.info/gems/yard/file/docs/Tags.md>
2017-08-27 15:27:41 +00:00
{: .-also-see}