rdoc 7.0.3 → 7.1.0

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.
@@ -0,0 +1,1169 @@
1
+ = RDoc Markup Reference
2
+
3
+ This document is the comprehensive reference for RDoc's +rdoc+ markup format.
4
+ It covers all markup syntax, directives, and formatting options available.
5
+
6
+ For Ruby-specific features that require actual code (like cross-reference targets
7
+ and directives that only work in Ruby comments), see RDoc::Example.
8
+
9
+ == Anchor Links
10
+
11
+ RDoc generates GitHub-style anchors for headings. The anchor is the heading
12
+ text converted to lowercase with spaces replaced by hyphens and special
13
+ characters removed.
14
+
15
+ You can link to headings using Markdown-style syntax:
16
+
17
+ - {Link to Headings}[#headings]
18
+ - {Link to Paragraphs}[#paragraphs]
19
+ - {Link to Verbatim Text Blocks}[#verbatim-text-blocks]
20
+
21
+ == About the Examples
22
+
23
+ - Examples in this reference show RDoc markup syntax.
24
+ - An example that shows rendered HTML output displays that output in a blockquote:
25
+
26
+ >>>
27
+ Some rendered output
28
+
29
+ == Markup Sources
30
+
31
+ The sources of markup documentation vary according to the file type:
32
+
33
+ - <tt>.rb</tt> (Ruby code file):
34
+
35
+ - Markup may be found in Ruby comments:
36
+ A comment that immediately precedes the definition
37
+ of a class, module, method, alias, constant, or attribute
38
+ becomes the documentation for that defined object.
39
+ - A markup directive may be found in:
40
+
41
+ - A trailing comment (on the same line as code);
42
+ see <tt>:nodoc:</tt>, <tt>:doc:</tt>, and <tt>:notnew:</tt>.
43
+ - A single-line comment;
44
+ see other Directives below.
45
+
46
+ - Documentation may be derived from the Ruby code itself;
47
+ see Derived Documentation below.
48
+
49
+ - <tt>.c</tt> (C code file): markup is parsed from C comments.
50
+ A comment that immediately precedes
51
+ a function that implements a Ruby method,
52
+ or otherwise immediately precedes the definition of a Ruby object,
53
+ becomes the documentation for that object.
54
+
55
+ - <tt>.rdoc</tt> (markup file):
56
+ markup is parsed from the entire file.
57
+ The text is not associated with any code object,
58
+ but may (depending on how the documentation is built)
59
+ become a separate page.
60
+
61
+ Note that all of the above applies to RDoc +markup+-formatted documentation:
62
+
63
+ - A C- or Ruby-coded file may contain <tt>markdown</tt>-formatted documentation,
64
+ though that format must be declared (because the default is +markup+).
65
+ - A markdown (<tt>.md</tt>) file contains only <tt>markdown</tt>-formatted documentation.
66
+
67
+ == Blocks
68
+
69
+ It's convenient to think of an RDoc document as a sequence of _blocks_
70
+ of various types:
71
+
72
+ - {Paragraph}[rdoc-ref:rdoc@Paragraphs]: an ordinary paragraph.
73
+ - {Verbatim text block}[rdoc-ref:rdoc@Verbatim+Text+Blocks]: a block of text to be rendered literally.
74
+ - {Code block}[rdoc-ref:rdoc@Code+Blocks]: a verbatim text block containing Ruby code,
75
+ to be rendered with code highlighting.
76
+ - {Block quote}[rdoc-ref:rdoc@Block+Quotes]: a longish quoted passage, to be rendered with indentation
77
+ instead of quote marks.
78
+ - {List}[rdoc-ref:rdoc@Lists]: items for a bullet list, numbered list, lettered list, or labeled list.
79
+ - {Heading}[rdoc-ref:rdoc@Headings]: a heading.
80
+ - {Horizontal rule}[rdoc-ref:rdoc@Horizontal+Rules]: a line across the rendered page.
81
+ - {Directive}[rdoc-ref:rdoc@Directives]: various special directions for the rendering.
82
+ - {Text Markup}[rdoc-ref:rdoc@Text+Markup]: text to be rendered in a special way.
83
+
84
+ About the blocks:
85
+
86
+ - Except for a paragraph, a block is distinguished by its indentation,
87
+ or by unusual initial or embedded characters.
88
+ - Any block may appear independently
89
+ (that is, not nested in another block);
90
+ some blocks may be nested, as detailed below.
91
+ - In a multi-line block,
92
+ RDoc looks for the block's natural left margin,
93
+ which becomes the <em>base margin</em> for the block
94
+ and is the initial <em>current margin</em> for the block.
95
+
96
+ === Paragraphs
97
+
98
+ A paragraph consists of one or more non-empty lines of ordinary text,
99
+ each beginning at the current margin.
100
+
101
+ Note: Here, <em>ordinary text</em> means text that is <em>not identified</em>
102
+ by indentation, or by unusual initial or embedded characters.
103
+ See below.
104
+
105
+ Paragraphs are separated by one or more empty lines.
106
+
107
+ Example input:
108
+
109
+ RDoc produces HTML and command-line documentation for Ruby projects.
110
+ RDoc includes the rdoc and ri tools for generating and displaying
111
+ documentation from the command-line.
112
+
113
+ You'll love it.
114
+
115
+ Rendered HTML:
116
+ >>>
117
+ RDoc produces HTML and command-line documentation for Ruby projects.
118
+ RDoc includes the rdoc and ri tools for generating and displaying
119
+ documentation from the command-line.
120
+
121
+ You'll love it.
122
+
123
+ A paragraph may contain nested blocks, including:
124
+
125
+ - {Verbatim text blocks}[rdoc-ref:rdoc@Verbatim+Text+Blocks].
126
+ - {Code blocks}[rdoc-ref:rdoc@Code+Blocks].
127
+ - {Block quotes}[rdoc-ref:rdoc@Block+Quotes].
128
+ - {Lists}[rdoc-ref:rdoc@Lists].
129
+ - {Headings}[rdoc-ref:rdoc@Headings].
130
+ - {Horizontal rules}[rdoc-ref:rdoc@Horizontal+Rules].
131
+ - {Text Markup}[rdoc-ref:rdoc@Text+Markup].
132
+
133
+ === Verbatim Text Blocks
134
+
135
+ Text indented farther than the current margin becomes a <em>verbatim text block</em>
136
+ (or a code block, described next).
137
+ In the rendered HTML, such text:
138
+
139
+ - Is indented.
140
+ - Has a contrasting background color.
141
+
142
+ The verbatim text block ends at the first line beginning at the current margin.
143
+
144
+ Example input:
145
+
146
+ This is not verbatim text.
147
+
148
+ This is verbatim text.
149
+ Whitespace is honored. # See?
150
+ Whitespace is honored. # See?
151
+
152
+ This is still the same verbatim text block.
153
+
154
+ This is not verbatim text.
155
+
156
+ Rendered HTML:
157
+ >>>
158
+ This is not verbatim text.
159
+
160
+ This is verbatim text.
161
+ Whitespace is honored. # See?
162
+ Whitespace is honored. # See?
163
+
164
+ This is still the same verbatim text block.
165
+
166
+ This is not verbatim text.
167
+
168
+ A verbatim text block may not contain nested blocks of any kind
169
+ -- it's verbatim.
170
+
171
+ === Code Blocks
172
+
173
+ A special case of verbatim text is the <em>code block</em>,
174
+ which is merely verbatim text that RDoc recognizes as Ruby code:
175
+
176
+ In the rendered HTML, the code block:
177
+
178
+ - Is indented.
179
+ - Has a contrasting background color.
180
+ - Has syntax highlighting.
181
+
182
+ Example input:
183
+
184
+ Consider this method:
185
+
186
+ def foo(name = '', value = 0)
187
+ @name = name # Whitespace is still honored.
188
+ @value = value
189
+ end
190
+
191
+ Rendered HTML:
192
+ >>>
193
+ Consider this method:
194
+
195
+ def foo(name = '', value = 0)
196
+ @name = name # Whitespace is still honored.
197
+ @value = value
198
+ end
199
+
200
+ Pro tip: If your indented Ruby code does not get highlighted,
201
+ it may contain a syntax error.
202
+
203
+ A code block may not contain nested blocks of any kind
204
+ -- it's verbatim.
205
+
206
+ === Block Quotes
207
+
208
+ You can use the characters <tt>>>></tt> (unindented),
209
+ followed by indented text, to treat the text
210
+ as a block quote[https://en.wikipedia.org/wiki/Block_quotation]:
211
+
212
+ Example input:
213
+
214
+ Here's a block quote:
215
+ >>>
216
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer
217
+ commodo quam iaculis massa posuere, dictum fringilla justo pulvinar.
218
+ Quisque turpis erat, pharetra eu dui at, sollicitudin accumsan nulla.
219
+
220
+ Aenean congue ligula eu ligula molestie, eu pellentesque purus
221
+ faucibus. In id leo non ligula condimentum lobortis. Duis vestibulum,
222
+ diam in pellentesque aliquet, mi tellus placerat sapien, id euismod
223
+ purus magna ut tortor.
224
+
225
+ Rendered HTML:
226
+
227
+ >>>
228
+ Here's a block quote:
229
+ >>>
230
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer
231
+ commodo quam iaculis massa posuere, dictum fringilla justo pulvinar.
232
+ Quisque turpis erat, pharetra eu dui at, sollicitudin accumsan nulla.
233
+
234
+ Aenean congue ligula eu ligula molestie, eu pellentesque purus
235
+ faucibus. In id leo non ligula condimentum lobortis. Duis vestibulum,
236
+ diam in pellentesque aliquet, mi tellus placerat sapien, id euismod
237
+ purus magna ut tortor.
238
+
239
+ Note that, unlike verbatim text, single newlines are not honored,
240
+ but that a double newline begins a new paragraph in the block quote.
241
+
242
+ A block quote may contain nested blocks, including:
243
+
244
+ - Other {block quotes}[rdoc-ref:rdoc@Block+Quotes].
245
+ - {Paragraphs}[rdoc-ref:rdoc@Paragraphs].
246
+ - {Verbatim text blocks}[rdoc-ref:rdoc@Verbatim+Text+Blocks].
247
+ - {Code blocks}[rdoc-ref:rdoc@Code+Blocks].
248
+ - {Lists}[rdoc-ref:rdoc@Lists].
249
+ - {Headings}[rdoc-ref:rdoc@Headings].
250
+ - {Horizontal rules}[rdoc-ref:rdoc@Horizontal+Rules].
251
+ - {Text Markup}[rdoc-ref:rdoc@Text+Markup].
252
+
253
+ === Lists
254
+
255
+ Each type of list item is marked by a special beginning:
256
+
257
+ - Bullet list item: Begins with a hyphen or asterisk.
258
+ - Numbered list item: Begins with digits and a period.
259
+ - Lettered list item: Begins with an alphabetic character and a period.
260
+ - Labeled list item: Begins with one of:
261
+ - Square-bracketed text.
262
+ - A word followed by two colons.
263
+
264
+ A list begins with a list item and continues, even across blank lines,
265
+ as long as list items of the same type are found at the same indentation level.
266
+
267
+ A new list resets the current margin inward.
268
+ Additional lines of text aligned at that margin
269
+ are part of the continuing list item.
270
+
271
+ A list item may be continued on additional lines that are aligned
272
+ with the first line. See examples below.
273
+
274
+ A list item may contain nested blocks, including:
275
+
276
+ - Other {lists}[rdoc-ref:rdoc@Lists] of any type.
277
+ - {Paragraphs}[rdoc-ref:rdoc@Paragraphs].
278
+ - {Verbatim text blocks}[rdoc-ref:rdoc@Verbatim+Text+Blocks].
279
+ - {Code blocks}[rdoc-ref:rdoc@Code+Blocks].
280
+ - {Block quotes}[rdoc-ref:rdoc@Block+Quotes].
281
+ - {Headings}[rdoc-ref:rdoc@Headings].
282
+ - {Horizontal rules}[rdoc-ref:rdoc@Horizontal+Rules].
283
+ - {Text Markup}[rdoc-ref:rdoc@Text+Markup].
284
+
285
+ ==== Bullet Lists
286
+
287
+ A bullet list item begins with a hyphen or asterisk.
288
+
289
+ Example input:
290
+
291
+ - An item.
292
+ - Another.
293
+ - An item spanning
294
+ multiple lines.
295
+
296
+ * Yet another.
297
+ - Last one.
298
+
299
+ Rendered HTML:
300
+ >>>
301
+ - An item.
302
+ - Another.
303
+ - An item spanning
304
+ multiple lines.
305
+
306
+ * Yet another.
307
+ - Last one.
308
+
309
+ ==== Numbered Lists
310
+
311
+ A numbered list item begins with digits and a period.
312
+
313
+ The items are automatically re-numbered.
314
+
315
+ Example input:
316
+
317
+ 100. An item.
318
+ 10. Another.
319
+ 1. An item spanning
320
+ multiple lines.
321
+
322
+ 1. Yet another.
323
+ 1000. Last one.
324
+
325
+ Rendered HTML:
326
+ >>>
327
+ 100. An item.
328
+ 10. Another.
329
+ 1. An item spanning
330
+ multiple lines.
331
+
332
+ 1. Yet another.
333
+ 1000. Last one.
334
+
335
+ ==== Lettered Lists
336
+
337
+ A lettered list item begins with letters and a period.
338
+
339
+ The items are automatically "re-lettered."
340
+
341
+ Example input:
342
+
343
+ z. An item.
344
+ y. Another.
345
+ x. An item spanning
346
+ multiple lines.
347
+
348
+ x. Yet another.
349
+ a. Last one.
350
+
351
+ Rendered HTML:
352
+ >>>
353
+ z. An item.
354
+ y. Another.
355
+ x. An item spanning
356
+ multiple lines.
357
+
358
+ x. Yet another.
359
+ a. Last one.
360
+
361
+ ==== Labeled Lists
362
+
363
+ A labeled list item begins with one of:
364
+
365
+ - Square-bracketed text: the label and text are on two lines.
366
+ - A word followed by two colons: the label and text are on the same line.
367
+
368
+ Example input:
369
+
370
+ [foo] An item.
371
+ bat:: Another.
372
+ [bag] An item spanning
373
+ multiple lines.
374
+
375
+ [bar baz] Yet another.
376
+ bam:: Last one.
377
+
378
+ Rendered HTML:
379
+ >>>
380
+ [foo] An item.
381
+ bat:: Another.
382
+ [bag] An item spanning
383
+ multiple lines.
384
+
385
+ [bar baz] Yet another.
386
+ bam:: Last one.
387
+
388
+ === Headings
389
+
390
+ A heading begins with up to six equal-signs, followed by heading text.
391
+ Whitespace between those and the heading text is optional.
392
+
393
+ You should not use headings beyond level 3, as it becomes difficult
394
+ for the reader to track the multiple layers of nesting.
395
+
396
+ Examples:
397
+
398
+ = Section 1
399
+ == Section 1.1
400
+ === Section 1.1.1
401
+ === Section 1.1.2
402
+ == Section 1.2
403
+ = Section 2
404
+ ============Still a Heading (Level 6)
405
+ \== Not a Heading
406
+
407
+ A heading may contain only one type of nested block:
408
+
409
+ - {Text Markup}[rdoc-ref:rdoc@Text+Markup].
410
+
411
+ ==== Heading Examples
412
+
413
+ = Heading level 1
414
+
415
+ Above is a level one heading.
416
+
417
+ == Heading level 2
418
+
419
+ Above is a level two heading.
420
+
421
+ === Heading level 3
422
+
423
+ Above is a level three heading.
424
+
425
+ ==== Heading level 4
426
+
427
+ Above is a level four heading.
428
+
429
+ ===== Heading level 5
430
+
431
+ Above is a level five heading.
432
+
433
+ ====== Heading level 6
434
+
435
+ Above is a level six heading.
436
+
437
+ === Horizontal Rules
438
+
439
+ A horizontal rule consists of a line with three or more hyphens
440
+ and nothing more.
441
+
442
+ Example input:
443
+
444
+ ---
445
+ --- Not a horizontal rule.
446
+
447
+ -- Also not a horizontal rule.
448
+ ---
449
+
450
+ Rendered HTML:
451
+ >>>
452
+ ---
453
+ --- Not a horizontal rule.
454
+
455
+ -- Also not a horizontal rule.
456
+ ---
457
+
458
+ == Directives
459
+
460
+ === Directives for Allowing or Suppressing Documentation
461
+
462
+ ==== <tt>:stopdoc:</tt>
463
+
464
+ - Appears on a line by itself.
465
+ - Specifies that RDoc should ignore markup
466
+ until next <tt>:startdoc:</tt> directive or end-of-file.
467
+
468
+ ==== <tt>:startdoc:</tt>
469
+
470
+ - Appears on a line by itself.
471
+ - Specifies that RDoc should resume parsing markup.
472
+
473
+ ==== <tt>:enddoc:</tt>
474
+
475
+ - Appears on a line by itself.
476
+ - Specifies that RDoc should ignore markup to end-of-file
477
+ regardless of other directives.
478
+
479
+ ==== <tt>:nodoc:</tt>
480
+
481
+ - Appended to a line of code
482
+ that defines a class, module, method, alias, constant, or attribute;
483
+ takes optional argument +all+ (<tt>:nodoc: all</tt>).
484
+ - Specifies that the defined object should not be documented.
485
+
486
+ For a method definition in C code, the directive must be in the comment line
487
+ immediately preceding the definition:
488
+
489
+ /* :nodoc: */
490
+ static VALUE
491
+ some_method(VALUE self)
492
+ {
493
+ return self;
494
+ }
495
+
496
+ Note that this directive has <em>no effect at all</em>
497
+ when placed at the method declaration:
498
+
499
+ /* :nodoc: */
500
+ rb_define_method(cMyClass, "do_something", something_func, 0);
501
+
502
+ The above comment is just a comment and has nothing to do with RDoc.
503
+ Therefore, +do_something+ method will be reported as "undocumented"
504
+ unless that method or function is documented elsewhere.
505
+
506
+ For a constant definition in C code, this directive <em>cannot work</em>
507
+ because there is no "implementation" place for a constant.
508
+
509
+ With argument +all+ (<tt>:nodoc: all</tt>),
510
+ specifies that the class or module should not be documented.
511
+ By default, however, a nested class or module _will_ be documented.
512
+
513
+ ==== <tt>:doc:</tt>
514
+
515
+ - Appended to a line of code
516
+ that defines a class, module, method, alias, constant, or attribute.
517
+ - Specifies the defined object should be documented, even if it otherwise
518
+ would not be documented.
519
+
520
+ ==== <tt>:notnew:</tt>
521
+
522
+ - Appended to a line of code
523
+ that defines instance method +initialize+.
524
+ - Specifies that singleton method +new+ should not be documented.
525
+ By default, Ruby fakes a corresponding singleton method +new+,
526
+ which RDoc includes in the documentation.
527
+ Note that instance method +initialize+ is private, and so by default
528
+ is not documented.
529
+
530
+ Aliased as <tt>:not_new:</tt> and <tt>:not-new:</tt>.
531
+
532
+ For Ruby code, but not for other RDoc sources,
533
+ there is a shorthand for <tt>:stopdoc:</tt> and <tt>:startdoc:</tt>:
534
+
535
+ # Documented.
536
+ #--
537
+ # Not documented.
538
+ #++
539
+ # Documented.
540
+
541
+ For C code, any of directives <tt>:startdoc:</tt>, <tt>:stopdoc:</tt>,
542
+ and <tt>:enddoc:</tt> may appear in a stand-alone comment:
543
+
544
+ /* :startdoc: */
545
+ /* :stopdoc: */
546
+ /* :enddoc: */
547
+
548
+ === Directive for Specifying RDoc Source Format
549
+
550
+ ==== <tt>:markup:</tt>
551
+
552
+ - Appears on a line by itself; takes argument +format+ (<tt>:markup: format</tt>).
553
+ - Specifies the format for the RDoc input;
554
+ argument +format+ is one of: +rdoc+ (the default), +markdown+, +rd+, +tomdoc+.
555
+
556
+ === Directives for Method Documentation
557
+
558
+ ==== <tt>:call-seq:</tt>
559
+
560
+ - Appears on a line by itself.
561
+ - Specifies the calling sequence to be reported in the HTML,
562
+ overriding the actual calling sequence in the code.
563
+ See RDoc::Example#call_seq_example for a demonstration.
564
+
565
+ Note that RDoc can build the calling sequence for a Ruby-coded method,
566
+ but not for other languages.
567
+ You may want to override that by explicitly giving a <tt>:call-seq:</tt>
568
+ directive if you want to include:
569
+
570
+ - A return type, which is not automatically inferred.
571
+ - Multiple calling sequences.
572
+
573
+ For C code, the directive may appear in a stand-alone comment.
574
+
575
+ ==== <tt>:args:</tt>
576
+
577
+ - Appears on a line by itself; takes argument +arg_names+ (<tt>:args: arg_names</tt>).
578
+ - Specifies the arguments to be reported in the HTML,
579
+ overriding the actual arguments in the code.
580
+ See RDoc::Example#args_example for a demonstration.
581
+
582
+ Aliased as <tt>:arg:</tt>.
583
+
584
+ ==== <tt>:yields:</tt>
585
+
586
+ - Appears on a line by itself; takes argument +arg_names+ (<tt>:yields: arg_names</tt>).
587
+ - Specifies the yield arguments to be reported in the HTML,
588
+ overriding the actual yield in the code.
589
+ See RDoc::Example#yields_example for a demonstration.
590
+
591
+ Aliased as <tt>:yield:</tt>.
592
+
593
+ === Directives for Organizing Documentation
594
+
595
+ By default, RDoc groups:
596
+
597
+ - Singleton methods together in alphabetical order.
598
+ - Instance methods and their aliases together in alphabetical order.
599
+ - Attributes and their aliases together in alphabetical order.
600
+
601
+ You can use directives to modify those behaviors.
602
+
603
+ ==== <tt>:section:</tt>
604
+
605
+ - Appears on a line by itself; takes argument +section_title+ (<tt>:section: section_title</tt>).
606
+ - Specifies that following methods are to be grouped into the section
607
+ with the given +section_title+,
608
+ or into the default section if no title is given.
609
+ The directive remains in effect until another such directive is given,
610
+ but may be temporarily overridden by directive <tt>:category:</tt>.
611
+ See below.
612
+
613
+ The comment block containing this directive:
614
+
615
+ - Must be separated by a blank line from the documentation for the next item.
616
+ - May have one or more lines preceding the directive.
617
+ These will be removed, along with any trailing lines that match them.
618
+ Such lines may be visually helpful.
619
+ - Lines of text that are not so removed become the descriptive text
620
+ for the section.
621
+
622
+ Example:
623
+
624
+ # ----------------------------------------
625
+ # :section: My Section
626
+ # This is the section that I wrote.
627
+ # See it glisten in the noon-day sun.
628
+ # ----------------------------------------
629
+
630
+ ##
631
+ # Comment for some_method
632
+ def some_method
633
+ # ...
634
+ end
635
+
636
+ You can use directive <tt>:category:</tt> to temporarily
637
+ override the current section.
638
+
639
+ ==== <tt>:category:</tt>
640
+
641
+ - Appears on a line by itself; takes argument +section_title+ (<tt>:category: section_title</tt>).
642
+ - Specifies that just one following method is to be included
643
+ in the given section, or in the default section if no title is given.
644
+ Subsequent methods are to be grouped into the current section.
645
+
646
+ === Directive for Including a File
647
+
648
+ ==== <tt>:include:</tt>
649
+
650
+ - Appears on a line by itself; takes argument +filepath+ (<tt>:include: filepath</tt>).
651
+ - Specifies that the contents of the given file
652
+ are to be included at this point.
653
+
654
+ The file content is shifted to have the same indentation as the colon
655
+ at the start of the directive.
656
+
657
+ The file is searched for in the directory containing the current file,
658
+ and then in each of the directories given with the <tt>--include</tt>
659
+ command-line option.
660
+
661
+ For C code, the directive may appear in a stand-alone comment.
662
+
663
+ == Text Markup
664
+
665
+ Text markup is metatext that affects HTML rendering:
666
+
667
+ - {Typeface}[rdoc-ref:rdoc@Typeface+Markup]: italic, bold, monofont, strikethrough.
668
+ - {Character conversions}[rdoc-ref:rdoc@Character+Conversions]: copyright, trademark, certain punctuation.
669
+ - {Links}[rdoc-ref:rdoc@Links].
670
+ - {Escapes}[rdoc-ref:rdoc@Escaping+Text]: marking text as "not markup."
671
+
672
+ === Typeface Markup
673
+
674
+ Typeface markup can specify that text is to be rendered
675
+ as italic, bold, monofont, or strikethrough.
676
+
677
+ Typeface markup may contain only one type of nested block:
678
+
679
+ - More typeface markup:
680
+ {italic}[rdoc-ref:rdoc@Italic], {bold}[rdoc-ref:rdoc@Bold], {monofont}[rdoc-ref:rdoc@Monofont],
681
+ {strikethrough}[rdoc-ref:rdoc@Strikethrough].
682
+
683
+ ==== Italic
684
+
685
+ Text may be marked as italic via HTML tag <tt><i></tt> or <tt><em></tt>.
686
+
687
+ Example input:
688
+
689
+ <i>Italicized words</i> in a paragraph.
690
+
691
+ <i>Italicized passage containing *bold* and +monofont+.</i>
692
+
693
+ Rendered HTML:
694
+ >>>
695
+ <i>Italicized words</i> in a paragraph.
696
+
697
+ <i>Italicized passage containing *bold* and +monofont+.</i>
698
+
699
+ A single word may be italicized via a shorthand:
700
+ prefixed and suffixed underscores.
701
+
702
+ Example input:
703
+
704
+ _Italic_ in a paragraph.
705
+
706
+ Rendered HTML:
707
+ >>>
708
+ _Italic_ in a paragraph.
709
+
710
+ ==== Bold
711
+
712
+ Text may be marked as bold via HTML tag <tt><b></tt>.
713
+
714
+ Example input:
715
+
716
+ <b>Bold words</b> in a paragraph.
717
+
718
+ <b>Bold passage containing _italics_ and +monofont+.</b>
719
+
720
+ Rendered HTML:
721
+
722
+ >>>
723
+ <b>Bold words</b> in a paragraph.
724
+
725
+ <b>Bold passage containing _italics_ and +monofont+.</b>
726
+
727
+ A single word may be made bold via a shorthand:
728
+ prefixed and suffixed asterisks.
729
+
730
+ Example input:
731
+
732
+ *Bold* in a paragraph.
733
+
734
+ Rendered HTML:
735
+
736
+ >>>
737
+ *Bold* in a paragraph.
738
+
739
+ ==== Monofont
740
+
741
+ Text may be marked as monofont
742
+ -- sometimes called 'typewriter font' --
743
+ via HTML tag <tt><tt></tt> or <tt><code></tt>.
744
+
745
+ Example input:
746
+
747
+ <tt>Monofont words</tt> in a paragraph.
748
+
749
+ <tt>Monofont stylings are disabled: _italics_ and *bold*.</tt>
750
+
751
+ Rendered HTML:
752
+
753
+ >>>
754
+ <tt>Monofont words</tt> in a paragraph.
755
+
756
+ <tt>Monofont stylings are disabled: _italics_ and *bold*.</tt>
757
+
758
+ A single word may be made monofont by a shorthand:
759
+ prefixed and suffixed plus-signs or backticks.
760
+
761
+ Example input:
762
+
763
+ +Monofont+ in a paragraph.
764
+
765
+ `Monofont` in a paragraph.
766
+
767
+ Rendered HTML:
768
+
769
+ >>>
770
+ +Monofont+ in a paragraph.
771
+
772
+ `Monofont` in a paragraph.
773
+
774
+ Note: The shorthand (<tt>+...+</tt> and <tt>`...`</tt>) only works for simple content
775
+ containing word characters, colons, periods, slashes, brackets, and hyphens.
776
+ Content containing HTML tags or other markup delimiters will not be matched.
777
+ For complex content, use the HTML tags <tt><tt></tt> or <tt><code></tt> instead:
778
+
779
+ <tt>+literal_plus+</tt> shows: +literal_plus+
780
+
781
+ <tt>`literal_backtick`</tt> shows: `literal_backtick`
782
+
783
+ <tt><code>content</code></tt> shows: <code>content</code>
784
+
785
+ ==== Strikethrough
786
+
787
+ Text may be marked as strikethrough via HTML tag <tt><del></tt> or <tt><s></tt>.
788
+
789
+ Example input:
790
+
791
+ <del>Strikethrough words</del> in a paragraph.
792
+
793
+ <del>Deleted passage containing _italics_ and *bold*.</del>
794
+
795
+ Rendered HTML:
796
+
797
+ >>>
798
+ <del>Strikethrough words</del> in a paragraph.
799
+
800
+ <del>Deleted passage containing _italics_ and *bold*.</del>
801
+
802
+ === Character Conversions
803
+
804
+ Certain combinations of characters may be converted to special characters;
805
+ whether the conversion occurs depends on whether the special character
806
+ is available in the current encoding.
807
+
808
+ - <tt>(c)</tt> converts to (c) (copyright character); must be lowercase.
809
+
810
+ - <tt>(r)</tt> converts to (r) (registered trademark character); must be lowercase.
811
+
812
+ - <tt>'foo'</tt> converts to 'foo' (smart single-quotes).
813
+
814
+ - <tt>"foo"</tt> converts to "foo" (smart double-quotes).
815
+
816
+ - <tt>foo ... bar</tt> converts to foo ... bar (1-character ellipsis).
817
+
818
+ - <tt>foo -- bar</tt> converts to foo -- bar (1-character en-dash).
819
+
820
+ - <tt>foo --- bar</tt> converts to foo --- bar (1-character em-dash).
821
+
822
+ == Links
823
+
824
+ Certain strings in RDoc text are converted to links.
825
+ Any such link may be suppressed by prefixing a backslash.
826
+ This section shows how to link to various targets.
827
+
828
+ === Class Links
829
+
830
+ - On-page: <tt>RDoc::Example::ExampleClass</tt> links to RDoc::Example::ExampleClass.
831
+ - Off-page: <tt>RDoc::Alias</tt> links to RDoc::Alias.
832
+
833
+ Note: When marking up code (such as class, module,
834
+ constant, and method) as "<tt>+code+</tt>" (for interoperability
835
+ with other Markdown parsers mainly), any word that refers to a known
836
+ code object, and is marked up entirely and separately as "monofont",
837
+ is also converted to a link.
838
+
839
+ - <tt>+RDoc+</tt> links to +RDoc+.
840
+
841
+ === Module Links
842
+
843
+ - On-page: <tt>RDoc::Example::ExampleModule</tt> links to RDoc::Example::ExampleModule.
844
+ - Off-page: <tt>RDoc</tt> links to RDoc.
845
+
846
+ === Constant Links
847
+
848
+ - On-page: <tt>RDoc::Example::EXAMPLE_CONSTANT</tt> links to RDoc::Example::EXAMPLE_CONSTANT.
849
+ - Off-page: <tt>RDoc::Text::MARKUP_FORMAT</tt> links to RDoc::Text::MARKUP_FORMAT.
850
+
851
+ === Singleton Method Links
852
+
853
+ - On-page: <tt>RDoc::Example::singleton_method_example</tt> links to RDoc::Example::singleton_method_example.
854
+ - Off-page: <tt>RDoc::TokenStream::to_html</tt> links to RDoc::TokenStream::to_html.
855
+
856
+ Note: Occasionally RDoc is not linked to a method whose name
857
+ has only special characters. Check whether the links you were expecting
858
+ are actually there. If not, you'll need to put in an explicit link;
859
+ see below.
860
+
861
+ Pro tip: The link to any method is available in the alphabetical table of contents
862
+ at the top left of the page for the class or module.
863
+
864
+ === Instance Method Links
865
+
866
+ - On-page: <tt>#instance_method_example</tt> links to #instance_method_example
867
+ (when in the same class context).
868
+ - Off-page: <tt>RDoc::Alias#html_name</tt> links to RDoc::Alias#html_name.
869
+
870
+ See the Note and Pro Tip immediately above.
871
+
872
+ === Attribute Links
873
+
874
+ - Off-page: <tt>RDoc::Alias#name</tt> links to RDoc::Alias#name.
875
+
876
+ === Alias Links
877
+
878
+ - Off-page: <tt>RDoc::Alias#new_name</tt> links to RDoc::Alias#new_name.
879
+
880
+ === Protocol Links
881
+
882
+ [Protocol +http+]
883
+
884
+ - Linked: <tt>http://yahoo.com</tt> links to http://yahoo.com.
885
+
886
+ [Protocol +https+]
887
+
888
+ - Linked: <tt>https://github.com</tt> links to https://github.com.
889
+
890
+ [Protocol +ftp+]
891
+
892
+ - Linked: <tt>ftp://nosuch.site</tt> links to ftp://nosuch.site.
893
+
894
+ [Protocol +mailto+]
895
+
896
+ - Linked: <tt>mailto:foo@bar.com</tt> links to mailto:foo@bar.com.
897
+
898
+ [Protocol +irc+]
899
+
900
+ - Link: <tt>irc://irc.freenode.net/ruby</tt> links to irc://irc.freenode.net/ruby.
901
+
902
+ === Image Filename Extensions
903
+
904
+ Link: <tt>https://www.ruby-lang.org/images/header-ruby-logo@2x.png</tt> is
905
+ converted to an in-line HTML +img+ tag, which displays the image in the HTML:
906
+
907
+ https://www.ruby-lang.org/images/header-ruby-logo@2x.png
908
+
909
+ Also works for +bmp+, +gif+, +jpeg+, and +jpg+ files.
910
+
911
+ Note: Works only for a fully qualified URL.
912
+
913
+ === Heading Links
914
+
915
+ Link: <tt>RDoc::RD@LICENSE</tt> links to RDoc::RDoc::RD@LICENSE.
916
+
917
+ Note that spaces in the actual heading are represented by <tt>+</tt> characters
918
+ in the linkable text.
919
+
920
+ - Link: <tt>RDoc::Options@Saved+Options</tt> links to RDoc::Options@Saved+Options.
921
+
922
+ Punctuation and other special characters must be escaped like CGI.escape.
923
+
924
+ Pro tip: The link to any heading is available in the alphabetical table of contents
925
+ at the top left of the page for the class or module.
926
+
927
+ === Section Links
928
+
929
+ See Directives for Organizing Documentation above.
930
+
931
+ - Link: <tt>RDoc::Markup::ToHtml@Visitor</tt> links to RDoc::Markup::ToHtml@Visitor.
932
+
933
+ If a section and a heading share the same name, the link target is the section.
934
+
935
+ === Single-Word Text Link
936
+
937
+ Use square brackets to create single-word text link:
938
+
939
+ - <tt>GitHub[https://github.com]</tt> links to GitHub[https://github.com].
940
+
941
+ === Multi-Word Text Link
942
+
943
+ Use square brackets and curly braces to create a multi-word text link.
944
+
945
+ - <tt>{GitHub home page}[https://github.com]</tt> links to
946
+ {GitHub home page}[https://github.com].
947
+
948
+ === <tt>rdoc-ref</tt> Scheme
949
+
950
+ A link with the <tt>rdoc-ref:</tt> scheme links to the referenced item,
951
+ if that item exists.
952
+ The referenced item may be a class, module, method, file, etc.
953
+
954
+ - Class: <tt>Alias[rdoc-ref:RDoc::Alias]</tt> generates Alias[rdoc-ref:RDoc::Alias].
955
+ - Module: <tt>RDoc[rdoc-ref:RDoc]</tt> generates RDoc[rdoc-ref:RDoc].
956
+ - Method: <tt>foo[rdoc-ref:RDoc::Example#instance_method_example]</tt>
957
+ generates foo[rdoc-ref:RDoc::Example#instance_method_example].
958
+ - Constant: <tt>bar[rdoc-ref:RDoc::Example::EXAMPLE_CONSTANT]</tt>
959
+ generates bar[rdoc-ref:RDoc::Example::EXAMPLE_CONSTANT].
960
+ - File: <tt>README[rdoc-ref:README.md]</tt> generates README[rdoc-ref:README.md].
961
+
962
+ If the referenced item does not exist, no link is generated
963
+ and entire <tt>rdoc-ref:</tt> square-bracketed clause is removed
964
+ from the resulting text.
965
+
966
+ - <tt>Nosuch[rdoc-ref:RDoc::Nosuch]</tt> generates Nosuch.
967
+
968
+ === <tt>rdoc-label</tt> Scheme
969
+
970
+ ==== Simple
971
+
972
+ You can specify a link target using this form,
973
+ where the second part cites the id of an HTML element.
974
+
975
+ This link refers to the constant +EXAMPLE_CONSTANT+ on this page:
976
+
977
+ - <tt>{EXAMPLE_CONSTANT}[rdoc-label:EXAMPLE_CONSTANT]</tt>
978
+
979
+ ==== With Return
980
+
981
+ You can specify both a link target and a local label
982
+ that can be used as the target for a return link.
983
+ These two links refer to each other:
984
+
985
+ - <tt>{go to addressee}[rdoc-label:addressee:sender]</tt>
986
+ - <tt>{return to sender}[rdoc-label:sender:addressee]</tt>
987
+
988
+ Thus:
989
+
990
+ {go to addressee}[rdoc-label:addressee:sender]
991
+
992
+ Some text.
993
+
994
+ {return to sender}[rdoc-label:sender:addressee]
995
+
996
+ === <tt>link:</tt> Scheme
997
+
998
+ - <tt>link:README_md.html</tt> links to link:README_md.html.
999
+
1000
+ === <tt>rdoc-image</tt> Scheme
1001
+
1002
+ Use the <tt>rdoc-image</tt> scheme to display an image that is also a link:
1003
+
1004
+ {rdoc-image:path/to/image}[link_target]
1005
+
1006
+ - Link: <tt>{rdoc-image:https://www.ruby-lang.org/images/header-ruby-logo@2x.png}[https://www.ruby-lang.org]</tt>
1007
+ displays image <tt>https://www.ruby-lang.org/images/header-ruby-logo@2x.png</tt>
1008
+ as a link to <tt>https://www.ruby-lang.org</tt>.
1009
+
1010
+ {rdoc-image:https://www.ruby-lang.org/images/header-ruby-logo@2x.png}[https://www.ruby-lang.org]
1011
+
1012
+ A relative path as the target also works:
1013
+
1014
+ - Link: <tt>{rdoc-image:https://www.ruby-lang.org/images/header-ruby-logo@2x.png}[./Alias.html]</tt> links to <tt>./Alias.html</tt>
1015
+
1016
+ {rdoc-image:https://www.ruby-lang.org/images/header-ruby-logo@2x.png}[./Alias.html]
1017
+
1018
+ == Escaping Text
1019
+
1020
+ Text that would otherwise be interpreted as markup
1021
+ can be "escaped," so that it is not interpreted as markup;
1022
+ the escape character is the backslash (<tt>'\\'</tt>).
1023
+
1024
+ In a verbatim text block or a code block,
1025
+ the escape character is always preserved:
1026
+
1027
+ Example input:
1028
+
1029
+ This is not verbatim text.
1030
+
1031
+ This is verbatim text, with an escape character \.
1032
+
1033
+ This is not a code block.
1034
+
1035
+ def foo
1036
+ 'String with an escape character.'
1037
+ end
1038
+
1039
+ Rendered HTML:
1040
+
1041
+ >>>
1042
+ This is not verbatim text.
1043
+
1044
+ This is verbatim text, with an escape character \.
1045
+
1046
+ This is not a code block.
1047
+
1048
+ def foo
1049
+ 'This is a code block with an escape character \.'
1050
+ end
1051
+
1052
+ In typeface markup (italic, bold, or monofont),
1053
+ an escape character is preserved unless it is immediately
1054
+ followed by nested typeface markup.
1055
+
1056
+ Example input:
1057
+
1058
+ This list is about escapes; it contains:
1059
+
1060
+ - <b>Bold text with unescaped nested _italic_</b>.
1061
+ - <b>Bold text with escaped nested \_italic_</b>.
1062
+ - <b>Bold text with an escape character \</b>.
1063
+
1064
+ Rendered HTML:
1065
+
1066
+ >>>
1067
+ This list is about escapes; it contains:
1068
+
1069
+ - <b>Bold text with unescaped nested _italic_</b>.
1070
+ - <b>Bold text with escaped nested \_italic_</b>.
1071
+ - <b>Bold text with an escape character \ </b>.
1072
+
1073
+ In other text-bearing blocks
1074
+ (paragraphs, block quotes, list items, headings):
1075
+
1076
+ - A single escape character immediately followed by markup
1077
+ escapes the markup.
1078
+ - A single escape character followed by whitespace is preserved.
1079
+ - A single escape character anywhere else is ignored.
1080
+ - A double escape character is rendered as a single backslash.
1081
+
1082
+ Example input:
1083
+
1084
+ This list is about escapes; it contains:
1085
+
1086
+ - An unescaped class name, RDoc, that will become a link.
1087
+ - An escaped class name, \RDoc, that will not become a link.
1088
+ - An escape character followed by whitespace \ .
1089
+ - An escape character \that is ignored.
1090
+ - A double escape character \\ that is rendered
1091
+ as a single backslash.
1092
+
1093
+ Rendered HTML:
1094
+
1095
+ >>>
1096
+ This list is about escapes; it contains:
1097
+
1098
+ - An unescaped class name, RDoc, that will become a link.
1099
+ - An escaped class name, \RDoc, that will not become a link.
1100
+ - An escape character followed by whitespace \ .
1101
+ - An escape character \that is ignored.
1102
+ - A double escape character \\ that is rendered
1103
+ as a single backslash.
1104
+
1105
+ == Derived Documentation
1106
+
1107
+ RDoc can automatically derive documentation from Ruby code.
1108
+ For demonstrations, see RDoc::Example.
1109
+
1110
+ === Class
1111
+
1112
+ By default, RDoc documents:
1113
+
1114
+ - Class name.
1115
+ - Parent class.
1116
+ - Included modules.
1117
+ - Singleton methods.
1118
+ - Instance methods.
1119
+ - Aliases.
1120
+ - Constants.
1121
+ - Attributes.
1122
+
1123
+ === Module
1124
+
1125
+ By default, RDoc documents:
1126
+
1127
+ - Module name.
1128
+ - Included modules.
1129
+ - Singleton methods.
1130
+ - Instance methods.
1131
+ - Aliases.
1132
+ - Constants.
1133
+ - Attributes.
1134
+
1135
+ === Method
1136
+
1137
+ By default, RDoc documents:
1138
+
1139
+ - Method name.
1140
+ - Arguments.
1141
+ - Yielded values.
1142
+
1143
+ See RDoc::Example#derived_docs_example.
1144
+
1145
+ === Alias
1146
+
1147
+ By default, RDoc documents:
1148
+
1149
+ - Alias name.
1150
+ - Aliased name.
1151
+
1152
+ See RDoc::Example#aliased_method.
1153
+
1154
+ === Constant
1155
+
1156
+ By default, RDoc documents:
1157
+
1158
+ - Constant name.
1159
+
1160
+ See RDoc::Example::EXAMPLE_CONSTANT.
1161
+
1162
+ === Attribute
1163
+
1164
+ By default, RDoc documents:
1165
+
1166
+ - Attribute name.
1167
+ - Attribute type (<tt>[R]</tt>, <tt>[W]</tt>, or <tt>[RW]</tt>)
1168
+
1169
+ See RDoc::Example#example_attribute.