OSDN Git Service

Regular updates
[twpd/master.git] / rdoc.md
1 ---
2 title: Rdoc
3 category: Markup
4 layout: 2017/sheet
5 ---
6
7 ### Basic RDoc format
8
9 ```rb
10 # Foo.
11 #
12 # @example
13 #
14 #   y
15 #   g
16 #
17 # @param [String] param_name The xx and xx.
18 #
19 # @see https://example.com/
20 #
21 # @return [true] if so
22 ```
23
24 ### Hash parameters
25
26 ```rb
27 # @param [Hash] opts the options to create a message with.
28 # @option opts [String] :subject The subject
29 # @option opts [String] :from ('nobody') From address
30 # @option opts [String] :to Recipient email
31 # @option opts [String] :body ('') The email's body 
32 ```
33
34 ### Parameter types
35
36 ```rb
37 # @param (see User#initialize)
38 # @param [OptionParser] opts the option parser object
39 # @param [Array<String>] args the arguments passed from input. This
40 #   array will be modified.
41 # @param [Array<String, Symbol>] list the list of strings and symbols.
42 # @param [Hash<Symbol, String>] a hash with symbol keys and string values
43 #
44 # The options parsed out of the commandline.
45 # Default options are:
46 #   :format => :dot
47 ```
48
49 ### Inline
50
51 ```markdown
52 *bold*
53 _emphasized_
54 +code+
55 ```
56
57 ```markdown
58 https://www.example.com/
59 See Models::User@Examples
60 {Google}[https://google.com/]
61 ```
62
63 ### Skip
64
65 ```rb
66 def input # :nodoc:
67 ```
68
69 ```rb
70 module MyModule # :nodoc: all
71 ```
72
73 ### Definition lists
74
75 ```rb
76 # == Definition lists
77 #
78 # list::  hi.
79 # +foo+:: parameterized
80 ```
81
82 ```rb
83 # == Definition lists
84 # [foo]   also
85 # [bar]   like this
86 ```
87
88 ### Return types
89
90 ```rb
91 # @return [String]
92 # @return [String, nil] the name
93 ```
94
95 ### Callseq
96
97 ```rb
98 # :call-seq:
99 #   ARGF.readlines(sep=$/)     -> array
100 #   ARGF.readlines(limit)      -> array
101 #   ARGF.readlines(sep, limit) -> array
102 #
103 #   ARGF.to_a(sep=$/)     -> array
104 #   ARGF.to_a(limit)      -> array
105 #   ARGF.to_a(sep, limit) -> array
106 ```
107
108 ### Category
109
110 ```rb
111 # :category: Utilities
112 ```
113
114 ### Sections
115
116 ```rb
117 # :section: Expiry methods
118 # methods relating to expiring
119
120 def expire!
121 def expired?
122 ...
123 ```
124
125 ### Using tomdoc
126
127 ```rb
128 # :markup: TomDoc
129 ```
130
131 Place this at the beginning of the file.
132
133 ## Also see
134 {: .-one-column}
135
136 * <http://rdoc.rubyforge.org/RDoc/Markup.html>
137 * <https://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md>
138 {: .-also-see}