|
99 | 99 | # |
100 | 100 | # See RDoc::MarkupReference. |
101 | 101 | # |
102 | | -# === Escaping Text Markup |
103 | | -# |
104 | | -# Text markup can be escaped with a backslash, as in \<tt>, which was obtained |
105 | | -# with <tt>\\<tt></tt>. Except in verbatim sections and between \<tt> tags, |
106 | | -# to produce a backslash you have to double it unless it is followed by a |
107 | | -# space, tab or newline. Otherwise, the HTML formatter will discard it, as it |
108 | | -# is used to escape potential links: |
109 | | -# |
110 | | -# * The \ must be doubled if not followed by white space: \\. |
111 | | -# * But not in \<tt> tags: in a Regexp, <tt>\S</tt> matches non-space. |
112 | | -# * This is a link to {ruby-lang}[https://www.ruby-lang.org]. |
113 | | -# * This is not a link, however: \{ruby-lang.org}[https://www.ruby-lang.org]. |
114 | | -# * This will not be linked to \RDoc::RDoc#document |
115 | | -# |
116 | | -# generates: |
117 | | -# |
118 | | -# * The \ must be doubled if not followed by white space: \\. |
119 | | -# * But not in \<tt> tags: in a Regexp, <tt>\S</tt> matches non-space. |
120 | | -# * This is a link to {ruby-lang}[https://www.ruby-lang.org] |
121 | | -# * This is not a link, however: \{ruby-lang.org}[https://www.ruby-lang.org] |
122 | | -# * This will not be linked to \RDoc::RDoc#document |
123 | | -# |
124 | | -# Inside \<tt> tags, more precisely, leading backslashes are removed only if |
125 | | -# followed by a markup character (<tt><*_+</tt>), a backslash, or a known link |
126 | | -# reference (a known class or method). So in the example above, the backslash |
127 | | -# of <tt>\S</tt> would be removed if there was a class or module named +S+ in |
128 | | -# the current context. |
129 | | -# |
130 | | -# This behavior is inherited from RDoc version 1, and has been kept for |
131 | | -# compatibility with existing RDoc documentation. |
132 | | -# |
133 | | -# === Conversion of characters |
134 | | -# |
135 | | -# HTML will convert two/three dashes to an em-dash. Other common characters are |
136 | | -# converted as well: |
137 | | -# |
138 | | -# em-dash:: -- or --- |
139 | | -# ellipsis:: ... |
140 | | -# |
141 | | -# single quotes:: 'text' or `text' |
142 | | -# double quotes:: "text" or ``text'' |
143 | | -# |
144 | | -# copyright:: (c) |
145 | | -# registered trademark:: (r) |
146 | | -# |
147 | | -# produces: |
148 | | -# |
149 | | -# em-dash:: -- or --- |
150 | | -# ellipsis:: ... |
151 | | -# |
152 | | -# single quotes:: 'text' or `text' |
153 | | -# double quotes:: "text" or ``text'' |
154 | | -# |
155 | | -# copyright:: (c) |
156 | | -# registered trademark:: (r) |
157 | | -# |
158 | | -# |
159 | | -# == Documenting Source Code |
160 | | -# |
161 | | -# Comment blocks can be written fairly naturally, either using <tt>#</tt> on |
162 | | -# successive lines of the comment, or by including the comment in |
163 | | -# a <tt>=begin</tt>/<tt>=end</tt> block. If you use the latter form, |
164 | | -# the <tt>=begin</tt> line _must_ be flagged with an +rdoc+ tag: |
165 | | -# |
166 | | -# =begin rdoc |
167 | | -# Documentation to be processed by RDoc. |
168 | | -# |
169 | | -# ... |
170 | | -# =end |
171 | | -# |
172 | | -# RDoc stops processing comments if it finds a comment line starting |
173 | | -# with <tt>--</tt> right after the <tt>#</tt> character (otherwise, |
174 | | -# it will be treated as a rule if it has three dashes or more). |
175 | | -# This can be used to separate external from internal comments, |
176 | | -# or to stop a comment being associated with a method, class, or module. |
177 | | -# Commenting can be turned back on with a line that starts with <tt>++</tt>. |
178 | | -# |
179 | | -# ## |
180 | | -# # Extract the age and calculate the date-of-birth. |
181 | | -# #-- |
182 | | -# # FIXME: fails if the birthday falls on February 29th |
183 | | -# #++ |
184 | | -# # The DOB is returned as a Time object. |
185 | | -# |
186 | | -# def get_dob(person) |
187 | | -# # ... |
188 | | -# end |
189 | | -# |
190 | | -# Names of classes, files, and any method names containing an underscore or |
191 | | -# preceded by a hash character are automatically linked from comment text to |
192 | | -# their description. This linking works inside the current class or module, |
193 | | -# and with ancestor methods (in included modules or in the superclass). |
194 | | -# |
195 | | -# Method parameter lists are extracted and displayed with the method |
196 | | -# description. If a method calls +yield+, then the parameters passed to yield |
197 | | -# will also be displayed: |
198 | | -# |
199 | | -# def fred |
200 | | -# ... |
201 | | -# yield line, address |
202 | | -# |
203 | | -# This will get documented as: |
204 | | -# |
205 | | -# fred() { |line, address| ... } |
206 | | -# |
207 | | -# You can override this using a comment containing ':yields: ...' immediately |
208 | | -# after the method definition |
209 | | -# |
210 | | -# def fred # :yields: index, position |
211 | | -# # ... |
212 | | -# |
213 | | -# yield line, address |
214 | | -# |
215 | | -# which will get documented as |
216 | | -# |
217 | | -# fred() { |index, position| ... } |
218 | | -# |
219 | | -# +:yields:+ is an example of a documentation directive. These appear |
220 | | -# immediately after the start of the document element they are modifying. |
221 | | -# |
222 | | -# RDoc automatically cross-references words with underscores or camel-case. |
223 | | -# To suppress cross-references, prefix the word with a \ character. To |
224 | | -# include special characters like "<tt>\n</tt>", you'll need to use |
225 | | -# two \ characters in normal text, but only one in \<tt> text: |
226 | | -# |
227 | | -# "\\n" or "<tt>\n</tt>" |
228 | | -# |
229 | | -# produces: |
230 | | -# |
231 | | -# "\\n" or "<tt>\n</tt>" |
232 | | -# |
233 | | -# == Directives |
234 | | -# |
235 | | -# Directives are keywords surrounded by ":" characters. |
236 | | -# |
237 | | -# === Controlling what is documented |
238 | | -# |
239 | | -# [+:nodoc:+ / <tt>:nodoc: all</tt>] |
240 | | -# This directive prevents documentation for the element from |
241 | | -# being generated. For classes and modules, methods, aliases, |
242 | | -# constants, and attributes directly within the affected class or |
243 | | -# module also will be omitted. By default, though, modules and |
244 | | -# classes within that class or module _will_ be documented. This is |
245 | | -# turned off by adding the +all+ modifier. |
246 | | -# |
247 | | -# module MyModule # :nodoc: |
248 | | -# class Input |
249 | | -# end |
250 | | -# end |
251 | | -# |
252 | | -# module OtherModule # :nodoc: all |
253 | | -# class Output |
254 | | -# end |
255 | | -# end |
256 | | -# |
257 | | -# In the above code, only class <tt>MyModule::Input</tt> will be documented. |
258 | | -# |
259 | | -# The +:nodoc:+ directive, like +:enddoc:+, +:stopdoc:+ and +:startdoc:+ |
260 | | -# presented below, is local to the current file: if you do not want to |
261 | | -# document a module that appears in several files, specify +:nodoc:+ on each |
262 | | -# appearance, at least once per file. |
263 | | -# |
264 | | -# [+:stopdoc:+ / +:startdoc:+] |
265 | | -# Stop and start adding new documentation elements to the current container. |
266 | | -# For example, if a class has a number of constants that you don't want to |
267 | | -# document, put a +:stopdoc:+ before the first, and a +:startdoc:+ after the |
268 | | -# last. If you don't specify a +:startdoc:+ by the end of the container, |
269 | | -# disables documentation for the rest of the current file. |
270 | | -# |
271 | | -# [+:doc:+] |
272 | | -# Forces a method or attribute to be documented even if it wouldn't be |
273 | | -# otherwise. Useful if, for example, you want to include documentation of a |
274 | | -# particular private method. |
275 | | -# |
276 | | -# [+:enddoc:+] |
277 | | -# Document nothing further at the current level: directives +:startdoc:+ and |
278 | | -# +:doc:+ that appear after this will not be honored for the current container |
279 | | -# (file, class or module), in the current file. |
280 | | -# |
281 | | -# [+:notnew:+ / +:not_new:+ / +:not-new:+ ] |
282 | | -# Only applicable to the +initialize+ instance method. Normally RDoc |
283 | | -# assumes that the documentation and parameters for +initialize+ are |
284 | | -# actually for the +new+ method, and so fakes out a +new+ for the class. |
285 | | -# The +:notnew:+ directive stops this. Remember that +initialize+ is private, |
286 | | -# so you won't see the documentation unless you use the +-a+ command line |
287 | | -# option. |
288 | | -# |
289 | | -# === Method arguments |
290 | | -# |
291 | | -# [+:arg:+ or +:args:+ _parameters_] |
292 | | -# Overrides the default argument handling with exactly these parameters. |
293 | | -# |
294 | | -# ## |
295 | | -# # :args: a, b |
296 | | -# |
297 | | -# def some_method(*a) |
298 | | -# end |
299 | | -# |
300 | | -# [+:yield:+ or +:yields:+ _parameters_] |
301 | | -# Overrides the default yield discovery with these parameters. |
302 | | -# |
303 | | -# ## |
304 | | -# # :yields: key, value |
305 | | -# |
306 | | -# def each_thing &block |
307 | | -# @things.each(&block) |
308 | | -# end |
309 | | -# |
310 | | -# [+:call-seq:+] |
311 | | -# Lines up to the next blank line or lines with a common prefix in the |
312 | | -# comment are treated as the method's calling sequence, overriding the |
313 | | -# default parsing of method parameters and yield arguments. |
314 | | -# |
315 | | -# Multiple lines may be used. |
316 | | -# |
317 | | -# # :call-seq: |
318 | | -# # ARGF.readlines(sep=$/) -> array |
319 | | -# # ARGF.readlines(limit) -> array |
320 | | -# # ARGF.readlines(sep, limit) -> array |
321 | | -# # |
322 | | -# # ARGF.to_a(sep=$/) -> array |
323 | | -# # ARGF.to_a(limit) -> array |
324 | | -# # ARGF.to_a(sep, limit) -> array |
325 | | -# # |
326 | | -# # The remaining lines are documentation ... |
327 | | -# |
328 | | -# === Sections |
329 | | -# |
330 | | -# Sections allow you to group methods in a class into sensible containers. If |
331 | | -# you use the sections 'Public', 'Internal' and 'Deprecated' (the three |
332 | | -# allowed method statuses from TomDoc) the sections will be displayed in that |
333 | | -# order placing the most useful methods at the top. Otherwise, sections will |
334 | | -# be displayed in alphabetical order. |
335 | | -# |
336 | | -# [+:category:+ _section_] |
337 | | -# Adds this item to the named +section+ overriding the current section. Use |
338 | | -# this to group methods by section in RDoc output while maintaining a |
339 | | -# sensible ordering (like alphabetical). |
340 | | -# |
341 | | -# # :category: Utility Methods |
342 | | -# # |
343 | | -# # CGI escapes +text+ |
344 | | -# |
345 | | -# def convert_string text |
346 | | -# CGI.escapeHTML text |
347 | | -# end |
348 | | -# |
349 | | -# An empty category will place the item in the default category: |
350 | | -# |
351 | | -# # :category: |
352 | | -# # |
353 | | -# # This method is in the default category |
354 | | -# |
355 | | -# def some_method |
356 | | -# # ... |
357 | | -# end |
358 | | -# |
359 | | -# Unlike the :section: directive, :category: is not sticky. The category |
360 | | -# only applies to the item immediately following the comment. |
361 | | -# |
362 | | -# Use the :section: directive to provide introductory text for a section of |
363 | | -# documentation. |
364 | | -# |
365 | | -# [+:section:+ _title_] |
366 | | -# Provides section introductory text in RDoc output. The title following |
367 | | -# +:section:+ is used as the section name and the remainder of the comment |
368 | | -# containing the section is used as introductory text. A section's comment |
369 | | -# block must be separated from following comment blocks. Use an empty title |
370 | | -# to switch to the default section. |
371 | | -# |
372 | | -# The :section: directive is sticky, so subsequent methods, aliases, |
373 | | -# attributes, and classes will be contained in this section until the |
374 | | -# section is changed. The :category: directive will override the :section: |
375 | | -# directive. |
376 | | -# |
377 | | -# A :section: comment block may have one or more lines before the :section: |
378 | | -# directive. These will be removed, and any identical lines at the end of |
379 | | -# the block are also removed. This allows you to add visual cues to the |
380 | | -# section. |
381 | | -# |
382 | | -# Example: |
383 | | -# |
384 | | -# # ---------------------------------------- |
385 | | -# # :section: My Section |
386 | | -# # This is the section that I wrote. |
387 | | -# # See it glisten in the noon-day sun. |
388 | | -# # ---------------------------------------- |
389 | | -# |
390 | | -# ## |
391 | | -# # Comment for some_method |
392 | | -# |
393 | | -# def some_method |
394 | | -# # ... |
395 | | -# end |
396 | | -# |
397 | | -# === Other directives |
398 | | -# |
399 | | -# [+:markup:+ _type_] |
400 | | -# Overrides the default markup type for this comment with the specified |
401 | | -# markup type. For Ruby files, if the first comment contains this directive |
402 | | -# it is applied automatically to all comments in the file. |
403 | | -# |
404 | | -# Unless you are converting between markup formats you should use a |
405 | | -# <code>.rdoc_options</code> file to specify the default documentation |
406 | | -# format for your entire project. See RDoc::Options@Saved+Options for |
407 | | -# instructions. |
408 | | -# |
409 | | -# At the top of a file the +:markup:+ directive applies to the entire file: |
410 | | -# |
411 | | -# # coding: UTF-8 |
412 | | -# # :markup: TomDoc |
413 | | -# |
414 | | -# # TomDoc comment here ... |
415 | | -# |
416 | | -# class MyClass |
417 | | -# # ... |
418 | | -# |
419 | | -# For just one comment: |
420 | | -# |
421 | | -# # ... |
422 | | -# end |
423 | | -# |
424 | | -# # :markup: RDoc |
425 | | -# # |
426 | | -# # This is a comment in RDoc markup format ... |
427 | | -# |
428 | | -# def some_method |
429 | | -# # ... |
430 | | -# |
431 | | -# See Markup@CONTRIBUTING for instructions on adding a new markup format. |
432 | | -# |
433 | | -# [+:include:+ _filename_] |
434 | | -# Include the contents of the named file at this point. This directive |
435 | | -# must appear alone on one line, possibly preceded by spaces. In this |
436 | | -# position, it can be escaped with a \ in front of the first colon. |
437 | | -# |
438 | | -# The file will be searched for in the directories listed by the +--include+ |
439 | | -# option, or in the current directory by default. The contents of the file |
440 | | -# will be shifted to have the same indentation as the ':' at the start of |
441 | | -# the +:include:+ directive. |
442 | | -# |
443 | | -# [+:title:+ _text_] |
444 | | -# Sets the title for the document. Equivalent to the <tt>--title</tt> |
445 | | -# command line parameter. (The command line parameter overrides any :title: |
446 | | -# directive in the source). |
447 | | -# |
448 | | -# [+:main:+ _name_] |
449 | | -# Equivalent to the <tt>--main</tt> command line parameter. |
450 | | -# |
451 | 102 | #-- |
452 | 103 | # Original Author:: Dave Thomas, [email protected] |
453 | 104 | # License:: Ruby license |
|
0 commit comments