Class: RD::RD2MANVisitor
Constant Summary
collapse
- SYSTEM_NAME =
"RDtool -- RD2ManVisitor"
- SYSTEM_VERSION =
"$Version: 0.6.21$"
- VERSION =
Version.new_from_version_string(SYSTEM_NAME, SYSTEM_VERSION)
- OUTPUT_SUFFIX =
"1"
- INCLUDE_SUFFIX =
["1"]
Constants included
from MethodParse
MethodParse::KIND2NUM
Instance Attribute Summary
#filename, #include_suffix
Class Method Summary
collapse
Instance Method Summary
collapse
-
#apply_to_Code(element, content) ⇒ Object
-
#apply_to_DescList(element, items) ⇒ Object
-
#apply_to_DescListItem(element, term, description) ⇒ Object
-
#apply_to_DocumentElement(element, content) ⇒ Object
-
#apply_to_Emphasis(element, content) ⇒ Object
-
#apply_to_EnumList(element, items) ⇒ Object
-
#apply_to_EnumListItem(element, content) ⇒ Object
-
#apply_to_Footnote(element, content) ⇒ Object
-
#apply_to_Headline(element, title) ⇒ Object
-
#apply_to_Index(element, content) ⇒ Object
-
#apply_to_ItemList(element, items) ⇒ Object
-
#apply_to_ItemListItem(element, content) ⇒ Object
-
#apply_to_Keyboard(element, content) ⇒ Object
-
#apply_to_MethodList(element, items) ⇒ Object
-
#apply_to_MethodListItem(element, term, description) ⇒ Object
-
#apply_to_Reference(element, content) ⇒ Object
-
#apply_to_RefToElement(element, content) ⇒ Object
-
#apply_to_RefToOtherFile(element, content) ⇒ Object
-
#apply_to_RefToURL(element, content) ⇒ Object
-
#apply_to_String(element) ⇒ Object
-
#apply_to_StringElement(element) ⇒ Object
-
#apply_to_TextBlock(element, content) ⇒ Object
RDVisitor#apply_to_Include.
-
#apply_to_Var(element, content) ⇒ Object
-
#apply_to_Verb(element) ⇒ Object
-
#apply_to_Verbatim(element) ⇒ Object
-
#initialize ⇒ RD2MANVisitor
constructor
A new instance of RD2MANVisitor.
-
#visit(tree) ⇒ Object
analize_method, kind2num, kind2str, make_method_index, make_mindex_label, str2kind, tr_method
Methods inherited from RDVisitor
#apply_to_DescListItemTerm, #apply_to_MethodListItemTerm, #prepare_labels, #refer_external
#apply_to_Include
Methods included from SearchFile
#search_file
Methods inherited from Visitor
define_visit_Nonterminal, define_visit_Terminal, #visit_DescListItem, #visit_MethodListItem, #visit_Reference, #visit_children
Constructor Details
Returns a new instance of RD2MANVisitor.
30
31
32
33
34
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 30
def initialize
@enumcounter = 0
@index = {}
@filename = nil
end
|
Class Method Details
.version ⇒ Object
22
23
24
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 22
def self.version
VERSION
end
|
Instance Method Details
#apply_to_Code(element, content) ⇒ Object
161
162
163
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 161
def apply_to_Code(element, content)
%{\\&\\fB#{content.join.sub(/\./, '\\.')}\\fP}
end
|
#apply_to_DescList(element, items) ⇒ Object
89
90
91
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 89
def apply_to_DescList(element, items)
items.map{ |i| i =~ /\n$/ ? i : i + "\n" }.join("")
end
|
#apply_to_DescListItem(element, term, description) ⇒ Object
106
107
108
109
110
111
112
113
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 106
def apply_to_DescListItem(element, term, description)
anchor = refer(element)
if description.empty?
".TP\n.fi\n.B\n#{term}"
else
%[.TP\n.fi\n.B\n#{term}\n#{description.join("\n")}].chomp
end
end
|
#apply_to_DocumentElement(element, content) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 41
def apply_to_DocumentElement(element, content)
content = content.join
title = @filename || ARGF.filename || "Untitled"
title = File.basename title
title = title.sub(/\.rd$/i, '')
<<"EOT"
.\\" DO NOT MODIFY THIS FILE! it was generated by rd2
.TH #{title} 1 "#{Time.now.strftime '%B %Y'}"
#{content}
EOT
end
|
#apply_to_Emphasis(element, content) ⇒ Object
157
158
159
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 157
def apply_to_Emphasis(element, content)
%Q[\\fI#{content.join}\\fP]
end
|
#apply_to_EnumList(element, items) ⇒ Object
84
85
86
87
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 84
def apply_to_EnumList(element, items)
@enumcounter = 0
items.join
end
|
#apply_to_EnumListItem(element, content) ⇒ Object
101
102
103
104
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 101
def apply_to_EnumListItem(element, content)
@enumcounter += 1
%Q[.TP\n#{@enumcounter}.\n#{content.join("\n")}]
end
|
214
215
216
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 214
def (element, content)
""
end
|
#apply_to_Headline(element, title) ⇒ Object
53
54
55
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 53
def apply_to_Headline(element, title)
element.level <= 1 ? ".SH #{title}\n" : ".SS #{title}\n"
end
|
#apply_to_Index(element, content) ⇒ Object
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 173
def apply_to_Index(element, content)
tmp = []
element.each do |i|
tmp.push(i) if i.is_a?(String)
end
key = meta_char_escape(tmp.join)
if @index.has_key?(key)
""
else
num = @index[key] = @index.size
%{\\&\\fB#{content.join.sub(/\./, '\\.')}\\fP}
end
end
|
#apply_to_ItemList(element, items) ⇒ Object
78
79
80
81
82
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 78
def apply_to_ItemList(element, items)
items.collect! do |x| x.sub(/\n\n/, "\n") end
items = items.join(".IP\n.B\n\\(bu\n") ".IP\n.B\n\\(bu\n" + items
end
|
#apply_to_ItemListItem(element, content) ⇒ Object
97
98
99
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 97
def apply_to_ItemListItem(element, content)
content.map{ |c| c =~ /\n$/ ? c : c + "\n" }.join("")
end
|
#apply_to_Keyboard(element, content) ⇒ Object
169
170
171
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 169
def apply_to_Keyboard(element, content)
content.join
end
|
#apply_to_MethodList(element, items) ⇒ Object
93
94
95
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 93
def apply_to_MethodList(element, items)
items.map{ |i| i =~ /\n$/ ? i : i + "\n" }.join("")
end
|
#apply_to_MethodListItem(element, term, description) ⇒ Object
115
116
117
118
119
120
121
122
123
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 115
def apply_to_MethodListItem(element, term, description)
term = parse_method(term) anchor = refer(element)
if description.empty?
".TP\n.fi\n.B\n#{term}"
else
%[.TP\n.fi\n.B\n#{term}\n#{description.join("\n")}]
end
end
|
#apply_to_Reference(element, content) ⇒ Object
188
189
190
191
192
193
194
195
196
197
198
199
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 188
def apply_to_Reference(element, content)
case element.label
when Reference::URL
apply_to_RefToURL(element, content)
when Reference::RDLabel
if element.label.filename
apply_to_RefToOtherFile(element, content)
else
apply_to_RefToElement(element, content)
end
end
end
|
#apply_to_RefToElement(element, content) ⇒ Object
201
202
203
204
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 201
def apply_to_RefToElement(element, content)
content = content.join
content.sub(/^function#/, "")
end
|
#apply_to_RefToOtherFile(element, content) ⇒ Object
206
207
208
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 206
def apply_to_RefToOtherFile(element, content)
content.join
end
|
#apply_to_RefToURL(element, content) ⇒ Object
210
211
212
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 210
def apply_to_RefToURL(element, content)
content.join
end
|
#apply_to_String(element) ⇒ Object
222
223
224
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 222
def apply_to_String(element)
meta_char_escape(element)
end
|
#apply_to_StringElement(element) ⇒ Object
153
154
155
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 153
def apply_to_StringElement(element)
apply_to_String(element.content)
end
|
#apply_to_TextBlock(element, content) ⇒ Object
RDVisitor#apply_to_Include
59
60
61
62
63
64
65
66
67
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 59
def apply_to_TextBlock(element, content)
if RD::DescListItem === element.parent ||
RD::ItemListItem === element.parent ||
RD::EnumListItem === element.parent
return content.join
else
return ".PP\n" + content.join
end
end
|
#apply_to_Var(element, content) ⇒ Object
165
166
167
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 165
def apply_to_Var(element, content)
content.join
end
|
#apply_to_Verb(element) ⇒ Object
218
219
220
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 218
def apply_to_Verb(element)
apply_to_String(element.content)
end
|
#apply_to_Verbatim(element) ⇒ Object
69
70
71
72
73
74
75
76
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 69
def apply_to_Verbatim(element)
content = []
element.each_line do |i|
content.push(apply_to_String(i))
end
%Q[.nf\n\\& #{content.join("\\& ")}.fi\n]
end
|
#visit(tree) ⇒ Object
36
37
38
39
|
# File 'lib/rd2odt/rdtool/rd/rd2man-lib.rb', line 36
def visit(tree)
prepare_labels(tree, "")
super(tree)
end
|