= RD working draft Japanese version is (()). == What is RD? RD is Ruby's POD, embeddable documentation format in script file. RD is influenced mainly from plain2, a program to translate from plain text to some mark-up language. So, RD looks like plain text, and its simpleness and neatness make it easy to read and write. == How does the interpreter work for RD? Ruby's interpreter, (({ruby})), simply ignores text between a line beginning with "(({=begin}))" and one beginning with "(({=end}))". So, RD is not only embeddable. You can write anything between (({=begin})) and (({=end})). RD is one of them, but RD will be a standard one.((- If you are interested in others, see rubyapi2 (()) for example. -)) == Concepts and Syntax === Element, Block and Inline We will use the term "Element" for features of RD which add information of document structure to text. In addition, we use a term "(())" for Elements for large and global structures, and a term "(())" for ones for small and local decorations. Paragraph, headline or list is a kind of Block. RD uses indentation and special characters to describe Blocks. You can also write complicated structure to nested Blocks. And this style of Block looks naturally like plain text format. See (()) for details. Emphasis, code or reference is a kind of Inline. Parentheses and special characters, like (('((? ... ?))')), are used for Inline. Almost all Inline may be nested inside each other. See (()) for more details. === Block ==== Basic Syntax Block has line oriented syntax. i.e. each character on the same line belongs to the same Block. And the indentation of the line represents nesting level and type of Block. The first character of the line represents the type of Block. + Concepts and Terms :Baseline Baseline is standard depth of indent. Relative depth between indent of one line and Baseline affects its Block-type. :Head Char Head Char is the first character of line, except whitespace. :STRINGLINE STRINGLINE is line which consists of strings. STRINGLINE doesn't have "(({*}))", "(({(((|num|)))}))", "(({:}))", "(({=}))" nor "(({+}))" as Head Char. But if the line is indented, "(({=}))" and "(({+}))" can be Head Char. :WHITELINE WHITELINE is a line which consists of whitespace, "(({\s}))", "(({\t}))" and "(({\n}))". :Comment A line which is matched with (({/^#/})) is regarded as a comment. + How Baseline is defined and how it works At the top level, Baseline is at left end, i.e., indent is 0. In List, Baseline is defined by first Block of ListItem. For example, Example: "|" means Baseline |Regard this line as one of TextBlock's in top level. |<- So this Baseline is at the left-most position. *|it is in List. (1) |<- this Baseline is defined by the marked with a (1). * |Different Item of List can have different Baseline inside. |<- So this Baseline differs from one of this list's first item. |Regard this line as one of TextBlock's in top level. |<- So this Baseline is at the left-most position. *|it is in List. (1) |<- this Baseline is defined by the marked with a (1). * |Different Items in Lists can have different Baselines inside. |<- So this Baseline differs from the one of this list's first item. If one Block is nested in another Block, the Baseline of the inside Blocks is deeper than the Baseline of outside Blocks. The relative position between Baseline and indent affects the type of Block. If a (()) has same indent with Baseline, it belongs to (()), otherwise, i.e. it has deeper indent than Baseline, it belongs to (()). ==== Types of Block + Headline Headline consists of a line which (()) is "(({=}))" or "(({+}))". And Headline can't include more than one line. Headline can be on only top level. Example: |<- Regard this as top level Baseline. = Headline 1. === Headline 1.1.1. + Headline 1.1.1.1.1. = Headline 1. === Headline 1.1.1. + Headline 1.1.1.1.1. Headline Mark represents level of Headline. See following figure. first Mark is biggest one, and last Mark has two parts. Fig: Headline Marks = == === ==== + ++ Text which follows Mark is title of Headline. It is also used as Label of (()). Title of Headline can contain (())s except for (()) and Footnote. + Include Include is a line that line head "(({<<<}))" and included file name. You can input from other file text, both RD and target format, with Include. When you include RD file, included file name have to have ".rd" or ".rb" as suffix, like "foo.rd", and write full name (not full path) of file after "(({<<<}))". For example, <<< foo.rd When you include target format file, include file name have to have suffix of target format standard one, for example ".html" in the case of outputting HTML, ".texi" in the case of outputting Texinfo, and write base name of file after "(({<<<}))". For example, <<< foo RD formatter include "foo.html" to output HTML, and include "foo.texi" to output Texinfo. If you want to use Include for target format, you should prepare plural type of included file. + TextBlock TextBlock is composed of (())s, but the (())s must have same indent with (()). If its indent is deeper than (()), the (()) belongs to (()). TextBlock can include (()) inside. Example: | This is TextBlock. Second line of same TextBlock. This line is not TextBlock, but Verbatim. * And this line is List. (But this line is exactly TextBlock in ListItem.) And this example is formatted such like: This is TextBlock. Second line of same TextBlock. This line is not TextBlock, but Verbatim. * And this line is List. (But this line is exactly TextBlock in ListItem.) + Verbatim You can use Verbatim to cite Ruby script. Verbatim is composed of (())s, and they must be indented deeper than (()). Verbatim can also include a line whose (()) is "(({*}))", "(({(1)}))" and "(({:}))", But it can't be first line of Verbatim, it is regarded as (()). Verbatim can't include a line which is indented shallower than first line. Verbatim can include (()). You can't use (()) in Verbatim. Example: This is Verbatim. Even if a line is indented deeper than first line, it is also in same Verbatim. * A line seems like list is also included in Verbatim. But if the line is indented shallower, it is not in same Verbatim. It is in other Verbatim. And this example is formatted such like: This is Verbatim. Even if a line is indented deeper than first line, it is also in same Verbatim. * A line seems like list is also included in Verbatim. But if the line is indented shallower, it is not in same Verbatim. It is in other Verbatim. + List List is special (()). List is composed of ListItems, and ListItem is composed of Blocks. So List can include Blocks inside, even also List itself.((- But List can't include (()) nor (()). -)) ListItem can include (()), and (()) can't include WHITELINE, so when you want to write 2 TextBlock inside ListItem, put a WHITELINE between TextBlocks. There is 3 type of List, "(())", "(())", "(())" and "(()). ++ ItemList ItemList is simple and not numbered List. ItemListItem begins by a line whose (()) is "(({*}))", and first Block of ItemListItem must be (()). Example: * first item of parent list * first item of sub list * second item of sub list text block ( line of first item of parent list) And this example is formatted such like: * first item of parent list * first item of sub list * second item of sub list text block ( line of first item of parent list) ++ EnumList EnumList is numbered List. EnumListItem starts with a line whose (()) is "(({(((|num|)))}))"(((|num|)) is integer). EnumList is same as (()) on other points. Example: (1) first line of parent list * first line of sub list(ItemList) (2) second list of parent list (10) number is ignored... And this example is formatted such like: (1) first line of parent list * first line of sub list(ItemList) (2) second list of parent list (10) number is ignored... ++ DescList DescList is List for descriptions. DescListItem has 2 part. One is Term part, the other is Description part. Term of DescListItem is also used as Label for (()). Term part is composed of a line whose (()) is "(({:}))", and Term part is same as (()), except that a line of Term part can be indented. Description part is starts with next line of Term part. (()) of Description part must be same or deeper than term of Term part of its pair. For example, following style is illegal. Example: : |Term |Description. Description part can include (())s. (()) can be first Block of Description part. Term part can contain (())s except for (()) and (()). Example: :Term first line of Description second line of Description :Term2 * also include List * ... And this example is formatted such like: :Term first line of definition. second line of definition :Term2 * also include list * ... ++ MethodList MethodList is the special type of (()) for explanation methods of your classes. MethodList is similar with (()) in almost all part, but it is labeled differently. RD formatters know it is some kind of program code, e.g. method or constants of class in Ruby or function prototype in C..., which is on Term part of MethodList. So, MethodList is labeled without the part which seems to be parameters of methods. See ((