Skip to content

Commit 7e6ef6c

Browse files
[DOC] Make example formats explicit and consistent (#913)
1 parent dc88f1b commit 7e6ef6c

File tree

1 file changed

+87
-66
lines changed

1 file changed

+87
-66
lines changed

doc/rdoc/markup_reference.rb

Lines changed: 87 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,37 @@
2929
# see <tt>:nodoc:</tt>, <tt>:doc:</tt>, and <tt>:notnew</tt>.
3030
# - \RDoc directives in single-line comments;
3131
# see other {Directives}[rdoc-ref:RDoc::MarkupReference@Directives].
32-
# - The Ruby code itself;
33-
# see {Documentation Derived from Ruby Code}[rdoc-ref:RDoc::MarkupReference@Documentation+Derived+from+Ruby+Code]
32+
# - The Ruby code itself (but not from C code);
33+
# see {Documentation Derived from Ruby Code}[rdoc-ref:RDoc::MarkupReference@Documentation+Derived+from+Ruby+Code].
3434
#
3535
# == Markup in Comments
3636
#
37-
# A single-line or multi-line comment that immediately precedes
38-
# the definition of a class, module, method, alias, constant, or attribute
39-
# becomes the documentation for that defined object.
37+
# The treatment of markup in comments varies according to the type of file:
4038
#
41-
# (\RDoc ignores other such comments that do not precede definitions.)
39+
# - <tt>.rb</tt> (Ruby code file): markup is parsed from Ruby comments.
40+
# - <tt>.c</tt> (C code file): markup is parsed from C comments.
41+
# - <tt>.rdoc</tt> (RDoc text file): markup is parsed from the entire file.
42+
#
43+
# The comment associated with
44+
# a Ruby class, module, method, alias, constant, or attribute
45+
# becomes the documentation for that defined object:
46+
#
47+
# - In a Ruby file, that comment immediately precedes
48+
# the definition of the object.
49+
# - In a C file, that comment immediately precedes
50+
# the function that implements a method,
51+
# or otherwise immediately precedes the definition of the object.
52+
#
53+
# In either a Ruby or a C file,
54+
# \RDoc ignores comments that do not precede object definitions.
55+
#
56+
# In an \RDoc file, the text is not associated with any code object,
57+
# but may (depending on how the documentation is built),
58+
# become a separate page.
59+
#
60+
# Almost all examples on this page are all RDoc-like;
61+
# that is, they have no comment markers like Ruby <tt>#</tt>
62+
# or C <tt>/* ... */</tt>.
4263
#
4364
# === Margins
4465
#
@@ -96,11 +117,11 @@
96117
#
97118
# Example input:
98119
#
99-
# # \RDoc produces HTML and command-line documentation for Ruby projects.
100-
# # \RDoc includes the rdoc and ri tools for generating and displaying
101-
# # documentation from the command-line.
102-
# #
103-
# # You'll love it.
120+
# \RDoc produces HTML and command-line documentation for Ruby projects.
121+
# \RDoc includes the rdoc and ri tools for generating and displaying
122+
# documentation from the command-line.
123+
#
124+
# You'll love it.
104125
#
105126
# Rendered HTML:
106127
# >>>
@@ -133,15 +154,15 @@
133154
#
134155
# Example input:
135156
#
136-
# # This is not verbatim text.
137-
# #
138-
# # This is verbatim text.
139-
# # Whitespace is honored. # See?
140-
# # Whitespace is honored. # See?
141-
# #
142-
# # This is still the same verbatim text block.
143-
# #
144-
# # This is not verbatim text.
157+
# This is not verbatim text.
158+
#
159+
# This is verbatim text.
160+
# Whitespace is honored. # See?
161+
# Whitespace is honored. # See?
162+
#
163+
# This is still the same verbatim text block.
164+
#
165+
# This is not verbatim text.
145166
#
146167
# Rendered HTML:
147168
# >>>
@@ -279,13 +300,13 @@
279300
#
280301
# Example input:
281302
#
282-
# # - An item.
283-
# # - Another.
284-
# # - An item spanning
285-
# # multiple lines.
286-
# #
287-
# # * Yet another.
288-
# # - Last one.
303+
# - An item.
304+
# - Another.
305+
# - An item spanning
306+
# multiple lines.
307+
#
308+
# * Yet another.
309+
# - Last one.
289310
#
290311
# Rendered HTML:
291312
# >>>
@@ -305,13 +326,13 @@
305326
#
306327
# Example input:
307328
#
308-
# # 100. An item.
309-
# # 10. Another.
310-
# # 1. An item spanning
311-
# # multiple lines.
312-
# #
313-
# # 1. Yet another.
314-
# # 1000. Last one.
329+
# 100. An item.
330+
# 10. Another.
331+
# 1. An item spanning
332+
# multiple lines.
333+
#
334+
# 1. Yet another.
335+
# 1000. Last one.
315336
#
316337
# Rendered HTML:
317338
# >>>
@@ -331,13 +352,13 @@
331352
#
332353
# Example input:
333354
#
334-
# # z. An item.
335-
# # y. Another.
336-
# # x. An item spanning
337-
# # multiple lines.
338-
# #
339-
# # x. Yet another.
340-
# # a. Last one.
355+
# z. An item.
356+
# y. Another.
357+
# x. An item spanning
358+
# multiple lines.
359+
#
360+
# x. Yet another.
361+
# a. Last one.
341362
#
342363
# Rendered HTML:
343364
# >>>
@@ -356,13 +377,13 @@
356377
#
357378
# Example input:
358379
#
359-
# # [foo] An item.
360-
# # bat:: Another.
361-
# # [bag] An item spanning
362-
# # multiple lines.
363-
# #
364-
# # [bar baz] Yet another.
365-
# # bam:: Last one.
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.
366387
#
367388
# Rendered HTML:
368389
# >>>
@@ -381,20 +402,20 @@
381402
#
382403
# Examples:
383404
#
384-
# # = Section 1
385-
# # == Section 1.1
386-
# # === Section 1.1.1
387-
# # === Section 1.1.2
388-
# # == Section 1.2
389-
# # = Section 2
390-
# # = Foo
391-
# # == Bar
392-
# # === Baz
393-
# # ==== Bam
394-
# # ===== Bat
395-
# # ====== Bad
396-
# # ============Still a Heading (Level 6)
397-
# # \== Not a Heading
405+
# = Section 1
406+
# == Section 1.1
407+
# === Section 1.1.1
408+
# === Section 1.1.2
409+
# == Section 1.2
410+
# = Section 2
411+
# = Foo
412+
# == Bar
413+
# === Baz
414+
# ==== Bam
415+
# ===== Bat
416+
# ====== Bad
417+
# ============Still a Heading (Level 6)
418+
# \== Not a Heading
398419
#
399420
# A heading may contain only one type of nested block:
400421
#
@@ -1147,10 +1168,10 @@ def dummy_instance_method(foo, bar); end;
11471168
#
11481169
# Here is the <tt>:call-seq:</tt> directive given for the method:
11491170
#
1150-
# # :call-seq:
1151-
# # call_seq_directive(foo, bar)
1152-
# # Can be anything -> bar
1153-
# # Also anything more -> baz or bat
1171+
# :call-seq:
1172+
# call_seq_directive(foo, bar)
1173+
# Can be anything -> bar
1174+
# Also anything more -> baz or bat
11541175
#
11551176
def call_seq_directive
11561177
nil

0 commit comments

Comments
 (0)