U:RDoc::NormalClass[iI"Markup:ETI"RDoc::Markup;TI"Object;To:RDoc::Markup::Document:@parts[o;;[ào:RDoc::Markup::Paragraph;[I"RRDoc::Markup parses plain text documents and attempts to decompose them into ;TI"Otheir constituent parts. Some of these parts are high-level: paragraphs, ;TI"Pchunks of verbatim text, list entries and the like. Other parts happen at ;TI"Rthe character level: a piece of bold text, a word in code font. This markup ;TI"Pis similar in spirit to that used on WikiWiki webs, where folks create web ;TI"2pages using a simple set of formatting rules.;To:RDoc::Markup::BlankLine o; ;[I"LRDoc::Markup and other markup formats do no output formatting, this is ;TI"7handled by the RDoc::Markup::Formatter subclasses.;T@S:RDoc::Markup::Heading:
leveli: textI"Supported Formats;T@o; ;[I"QBesides the RDoc::Markup format, the following formats are built in to RDoc:;T@o:RDoc::Markup::List:
@type: NOTE:@items[o:RDoc::Markup::ListItem:@label[I"
markdown;T;[o; ;[I")The markdown format as described by ;TI"Khttp://daringfireball.net/projects/markdown/. See RDoc::Markdown for ;TI"4details on the parser and supported extensions.;To;;[I"rd;T;[o; ;[I"KThe rdtool format. See RDoc::RD for details on the parser and format.;To;;[I"tomdoc;T;[o; ;[I"MThe TomDoc format as described by http://tomdoc.org/. See RDoc::TomDoc ;TI"8for details on the parser and supported extensions.;T@o; ;[I"@You can choose a markup format using the following methods:;T@o;;;;[o;;[I"per project;T;[o; ;[I"EIf you build your documentation with rake use RDoc::Task#markup.;T@o; ;[I"1If you build your documentation by hand run:;T@o:RDoc::Markup::Verbatim;[I"8rdoc --markup your_favorite_format --write-options
;T:@format0o; ;[I"Jand commit .rdoc_options and ship it with your packaged gem.;To;;[I"
per file;T;[o; ;[I"KAt the top of the file use the :markup: directive to set the ;TI"-default format for the rest of the file.;To;;[I"per comment;T;[o; ;[I"JUse the :markup: directive at the top of a comment you want ;TI"$to write in a different format.;T@S;;i;
I"RDoc::Markup;T@o; ;[I"PRDoc::Markup is extensible at runtime: you can add \new markup elements to ;TI"=be recognized in the documents that RDoc::Markup parses.;T@o; ;[
I"PRDoc::Markup is intended to be the basis for a family of tools which share ;TI"Lthe common requirement that simple, plain-text should be rendered in a ;TI"Jvariety of different output formats and media. It is envisaged that ;TI"ORDoc::Markup could be the basis for formatting RDoc style comment blocks, ;TI"#Wiki entries, and online FAQs.;T@S;;i;
I"
Synopsis;T@o; ;[I"OThis code converts +input_string+ to HTML. The conversion takes place in ;TI"Mthe +convert+ method, so you can use the same RDoc::Markup converter to ;TI"$convert multiple input strings.;T@o;;[
I"require 'rdoc'
;TI"
;TI"5h = RDoc::Markup::ToHtml.new(RDoc::Options.new)
;TI"
;TI""puts h.convert(input_string)
;T;0o; ;[I"DYou can extend the RDoc::Markup parser to recognize new markup ;TI"Fsequences, and to add special processing for text that matches a ;TI"Lregular expression. Here we make WikiWords significant to the parser, ;TI"Fand also make the sequences {word} and \", "")
;TI"
;TI"1puts "
);T@o; ;[ I"DUnlike conventional Wiki markup, general markup can cross line ;TI"Cboundaries. You can turn off the interpretation of markup by ;TI"Epreceding the first character with a backslash (see Escaping ;TI"Text Markup, below).;T@S;;i;
I"
Links;T@o; ;[I"KLinks to starting with +http:+, +https:+, +mailto:+, +ftp:+ or +www.+ ;TI"Qare recognized. An HTTP url that references an external image is converted ;TI""into an inline image element.;T@o; ;[
I"PClasses and methods will be automatically linked to their definition. For ;TI"Qexample, RDoc::Markup will link to this documentation. By default ;TI"Rmethods will only be automatically linked if they contain an _ (all ;TI"Nmethods can be automatically linked through the --hyperlink-all ;TI"command line option).;T@o; ;[ I"MSingle-word methods can be linked by using the # character for ;TI"Finstance methods or :: for class methods. For example, ;TI"R#convert links to #convert. A class or method may be combined like ;TI"#RDoc::Markup#convert.;T@o; ;[I"MA heading inside the documentation can be linked by following the class ;TI"7or method by an @ then the heading name. ;TI"FRDoc::Markup@Links will link to this section like this: ;TI"QRDoc::Markup@Links. Spaces in headings with multiple words must be escaped ;TI"Fwith + like RDoc::Markup@Escaping+Text+Markup. ;TI"NPunctuation and other special characters must be escaped like CGI.escape.;T@o; ;[I"NThe @ can also be used to link to sections. If a section and a ;TI"Gheading share the same name the section is preferred for the link.;T@o; ;[
I"QLinks can also be of the form label[url], in which case +label+ is ;TI"Nused in the displayed text, and +url+ is used as the target. If +label+ ;TI"Rcontains multiple words, put it in braces: {multi word label}[url]. ;TI"LThe +url+ may be an +http:+-type link or a cross-reference to a class, ;TI"#module or method with a label.;T@o; ;[I"QLinks with the rdoc-image:
scheme will create an image tag for ;TI";HTML output. Only fully-qualified URLs are supported.;T@o; ;[ I"QLinks with the rdoc-ref: scheme will link to the referenced class, ;TI"Jmodule, method, file, etc. If the referenced item is does not exist ;TI"Ono link will be generated and rdoc-ref: will be removed from the ;TI"resulting text.;T@o; ;[ I"ILinks starting with rdoc-label:label_name will link to the ;TI"E+label_name+. You can create a label for the current link (for ;TI"Hbidirectional links) by supplying a name for the current link like ;TI"0rdoc-label:label-other:label-mine.;T@o; ;[ I"PLinks starting with +link:+ refer to local files whose path is relative to ;TI"Ethe --op directory. Use rdoc-ref: instead of ;TI"Nlink: to link to files generated by RDoc as the link target may ;TI")be different across RDoc generators.;T@o; ;[I"Example links:;T@o;;[ I""https://github.com/rdoc/rdoc
;TI"mailto:user@example.com
;TI"5{RDoc Documentation}[http://rdoc.rubyforge.org]
;TI"*{RDoc Markup}[rdoc-ref:RDoc::Markup]
;T;0S;;i;
I"Escaping Text Markup;T@o; ;[
I"RText markup can be escaped with a backslash, as in \, which was obtained ;TI"Pwith \\. Except in verbatim sections and between \ tags, ;TI"Mto produce a backslash you have to double it unless it is followed by a ;TI"Qspace, tab or newline. Otherwise, the HTML formatter will discard it, as it ;TI"'is used to escape potential links:;T@o;;[
I"A* The \ must be doubled if not followed by white space: \\.
;TI"J* But not in \ tags: in a Regexp, \S matches non-space.
;TI"9* This is a link to {ruby-lang}[www.ruby-lang.org].
;TI"I* This is not a link, however: \{ruby-lang.org}[www.ruby-lang.org].
;TI"7* This will not be linked to \RDoc::RDoc#document
;T;0o; ;[I"generates:;T@o;;;;[
o;;0;[o; ;[I">The \ must be doubled if not followed by white space: \\.;To;;0;[o; ;[I"GBut not in \ tags: in a Regexp, \S matches non-space.;To;;0;[o; ;[I"5This is a link to {ruby-lang}[www.ruby-lang.org];To;;0;[o; ;[I"EThis is not a link, however: \{ruby-lang.org}[www.ruby-lang.org];To;;0;[o; ;[I"4This will not be linked to \RDoc::RDoc#document;T@o; ;[
I"PInside \ tags, more precisely, leading backslashes are removed only if ;TI"Rfollowed by a markup character (<*_+), a backslash, or a known link ;TI"Qreference (a known class or method). So in the example above, the backslash ;TI"Qof \S would be removed if there was a class or module named +S+ in ;TI"the current context.;T@o; ;[I"KThis behavior is inherited from RDoc version 1, and has been kept for ;TI"4compatibility with existing RDoc documentation.;T@S;;i;
I"Conversion of characters;T@o; ;[I"SHTML will convert two/three dashes to an em-dash. Other common characters are ;TI"converted as well:;T@o;;[
I"em-dash:: -- or ---
;TI"ellipsis:: ...
;TI"
;TI"&single quotes:: 'text' or `text'
;TI"(double quotes:: "text" or ``text''
;TI"
;TI"copyright:: (c)
;TI" registered trademark:: (r)
;T;0o; ;[I"produces:;T@o;;;;[o;;[I"em-dash;T;[o; ;[I"-- or ---;To;;[I"
ellipsis;T;[o; ;[I"...;T@o;;[I"single quotes;T;[o; ;[I"'text' or `text';To;;[I"double quotes;T;[o; ;[I""text" or ``text'';T@o;;[I"copyright;T;[o; ;[I"(c);To;;[I"registered trademark;T;[o; ;[I"(r);T@S;;i;
I"Documenting Source Code;T@o; ;[ I"PComment blocks can be written fairly naturally, either using # on ;TI"Esuccessive lines of the comment, or by including the comment in ;TI"Ia =begin/=end block. If you use the latter form, ;TI"Cthe =begin line _must_ be flagged with an +rdoc+ tag:;T@o;;[
I"=begin rdoc
;TI",Documentation to be processed by RDoc.
;TI"
;TI" ...
;TI"
=end
;T;0o; ;[I"HRDoc stops processing comments if it finds a comment line starting ;TI"Gwith -- right after the # character (otherwise, ;TI"Cit will be treated as a rule if it has three dashes or more). ;TI"CThis can be used to separate external from internal comments, ;TI"Lor to stop a comment being associated with a method, class, or module. ;TI"OCommenting can be turned back on with a line that starts with ++.;T@o;;[I"##
;TI"8# Extract the age and calculate the date-of-birth.
;TI" #--
;TI";# FIXME: fails if the birthday falls on February 29th
;TI" #++
;TI"-# The DOB is returned as a Time object.
;TI"
;TI"def get_dob(person)
;TI"
# ...
;TI" end
;T;0o; ;[ I"ONames of classes, files, and any method names containing an underscore or ;TI"Ppreceded by a hash character are automatically linked from comment text to ;TI"Otheir description. This linking works inside the current class or module, ;TI"Jand with ancestor methods (in included modules or in the superclass).;T@o; ;[I"HMethod parameter lists are extracted and displayed with the method ;TI"Rdescription. If a method calls +yield+, then the parameters passed to yield ;TI"will also be displayed:;T@o;;[I"def fred
;TI" ...
;TI" yield line, address
;T;0o; ;[I"!This will get documented as:;T@o;;[I"$fred() { |line, address| ... }
;T;0o; ;[I"QYou can override this using a comment containing ':yields: ...' immediately ;TI" after the method definition;T@o;;[ I")def fred # :yields: index, position
;TI"
# ...
;TI"
;TI" yield line, address
;T;0o; ;[I"!which will get documented as;T@o;;[I"&fred() { |index, position| ... }
;T;0o; ;[I"J+:yields:+ is an example of a documentation directive. These appear ;TI"Limmediately after the start of the document element they are modifying.;T@o; ;[ I"ORDoc automatically cross-references words with underscores or camel-case. ;TI"KTo suppress cross-references, prefix the word with a \ character. To ;TI"Ginclude special characters like "\n", you'll need to use ;TI"Atwo \ characters in normal text, but only one in \ text:;T@o;;[I""\\n" or "\n"
;T;0o; ;[I"produces:;T@o; ;[I""\\n" or "\n";T@S;;i;
I"Directives;T@o; ;[I":Directives are keywords surrounded by ":" characters.;T@S;;i;
I"#Controlling what is documented;T@o;;;;[
o;;[I"%+:nodoc:+ / :nodoc: all;T;[o; ;[I"@This directive prevents documentation for the element from ;TI"Bbeing generated. For classes and modules, methods, aliases, ;TI"Econstants, and attributes directly within the affected class or ;TI"Cmodule also will be omitted. By default, though, modules and ;TI"Hclasses within that class or module _will_ be documented. This is ;TI"-turned off by adding the +all+ modifier.;T@o;;[I"module MyModule # :nodoc:
;TI" class Input
;TI" end
;TI" end
;TI"
;TI"&module OtherModule # :nodoc: all
;TI" class Output
;TI" end
;TI" end
;T;0o; ;[I"OIn the above code, only class MyModule::Input will be documented.;T@o; ;[ I"LThe +:nodoc:+ directive, like +:enddoc:+, +:stopdoc:+ and +:startdoc:+ ;TI"Jpresented below, is local to the current file: if you do not want to ;TI"Pdocument a module that appears in several files, specify +:nodoc:+ on each ;TI"(appearance, at least once per file.;T@o;;[I"+:stopdoc:+ / +:startdoc:+;T;[o; ;[
I"PStop and start adding new documentation elements to the current container. ;TI"NFor example, if a class has a number of constants that you don't want to ;TI"Pdocument, put a +:stopdoc:+ before the first, and a +:startdoc:+ after the ;TI"Mlast. If you don't specify a +:startdoc:+ by the end of the container, ;TI"=disables documentation for the rest of the current file.;T@o;;[I"+:doc:+;T;[o; ;[I"JForces a method or attribute to be documented even if it wouldn't be ;TI"Potherwise. Useful if, for example, you want to include documentation of a ;TI"particular private method.;T@o;;[I"+:enddoc:+;T;[o; ;[I"PDocument nothing further at the current level: directives +:startdoc:+ and ;TI"R+:doc:+ that appear after this will not be honored for the current container ;TI"2(file, class or module), in the current file.;T@o;;[I",+:notnew:+ / +:not_new:+ / +:not-new:+ ;T;[o; ;[I"IOnly applicable to the +initialize+ instance method. Normally RDoc ;TI"Hassumes that the documentation and parameters for +initialize+ are ;TI"Lactually for the +new+ method, and so fakes out a +new+ for the class. ;TI"RThe +:notnew:+ directive stops this. Remember that +initialize+ is private, ;TI"Mso you won't see the documentation unless you use the +-a+ command line ;TI"option.;T@S;;i;
I"Method arguments;T@o;;;;[o;;[I"%+:arg:+ or +:args:+ _parameters_;T;[o; ;[I"KOverrides the default argument handling with exactly these parameters.;T@o;;[
I"##
;TI"# :args: a, b
;TI"
;TI"def some_method(*a)
;TI" end
;T;0o;;[I")+:yield:+ or +:yields:+ _parameters_;T;[o; ;[I"AOverrides the default yield discovery with these parameters.;T@o;;[I"##
;TI"# :yields: key, value
;TI"
;TI"def each_thing &block
;TI" @things.each(&block)
;TI" end
;T;0o;;[I"+:call-seq:+;T;[
o; ;[I"JLines up to the next blank line or lines with a common prefix in the ;TI"Jcomment are treated as the method's calling sequence, overriding the ;TI">default parsing of method parameters and yield arguments.;T@o; ;[I" Multiple lines may be used.;T@o;;[I"# :call-seq:
;TI"-# ARGF.readlines(sep=$/) -> array
;TI"-# ARGF.readlines(limit) -> array
;TI"-# ARGF.readlines(sep, limit) -> array
;TI"#
;TI"(# ARGF.to_a(sep=$/) -> array
;TI"(# ARGF.to_a(limit) -> array
;TI"(# ARGF.to_a(sep, limit) -> array
;TI"#
;TI"1# The remaining lines are documentation ...
;T;0S;;i;
I"
Sections;T@o; ;[
I"RSections allow you to group methods in a class into sensible containers. If ;TI"Kyou use the sections 'Public', 'Internal' and 'Deprecated' (the three ;TI"Qallowed method statuses from TomDoc) the sections will be displayed in that ;TI"Qorder placing the most useful methods at the top. Otherwise, sections will ;TI"(be displayed in alphabetical order.;T@o;;;;[o;;[I"+:category:+ _section_;T;[o; ;[I"PAdds this item to the named +section+ overriding the current section. Use ;TI"Ithis to group methods by section in RDoc output while maintaining a ;TI"+sensible ordering (like alphabetical).;T@o;;[I""# :category: Utility Methods
;TI"#
;TI"# CGI escapes +text+
;TI"
;TI"def convert_string text
;TI" CGI.escapeHTML text
;TI" end
;T;0o; ;[I"CAn empty category will place the item in the default category:;T@o;;[I"# :category:
;TI"#
;TI".# This method is in the default category
;TI"
;TI"def some_method
;TI"
# ...
;TI" end
;T;0o; ;[I"MUnlike the :section: directive, :category: is not sticky. The category ;TI"@only applies to the item immediately following the comment.;T@o; ;[I"OUse the :section: directive to provide introductory text for a section of ;TI"documentation.;T@o;;[I"+:section:+ _title_;T;[o; ;[
I"MProvides section introductory text in RDoc output. The title following ;TI"N+:section:+ is used as the section name and the remainder of the comment ;TI"Ocontaining the section is used as introductory text. A section's comment ;TI"Pblock must be separated from following comment blocks. Use an empty title ;TI"&to switch to the default section.;T@o; ;[ I"HThe :section: directive is sticky, so subsequent methods, aliases, ;TI"Iattributes, and classes will be contained in this section until the ;TI"Osection is changed. The :category: directive will override the :section: ;TI"directive.;T@o; ;[ I"OA :section: comment block may have one or more lines before the :section: ;TI"Ndirective. These will be removed, and any identical lines at the end of ;TI"Lthe block are also removed. This allows you to add visual cues to the ;TI"
section.;T@o; ;[I"
Example:;T@o;;[I"0# ----------------------------------------
;TI"# :section: My Section
;TI")# This is the section that I wrote.
;TI"+# See it glisten in the noon-day sun.
;TI"0# ----------------------------------------
;TI"
;TI"##
;TI"# Comment for some_method
;TI"
;TI"def some_method
;TI"
# ...
;TI" end
;T;0S;;i;
I"Other directives;T@o;;;;[ o;;[I"+:markup:+ _type_;T;[o; ;[I"KOverrides the default markup type for this comment with the specified ;TI"Pmarkup type. For Ruby files, if the first comment contains this directive ;TI"=it is applied automatically to all comments in the file.;T@o; ;[ I"GUnless you are converting between markup formats you should use a ;TI"J.rdoc_options
file to specify the default documentation ;TI"Jformat for your entire project. See RDoc::Options@Saved+Options for ;TI"instructions.;T@o; ;[I"NAt the top of a file the +:markup:+ directive applies to the entire file:;T@o;;[I"# coding: UTF-8
;TI"# :markup: TomDoc
;TI"
;TI"# TomDoc comment here ...
;TI"
;TI"class MyClass
;TI"
# ...
;T;0o; ;[I"For just one comment:;T@o;;[I"
# ...
;TI" end
;TI"
;TI"# :markup: RDoc
;TI"#
;TI"3# This is a comment in RDoc markup format ...
;TI"
;TI"def some_method
;TI"
# ...
;T;0o; ;[I"LSee Markup@CONTRIBUTING for instructions on adding a new markup format.;T@o;;[I"+:include:+ _filename_;T;[ o; ;[I"JInclude the contents of the named file at this point. This directive ;TI"Imust appear alone on one line, possibly preceded by spaces. In this ;TI"Fposition, it can be escaped with a \ in front of the first colon.;T@o; ;[ I"PThe file will be searched for in the directories listed by the +--include+ ;TI"Ooption, or in the current directory by default. The contents of the file ;TI"Mwill be shifted to have the same indentation as the ':' at the start of ;TI"the +:include:+ directive.;T@o;;[I"+:title:+ _text_;T;[o; ;[I"JSets the title for the document. Equivalent to the --title ;TI"Pcommand line parameter. (The command line parameter overrides any :title: ;TI"directive in the source).;T@o;;[I"+:main:+ _name_;T;[o; ;[I">Equivalent to the --main command line parameter.;T:
@fileI"lib/rdoc/markup.rb;T:0@omit_headings_from_table_of_contents_below0;0;0[[
I"attribute_manager;TI"R;T:publicFI"lib/rdoc/markup.rb;T[ [ [[I"
class;T[[;[[I"new;T@U[I"
parse;F@U[:protected[ [:private[ [I"
instance;T[[;[ [I"
add_html;F@U[I"add_special;F@U[I"add_word_pair;F@U[I"convert;F@U[;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ;0;0[@PI"lib/rdoc/parser.rb;TI"lib/rdoc/rd.rb;TI"lib/rdoc/stats.rb;TI"lib/rdoc/test_case.rb;TI"lib/rdoc/tom_doc.rb;T@PcRDoc::TopLevel