erbook 5.0.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/Rakefile +6 -79
- data/bin/erbook +25 -319
- data/doc/HelloWorld.spec +23 -21
- data/doc/README +4 -3
- data/doc/api/ERBook.html +35 -0
- data/doc/api/ERBook/Document.html +673 -0
- data/doc/api/ERBook/Document/Node.html +102 -0
- data/doc/api/ERBook/Template.html +670 -0
- data/doc/api/RDoc.html +23 -0
- data/doc/api/RDoc/AnyMethod.html +302 -0
- data/doc/api/RDoc/DummyMarkup.html +73 -0
- data/doc/api/RDoc/DummyMixin.html +23 -0
- data/doc/api/RDoc/DummyOptions.html +140 -0
- data/doc/api/RDoc/TopLevel.html +465 -0
- data/doc/api/String.html +372 -0
- data/doc/api/all-methods.html +253 -0
- data/doc/api/all-namespaces.html +42 -0
- data/doc/api/app.js +18 -0
- data/doc/api/index.html +16 -22
- data/doc/api/jquery.js +11 -0
- data/doc/api/readme.html +35 -0
- data/doc/api/style.css +68 -0
- data/doc/api/syntax_highlight.css +21 -0
- data/doc/erbook.png +0 -0
- data/doc/erbook.svg +150 -88
- data/doc/formats.erb +387 -0
- data/doc/history.erb +62 -0
- data/doc/index.erb +8 -0
- data/doc/index.xhtml +846 -654
- data/doc/intro.erb +97 -0
- data/doc/setup.erb +62 -0
- data/doc/theory.erb +187 -0
- data/doc/usage.erb +39 -0
- data/fmt/xhtml.yaml +497 -372
- data/lib/erbook.rb +18 -10
- data/lib/erbook/document.rb +233 -0
- data/lib/erbook/template.rb +210 -0
- data/lib/erbook/to_xhtml.rb +25 -17
- metadata +39 -45
- data/README +0 -14
- data/doc/api/classes/ERBook.html +0 -164
- data/doc/api/classes/RDoc.html +0 -112
- data/doc/api/classes/RDoc/AnyMethod.html +0 -195
- data/doc/api/classes/RDoc/AnyMethod.src/M000003.html +0 -18
- data/doc/api/classes/RDoc/AnyMethod.src/M000004.html +0 -23
- data/doc/api/classes/RDoc/AnyMethod.src/M000005.html +0 -18
- data/doc/api/classes/RDoc/AnyMethod.src/M000006.html +0 -22
- data/doc/api/classes/RDoc/TopLevel.html +0 -250
- data/doc/api/classes/RDoc/TopLevel.src/M000007.html +0 -18
- data/doc/api/classes/RDoc/TopLevel.src/M000008.html +0 -18
- data/doc/api/classes/RDoc/TopLevel.src/M000009.html +0 -18
- data/doc/api/classes/RDoc/TopLevel.src/M000010.html +0 -29
- data/doc/api/classes/RDoc/TopLevel.src/M000011.html +0 -25
- data/doc/api/classes/RDoc/TopLevel.src/M000012.html +0 -18
- data/doc/api/classes/String.html +0 -196
- data/doc/api/classes/String.src/M000001.html +0 -18
- data/doc/api/classes/String.src/M000002.html +0 -31
- data/doc/api/created.rid +0 -1
- data/doc/api/files/lib/erbook/rdoc_rb.html +0 -116
- data/doc/api/files/lib/erbook/to_xhtml_rb.html +0 -125
- data/doc/api/files/lib/erbook_rb.html +0 -107
- data/doc/api/fr_class_index.html +0 -31
- data/doc/api/fr_file_index.html +0 -29
- data/doc/api/fr_method_index.html +0 -38
- data/doc/api/rdoc-style.css +0 -208
- data/doc/feed-icon-28x28.png +0 -0
- data/doc/manual.erb +0 -812
data/doc/HelloWorld.spec
CHANGED
@@ -1,31 +1,33 @@
|
|
1
1
|
desc: An example format.
|
2
2
|
|
3
3
|
code: |
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
class ERBook::Node
|
5
|
+
def name
|
6
|
+
# dynamically compute (and store)
|
7
|
+
# the name of this node on demand
|
8
|
+
@name ||= generate_name
|
9
|
+
end
|
10
10
|
|
11
|
-
|
11
|
+
private
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
# Returns a random, yet pronounceable, name.
|
14
|
+
def generate_name
|
15
|
+
letters = ('a'..'z').to_a - %w[ c q w x ] # redundant sounds
|
16
|
+
vowels = %w[a e i o u]
|
17
|
+
consonants = letters - vowels
|
18
|
+
sets = [consonants, vowels]
|
16
19
|
|
17
|
-
|
18
|
-
set[rand(set.length)]
|
19
|
-
end.join
|
20
|
+
length = 3 + rand(5)
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
name = (0...length).map do |i|
|
23
|
+
# alternate between consonants and vowels
|
24
|
+
set = sets[i % sets.length]
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
# choose a random letter from the set
|
27
|
+
set[rand(set.length)]
|
28
|
+
end.join
|
29
|
+
|
30
|
+
name
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
@@ -57,6 +59,6 @@ nodes:
|
|
57
59
|
</dl>
|
58
60
|
|
59
61
|
output: |
|
60
|
-
Welcome to the "<%= @
|
62
|
+
Welcome to the "<%= @format[:name] %>" format.
|
61
63
|
<%= @content %>
|
62
64
|
That's all folks!
|
data/doc/README
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
The
|
2
|
-
|
3
|
-
and released into the
|
1
|
+
The "erbook.png" image and its "erbook.svg" source
|
2
|
+
utilize the ["cartoon owl sitting on a book"][1]
|
3
|
+
graphic, which was created and released into the
|
4
|
+
public domain by [Jens Vierbuchen][2] on July 7, 2008.
|
4
5
|
|
5
6
|
[1]: http://openclipart.org/media/files/lemmling/9065
|
6
7
|
[2]: http://openclipart.org/media/people/lemmling
|
data/doc/api/ERBook.html
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
6
|
+
<link rel="stylesheet" href="style.css" type="text/css" charset="utf-8" />
|
7
|
+
<link rel="stylesheet" href="syntax_highlight.css" type="text/css" charset="utf-8" />
|
8
|
+
|
9
|
+
<script src="jquery.js" type="text/javascript" charset="utf-8"></script>
|
10
|
+
<script src="app.js" type="text/javascript" charset="utf-8"></script>
|
11
|
+
<title>Module: ERBook</title>
|
12
|
+
</head>
|
13
|
+
<body>
|
14
|
+
<div id="content">
|
15
|
+
<div class="section module ERBook">
|
16
|
+
<h1 class="title">Module: ERBook</h1>
|
17
|
+
<div class="section constants">
|
18
|
+
<div class="thisclass">
|
19
|
+
<h1>Constants</h1>
|
20
|
+
<dl>
|
21
|
+
|
22
|
+
<dt id="FORMAT_FILES-constant">FORMAT_FILES</dt>
|
23
|
+
<dd>Dir[File.join(FORMATS_DIR, '*.yaml')]</dd>
|
24
|
+
|
25
|
+
<dt id="FORMATS_DIR-constant">FORMATS_DIR</dt>
|
26
|
+
<dd>File.join(INSTALL, 'fmt')</dd>
|
27
|
+
|
28
|
+
</dl>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
</div>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
</body>
|
35
|
+
</html>
|
@@ -0,0 +1,673 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
6
|
+
<link rel="stylesheet" href="../style.css" type="text/css" charset="utf-8" />
|
7
|
+
<link rel="stylesheet" href="../syntax_highlight.css" type="text/css" charset="utf-8" />
|
8
|
+
|
9
|
+
<script src="../jquery.js" type="text/javascript" charset="utf-8"></script>
|
10
|
+
<script src="../app.js" type="text/javascript" charset="utf-8"></script>
|
11
|
+
<title>Class: ERBook::Document</title>
|
12
|
+
</head>
|
13
|
+
<body>
|
14
|
+
<div id="content">
|
15
|
+
<div class="section class ERBook_Document">
|
16
|
+
<h1 class="title">Class: ERBook::Document</h1>
|
17
|
+
<div class="section attributes">
|
18
|
+
<h1>Attributes</h1>
|
19
|
+
|
20
|
+
|
21
|
+
<div class="instance">
|
22
|
+
<h2>Instance Attributes</h2>
|
23
|
+
<table>
|
24
|
+
|
25
|
+
<tr>
|
26
|
+
<th class="name">format</td>
|
27
|
+
<td class="readwrite">
|
28
|
+
[<span id='format-instance_method'>R</span>W]
|
29
|
+
</td>
|
30
|
+
<td class="visibility">
|
31
|
+
public
|
32
|
+
</td>
|
33
|
+
<td class="docstring">
|
34
|
+
<p>
|
35
|
+
Data from the format specification file.
|
36
|
+
</p>
|
37
|
+
|
38
|
+
|
39
|
+
</td>
|
40
|
+
</tr>
|
41
|
+
|
42
|
+
<tr>
|
43
|
+
<th class="name">nodes_by_type</td>
|
44
|
+
<td class="readwrite">
|
45
|
+
[<span id='nodes_by_type-instance_method'>R</span>W]
|
46
|
+
</td>
|
47
|
+
<td class="visibility">
|
48
|
+
public
|
49
|
+
</td>
|
50
|
+
<td class="docstring">
|
51
|
+
<p>
|
52
|
+
All nodes in the document arranged by node type.
|
53
|
+
</p>
|
54
|
+
|
55
|
+
|
56
|
+
</td>
|
57
|
+
</tr>
|
58
|
+
|
59
|
+
<tr>
|
60
|
+
<th class="name">nodes</td>
|
61
|
+
<td class="readwrite">
|
62
|
+
[<span id='nodes-instance_method'>R</span>W]
|
63
|
+
</td>
|
64
|
+
<td class="visibility">
|
65
|
+
public
|
66
|
+
</td>
|
67
|
+
<td class="docstring">
|
68
|
+
<p>
|
69
|
+
All nodes in the document.
|
70
|
+
</p>
|
71
|
+
|
72
|
+
|
73
|
+
</td>
|
74
|
+
</tr>
|
75
|
+
|
76
|
+
<tr>
|
77
|
+
<th class="name">roots</td>
|
78
|
+
<td class="readwrite">
|
79
|
+
[<span id='roots-instance_method'>R</span>W]
|
80
|
+
</td>
|
81
|
+
<td class="visibility">
|
82
|
+
public
|
83
|
+
</td>
|
84
|
+
<td class="docstring">
|
85
|
+
<p>
|
86
|
+
All root nodes in the document.
|
87
|
+
</p>
|
88
|
+
|
89
|
+
|
90
|
+
</td>
|
91
|
+
</tr>
|
92
|
+
|
93
|
+
</table>
|
94
|
+
</div>
|
95
|
+
|
96
|
+
</div><div class="section constants">
|
97
|
+
|
98
|
+
</div><div class="section constructor">
|
99
|
+
<h1>Constructor Summary</h1>
|
100
|
+
<div id="initialize-instance_method" class="section method">
|
101
|
+
<div class="details_title">
|
102
|
+
<div class='section methodsignature'>
|
103
|
+
<tt class='def'>
|
104
|
+
<span class='visibility'>public</span>
|
105
|
+
<span class='return_types'></span>
|
106
|
+
<span class='name'>initialize</span><span class='args'>(format, input_text, input_file, options = )</span>
|
107
|
+
<span class='block'></span>
|
108
|
+
</tt>
|
109
|
+
</div>
|
110
|
+
|
111
|
+
</div><div class="section tags">
|
112
|
+
<h2>Meta Tags</h2>
|
113
|
+
<div class="param">
|
114
|
+
<h3>Parameters:</h3>
|
115
|
+
<dl>
|
116
|
+
|
117
|
+
|
118
|
+
<dt>
|
119
|
+
<span class='type'>[<tt><a href="../String.html" title="String">String</a></tt>]</span>
|
120
|
+
<span class='name'>format</span>
|
121
|
+
|
122
|
+
</dt>
|
123
|
+
<dd>
|
124
|
+
<span class='desc'><p>
|
125
|
+
Either the short-hand name of a built-in format or the path to a format
|
126
|
+
specification file.
|
127
|
+
</p>
|
128
|
+
</span>
|
129
|
+
</dd>
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
<dt>
|
134
|
+
<span class='type'>[<tt><a href="../String.html" title="String">String</a></tt>]</span>
|
135
|
+
<span class='name'>input_text</span>
|
136
|
+
|
137
|
+
</dt>
|
138
|
+
<dd>
|
139
|
+
<span class='desc'><p>
|
140
|
+
The body of the input document.
|
141
|
+
</p>
|
142
|
+
</span>
|
143
|
+
</dd>
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
<dt>
|
148
|
+
<span class='type'>[<tt><a href="../String.html" title="String">String</a></tt>]</span>
|
149
|
+
<span class='name'>input_file</span>
|
150
|
+
|
151
|
+
</dt>
|
152
|
+
<dd>
|
153
|
+
<span class='desc'><p>
|
154
|
+
Name of the file from which the input document originated.
|
155
|
+
</p>
|
156
|
+
</span>
|
157
|
+
</dd>
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
<dt>
|
162
|
+
<span class='type'>[<tt>Hash</tt>]</span>
|
163
|
+
<span class='name'>options</span>
|
164
|
+
|
165
|
+
<em class="default">(defaults to: <tt></tt>)</em>
|
166
|
+
|
167
|
+
</dt>
|
168
|
+
<dd>
|
169
|
+
<span class='desc'><p>
|
170
|
+
Additional method parameters:
|
171
|
+
</p>
|
172
|
+
<dl>
|
173
|
+
<dt>boolean</dt><dd>:unindent => If true, all node content is unindented hierarchically.
|
174
|
+
|
175
|
+
</dd>
|
176
|
+
</dl>
|
177
|
+
</span>
|
178
|
+
</dd>
|
179
|
+
|
180
|
+
|
181
|
+
</dl>
|
182
|
+
</div>
|
183
|
+
</div><div class="section source">
|
184
|
+
<span>[<a class="source_link" href="#">View source</a>]</span>
|
185
|
+
<div class="source_code">
|
186
|
+
<table>
|
187
|
+
<tr>
|
188
|
+
<td>
|
189
|
+
<pre class="lines">
|
190
|
+
|
191
|
+
|
192
|
+
35
|
193
|
+
36
|
194
|
+
37
|
195
|
+
38
|
196
|
+
39
|
197
|
+
40
|
198
|
+
41
|
199
|
+
42
|
200
|
+
43
|
201
|
+
44
|
202
|
+
45
|
203
|
+
46
|
204
|
+
47
|
205
|
+
48
|
206
|
+
49
|
207
|
+
50
|
208
|
+
51
|
209
|
+
52
|
210
|
+
53
|
211
|
+
54
|
212
|
+
55
|
213
|
+
56
|
214
|
+
57
|
215
|
+
58
|
216
|
+
59
|
217
|
+
60
|
218
|
+
61
|
219
|
+
62
|
220
|
+
63
|
221
|
+
64
|
222
|
+
65
|
223
|
+
66
|
224
|
+
67
|
225
|
+
68
|
226
|
+
69
|
227
|
+
70
|
228
|
+
71
|
229
|
+
72
|
230
|
+
73
|
231
|
+
74
|
232
|
+
75
|
233
|
+
76
|
234
|
+
77
|
235
|
+
78
|
236
|
+
79
|
237
|
+
80
|
238
|
+
81
|
239
|
+
82
|
240
|
+
83
|
241
|
+
84
|
242
|
+
85
|
243
|
+
86
|
244
|
+
87
|
245
|
+
88
|
246
|
+
89
|
247
|
+
90
|
248
|
+
91
|
249
|
+
92
|
250
|
+
93
|
251
|
+
94
|
252
|
+
95
|
253
|
+
96
|
254
|
+
97
|
255
|
+
98
|
256
|
+
99
|
257
|
+
100
|
258
|
+
101
|
259
|
+
102
|
260
|
+
103
|
261
|
+
104
|
262
|
+
105
|
263
|
+
106
|
264
|
+
107
|
265
|
+
108
|
266
|
+
109
|
267
|
+
110
|
268
|
+
111
|
269
|
+
112
|
270
|
+
113
|
271
|
+
114
|
272
|
+
115
|
273
|
+
116
|
274
|
+
117
|
275
|
+
118
|
276
|
+
119
|
277
|
+
120
|
278
|
+
121
|
279
|
+
122
|
280
|
+
123
|
281
|
+
124
|
282
|
+
125
|
283
|
+
126
|
284
|
+
127
|
285
|
+
128
|
286
|
+
129
|
287
|
+
130
|
288
|
+
131
|
289
|
+
132
|
290
|
+
133
|
291
|
+
134
|
292
|
+
135
|
293
|
+
136
|
294
|
+
137
|
295
|
+
138
|
296
|
+
139
|
297
|
+
140
|
298
|
+
141
|
299
|
+
142
|
300
|
+
143
|
301
|
+
144
|
302
|
+
145
|
303
|
+
146
|
304
|
+
147
|
305
|
+
148
|
306
|
+
149
|
307
|
+
150
|
308
|
+
151
|
309
|
+
152
|
310
|
+
153
|
311
|
+
154
|
312
|
+
155
|
313
|
+
156
|
314
|
+
157
|
315
|
+
158
|
316
|
+
159
|
317
|
+
160
|
318
|
+
161
|
319
|
+
162
|
320
|
+
163
|
321
|
+
164
|
322
|
+
165
|
323
|
+
166
|
324
|
+
167
|
325
|
+
168
|
326
|
+
169
|
327
|
+
170
|
328
|
+
171
|
329
|
+
172
|
330
|
+
173
|
331
|
+
174
|
332
|
+
175
|
333
|
+
176
|
334
|
+
177
|
335
|
+
178
|
336
|
+
179
|
337
|
+
180
|
338
|
+
181
|
339
|
+
182
|
340
|
+
183
|
341
|
+
184
|
342
|
+
185
|
343
|
+
186
|
344
|
+
187
|
345
|
+
188</pre>
|
346
|
+
</td>
|
347
|
+
<td>
|
348
|
+
<pre class="code"><span class="info file"># File 'lib/erbook/document.rb', line 35</span>
|
349
|
+
|
350
|
+
<span class='def def kw'>def</span> <span class='initialize identifier id'>initialize</span> <span class='format identifier id'>format</span><span class='comma token'>,</span> <span class='input_text identifier id'>input_text</span><span class='comma token'>,</span> <span class='input_file identifier id'>input_file</span><span class='comma token'>,</span> <span class='options identifier id'>options</span> <span class='assign token'>=</span> <span class='semicolon token'>;</span><span class='lbrace token'>{</span><span class='rbrace token'>}</span>
|
351
|
+
<span class='comment val'># process format specification</span>
|
352
|
+
<span class='@format_file ivar id'>@format_file</span> <span class='assign token'>=</span> <span class='format identifier id'>format</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span>
|
353
|
+
|
354
|
+
<span class='File constant id'>File</span><span class='dot token'>.</span><span class='file? fid id'>file?</span> <span class='@format_file ivar id'>@format_file</span> <span class='or or kw'>or</span>
|
355
|
+
<span class='@format_file ivar id'>@format_file</span> <span class='assign token'>=</span> <span class='File constant id'>File</span><span class='dot token'>.</span><span class='join identifier id'>join</span><span class='lparen token'>(</span><span class='ERBook constant id'>ERBook</span><span class='colon2 op'>::</span><span class='FORMATS_DIR constant id'>FORMATS_DIR</span><span class='comma token'>,</span> <span class='@format_file ivar id'>@format_file</span> <span class='plus op'>+</span> <span class='string val'>'.yaml'</span><span class='rparen token'>)</span>
|
356
|
+
|
357
|
+
<span class='begin begin kw'>begin</span>
|
358
|
+
<span class='@format ivar id'>@format</span> <span class='assign token'>=</span> <span class='YAML constant id'>YAML</span><span class='dot token'>.</span><span class='load_file identifier id'>load_file</span><span class='lparen token'>(</span><span class='@format_file ivar id'>@format_file</span><span class='rparen token'>)</span>
|
359
|
+
<span class='@format ivar id'>@format</span><span class='lbrack token'>[</span><span class='symbol val'>:file</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='File constant id'>File</span><span class='dot token'>.</span><span class='expand_path identifier id'>expand_path</span><span class='lparen token'>(</span><span class='@format_file ivar id'>@format_file</span><span class='rparen token'>)</span>
|
360
|
+
<span class='@format ivar id'>@format</span><span class='lbrack token'>[</span><span class='symbol val'>:name</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='File constant id'>File</span><span class='dot token'>.</span><span class='basename identifier id'>basename</span><span class='lparen token'>(</span><span class='@format_file ivar id'>@format_file</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='sub identifier id'>sub</span><span class='lparen token'>(</span><span class='regexp val'>/\..*?$/</span><span class='comma token'>,</span> <span class='string val'>''</span><span class='rparen token'>)</span>
|
361
|
+
|
362
|
+
<span class='if if kw'>if</span> <span class='@format ivar id'>@format</span><span class='dot token'>.</span><span class='key? fid id'>key?</span> <span class='string val'>'code'</span>
|
363
|
+
<span class='eval identifier id'>eval</span> <span class='@format ivar id'>@format</span><span class='lbrack token'>[</span><span class='string val'>'code'</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span><span class='comma token'>,</span> <span class='TOPLEVEL_BINDING constant id'>TOPLEVEL_BINDING</span><span class='comma token'>,</span> <span class='dstring node'>"#{@format_file}:code"</span>
|
364
|
+
<span class='end end kw'>end</span>
|
365
|
+
|
366
|
+
<span class='rescue rescue kw'>rescue</span> <span class='Exception constant id'>Exception</span>
|
367
|
+
<span class='error identifier id'>error</span> <span class='dstring node'>"Could not load format specification file #{@format_file.inspect}"</span>
|
368
|
+
<span class='end end kw'>end</span>
|
369
|
+
|
370
|
+
<span class='@node_defs ivar id'>@node_defs</span> <span class='assign token'>=</span> <span class='@format ivar id'>@format</span><span class='lbrack token'>[</span><span class='string val'>'nodes'</span><span class='rbrack token'>]</span>
|
371
|
+
|
372
|
+
<span class='comment val'># process input document</span>
|
373
|
+
<span class='begin begin kw'>begin</span>
|
374
|
+
<span class='comment val'># create sandbox for input evaluation</span>
|
375
|
+
<span class='template identifier id'>template</span> <span class='assign token'>=</span> <span class='Template constant id'>Template</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='input_file identifier id'>input_file</span><span class='comma token'>,</span> <span class='input_text identifier id'>input_text</span><span class='comma token'>,</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:unindent</span><span class='rbrack token'>]</span><span class='rparen token'>)</span>
|
376
|
+
|
377
|
+
<span class='@template_vars ivar id'>@template_vars</span> <span class='assign token'>=</span> <span class='lbrace token'>{</span>
|
378
|
+
<span class='symbol val'>:@format</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='@format ivar id'>@format</span><span class='comma token'>,</span>
|
379
|
+
<span class='symbol val'>:@roots</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='@roots ivar id'>@roots</span> <span class='assign token'>=</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='comment val'># root nodes of all trees</span>
|
380
|
+
<span class='symbol val'>:@nodes</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='@nodes ivar id'>@nodes</span> <span class='assign token'>=</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='comment val'># all nodes in the forest</span>
|
381
|
+
<span class='symbol val'>:@nodes_by_type</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='@nodes_by_type ivar id'>@nodes_by_type</span> <span class='assign token'>=</span> <span class='Hash constant id'>Hash</span><span class='dot token'>.</span><span class='new identifier id'>new</span> <span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='h identifier id'>h</span><span class='comma token'>,</span><span class='k identifier id'>k</span><span class='bitor op'>|</span> <span class='h identifier id'>h</span><span class='lbrack token'>[</span><span class='k identifier id'>k</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span> <span class='rbrace token'>}</span><span class='comma token'>,</span>
|
382
|
+
<span class='symbol val'>:@node_stack</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='comment val'># stack for all nodes</span>
|
383
|
+
<span class='symbol val'>:@index_stack</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='comment val'># stack for nodes having index only</span>
|
384
|
+
<span class='rbrace token'>}</span><span class='dot token'>.</span><span class='each_pair identifier id'>each_pair</span> <span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='k identifier id'>k</span><span class='comma token'>,</span><span class='v identifier id'>v</span><span class='bitor op'>|</span> <span class='template identifier id'>template</span><span class='dot token'>.</span><span class='instance_variable_set identifier id'>instance_variable_set</span><span class='lparen token'>(</span><span class='k identifier id'>k</span><span class='comma token'>,</span> <span class='v identifier id'>v</span><span class='rparen token'>)</span> <span class='rbrace token'>}</span>
|
385
|
+
|
386
|
+
<span class='class class kw'>class</span> <span class='lshft op'><<</span> <span class='template identifier id'>template</span>
|
387
|
+
<span class='private identifier id'>private</span>
|
388
|
+
|
389
|
+
<span class='comment val'># Handles the method call from a node</span>
|
390
|
+
<span class='comment val'># placeholder in the input document.</span>
|
391
|
+
<span class='def def kw'>def</span> <span class='__node__ identifier id'>__node__</span> <span class='node_type identifier id'>node_type</span><span class='comma token'>,</span> <span class='mult op'>*</span><span class='node_args identifier id'>node_args</span><span class='comma token'>,</span> <span class='bitand op'>&</span><span class='node_content identifier id'>node_content</span>
|
392
|
+
<span class='node identifier id'>node</span> <span class='assign token'>=</span> <span class='Node constant id'>Node</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span>
|
393
|
+
<span class='symbol val'>:type</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='node_type identifier id'>node_type</span><span class='comma token'>,</span>
|
394
|
+
<span class='symbol val'>:defn</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='@format ivar id'>@format</span><span class='lbrack token'>[</span><span class='string val'>'nodes'</span><span class='rbrack token'>]</span><span class='lbrack token'>[</span><span class='node_type identifier id'>node_type</span><span class='rbrack token'>]</span><span class='comma token'>,</span>
|
395
|
+
<span class='symbol val'>:args</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='node_args identifier id'>node_args</span><span class='comma token'>,</span>
|
396
|
+
<span class='symbol val'>:children</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span><span class='comma token'>,</span>
|
397
|
+
|
398
|
+
<span class='comment val'># omit erbook internals from the stack trace</span>
|
399
|
+
<span class='symbol val'>:trace</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='caller identifier id'>caller</span><span class='dot token'>.</span><span class='reject identifier id'>reject</span> <span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='t identifier id'>t</span><span class='bitor op'>|</span>
|
400
|
+
<span class='lbrack token'>[</span><span class='$0 gvar id'>$0</span><span class='comma token'>,</span> <span class='ERBook constant id'>ERBook</span><span class='colon2 op'>::</span><span class='INSTALL constant id'>INSTALL</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='any? fid id'>any?</span> <span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='f identifier id'>f</span><span class='bitor op'>|</span> <span class='t identifier id'>t</span><span class='dot token'>.</span><span class='index identifier id'>index</span><span class='lparen token'>(</span><span class='f identifier id'>f</span><span class='rparen token'>)</span> <span class='eq op'>==</span> <span class='integer val'>0</span> <span class='rbrace token'>}</span>
|
401
|
+
<span class='rbrace token'>}</span>
|
402
|
+
<span class='rparen token'>)</span>
|
403
|
+
<span class='@nodes ivar id'>@nodes</span> <span class='lshft op'><<</span> <span class='node identifier id'>node</span>
|
404
|
+
<span class='@nodes_by_type ivar id'>@nodes_by_type</span><span class='lbrack token'>[</span><span class='node identifier id'>node</span><span class='dot token'>.</span><span class='type identifier id'>type</span><span class='rbrack token'>]</span> <span class='lshft op'><<</span> <span class='node identifier id'>node</span>
|
405
|
+
|
406
|
+
<span class='comment val'># calculate occurrence number for this node</span>
|
407
|
+
<span class='if if kw'>if</span> <span class='node identifier id'>node</span><span class='dot token'>.</span><span class='defn identifier id'>defn</span><span class='lbrack token'>[</span><span class='string val'>'number'</span><span class='rbrack token'>]</span>
|
408
|
+
<span class='@count ivar id'>@count</span> <span class='opasgn op'>||=</span> <span class='Hash constant id'>Hash</span><span class='dot token'>.</span><span class='new identifier id'>new</span> <span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='h identifier id'>h</span><span class='comma token'>,</span><span class='k identifier id'>k</span><span class='bitor op'>|</span> <span class='h identifier id'>h</span><span class='lbrack token'>[</span><span class='k identifier id'>k</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span><span class='rbrace token'>}</span>
|
409
|
+
<span class='node identifier id'>node</span><span class='dot token'>.</span><span class='number identifier id'>number</span> <span class='assign token'>=</span> <span class='lparen token'>(</span><span class='@count ivar id'>@count</span><span class='lbrack token'>[</span><span class='node identifier id'>node</span><span class='dot token'>.</span><span class='type identifier id'>type</span><span class='rbrack token'>]</span> <span class='lshft op'><<</span> <span class='node identifier id'>node</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='length identifier id'>length</span>
|
410
|
+
<span class='end end kw'>end</span>
|
411
|
+
|
412
|
+
<span class='comment val'># assign node family</span>
|
413
|
+
<span class='if if kw'>if</span> <span class='parent identifier id'>parent</span> <span class='assign token'>=</span> <span class='@node_stack ivar id'>@node_stack</span><span class='dot token'>.</span><span class='last identifier id'>last</span>
|
414
|
+
<span class='parent identifier id'>parent</span><span class='dot token'>.</span><span class='children identifier id'>children</span> <span class='lshft op'><<</span> <span class='node identifier id'>node</span>
|
415
|
+
<span class='node identifier id'>node</span><span class='dot token'>.</span><span class='parent identifier id'>parent</span> <span class='assign token'>=</span> <span class='parent identifier id'>parent</span>
|
416
|
+
<span class='node identifier id'>node</span><span class='dot token'>.</span><span class='depth identifier id'>depth</span> <span class='assign token'>=</span> <span class='parent identifier id'>parent</span><span class='dot token'>.</span><span class='depth identifier id'>depth</span>
|
417
|
+
<span class='node identifier id'>node</span><span class='dot token'>.</span><span class='depth identifier id'>depth</span> <span class='opasgn op'>+=</span> <span class='integer val'>1</span> <span class='if if_mod kw'>if</span> <span class='node identifier id'>node</span><span class='dot token'>.</span><span class='defn identifier id'>defn</span><span class='lbrack token'>[</span><span class='string val'>'depth'</span><span class='rbrack token'>]</span>
|
418
|
+
|
419
|
+
<span class='comment val'># calculate latex-style index number for this node</span>
|
420
|
+
<span class='if if kw'>if</span> <span class='node identifier id'>node</span><span class='dot token'>.</span><span class='defn identifier id'>defn</span><span class='lbrack token'>[</span><span class='string val'>'index'</span><span class='rbrack token'>]</span>
|
421
|
+
<span class='parent identifier id'>parent</span> <span class='assign token'>=</span> <span class='@index_stack ivar id'>@index_stack</span><span class='dot token'>.</span><span class='last identifier id'>last</span>
|
422
|
+
<span class='branches identifier id'>branches</span> <span class='assign token'>=</span> <span class='parent identifier id'>parent</span><span class='dot token'>.</span><span class='children identifier id'>children</span><span class='dot token'>.</span><span class='select identifier id'>select</span> <span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='n identifier id'>n</span><span class='bitor op'>|</span> <span class='n identifier id'>n</span><span class='dot token'>.</span><span class='index identifier id'>index</span> <span class='rbrace token'>}</span>
|
423
|
+
<span class='node identifier id'>node</span><span class='dot token'>.</span><span class='index identifier id'>index</span> <span class='assign token'>=</span> <span class='lbrack token'>[</span><span class='parent identifier id'>parent</span><span class='dot token'>.</span><span class='index identifier id'>index</span><span class='comma token'>,</span> <span class='branches identifier id'>branches</span><span class='dot token'>.</span><span class='length identifier id'>length</span> <span class='plus op'>+</span> <span class='integer val'>1</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='join identifier id'>join</span><span class='lparen token'>(</span><span class='string val'>'.'</span><span class='rparen token'>)</span>
|
424
|
+
<span class='end end kw'>end</span>
|
425
|
+
<span class='else else kw'>else</span>
|
426
|
+
<span class='@roots ivar id'>@roots</span> <span class='lshft op'><<</span> <span class='node identifier id'>node</span>
|
427
|
+
<span class='node identifier id'>node</span><span class='dot token'>.</span><span class='parent identifier id'>parent</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span>
|
428
|
+
<span class='node identifier id'>node</span><span class='dot token'>.</span><span class='depth identifier id'>depth</span> <span class='assign token'>=</span> <span class='integer val'>0</span>
|
429
|
+
|
430
|
+
<span class='comment val'># calculate latex-style index number for this node</span>
|
431
|
+
<span class='if if kw'>if</span> <span class='node identifier id'>node</span><span class='dot token'>.</span><span class='defn identifier id'>defn</span><span class='lbrack token'>[</span><span class='string val'>'index'</span><span class='rbrack token'>]</span>
|
432
|
+
<span class='branches identifier id'>branches</span> <span class='assign token'>=</span> <span class='@roots ivar id'>@roots</span><span class='dot token'>.</span><span class='select identifier id'>select</span> <span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='n identifier id'>n</span><span class='bitor op'>|</span> <span class='n identifier id'>n</span><span class='dot token'>.</span><span class='index identifier id'>index</span> <span class='rbrace token'>}</span>
|
433
|
+
<span class='node identifier id'>node</span><span class='dot token'>.</span><span class='index identifier id'>index</span> <span class='assign token'>=</span> <span class='lparen token'>(</span><span class='branches identifier id'>branches</span><span class='dot token'>.</span><span class='length identifier id'>length</span> <span class='plus op'>+</span> <span class='integer val'>1</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span>
|
434
|
+
<span class='end end kw'>end</span>
|
435
|
+
<span class='end end kw'>end</span>
|
436
|
+
|
437
|
+
<span class='comment val'># assign node content</span>
|
438
|
+
<span class='if if kw'>if</span> <span class='block_given? fid id'>block_given?</span>
|
439
|
+
<span class='@index_stack ivar id'>@index_stack</span><span class='dot token'>.</span><span class='push identifier id'>push</span> <span class='node identifier id'>node</span> <span class='if if_mod kw'>if</span> <span class='node identifier id'>node</span><span class='dot token'>.</span><span class='defn identifier id'>defn</span><span class='lbrack token'>[</span><span class='string val'>'index'</span><span class='rbrack token'>]</span>
|
440
|
+
<span class='@node_stack ivar id'>@node_stack</span><span class='dot token'>.</span><span class='push identifier id'>push</span> <span class='node identifier id'>node</span>
|
441
|
+
<span class='content identifier id'>content</span> <span class='assign token'>=</span> <span class='content_from_block identifier id'>content_from_block</span><span class='lparen token'>(</span><span class='node identifier id'>node</span><span class='comma token'>,</span> <span class='bitand op'>&</span><span class='node_content identifier id'>node_content</span><span class='rparen token'>)</span>
|
442
|
+
<span class='@node_stack ivar id'>@node_stack</span><span class='dot token'>.</span><span class='pop identifier id'>pop</span>
|
443
|
+
<span class='@index_stack ivar id'>@index_stack</span><span class='dot token'>.</span><span class='pop identifier id'>pop</span> <span class='if if_mod kw'>if</span> <span class='node identifier id'>node</span><span class='dot token'>.</span><span class='defn identifier id'>defn</span><span class='lbrack token'>[</span><span class='string val'>'index'</span><span class='rbrack token'>]</span>
|
444
|
+
|
445
|
+
<span class='digest identifier id'>digest</span> <span class='assign token'>=</span> <span class='Document constant id'>Document</span><span class='dot token'>.</span><span class='digest identifier id'>digest</span><span class='lparen token'>(</span><span class='content identifier id'>content</span><span class='rparen token'>)</span>
|
446
|
+
<span class='self self kw'>self</span><span class='dot token'>.</span><span class='buffer identifier id'>buffer</span> <span class='lshft op'><<</span> <span class='digest identifier id'>digest</span>
|
447
|
+
<span class='else else kw'>else</span>
|
448
|
+
<span class='content identifier id'>content</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span>
|
449
|
+
<span class='digest identifier id'>digest</span> <span class='assign token'>=</span> <span class='Document constant id'>Document</span><span class='dot token'>.</span><span class='digest identifier id'>digest</span><span class='lparen token'>(</span><span class='node identifier id'>node</span><span class='dot token'>.</span><span class='object_id identifier id'>object_id</span><span class='rparen token'>)</span>
|
450
|
+
<span class='end end kw'>end</span>
|
451
|
+
|
452
|
+
<span class='node identifier id'>node</span><span class='dot token'>.</span><span class='content identifier id'>content</span> <span class='assign token'>=</span> <span class='content identifier id'>content</span>
|
453
|
+
<span class='node identifier id'>node</span><span class='dot token'>.</span><span class='digest identifier id'>digest</span> <span class='assign token'>=</span> <span class='digest identifier id'>digest</span>
|
454
|
+
|
455
|
+
<span class='digest identifier id'>digest</span>
|
456
|
+
<span class='end end kw'>end</span>
|
457
|
+
<span class='end end kw'>end</span>
|
458
|
+
|
459
|
+
<span class='@node_defs ivar id'>@node_defs</span><span class='dot token'>.</span><span class='each_key identifier id'>each_key</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='type identifier id'>type</span><span class='bitor op'>|</span>
|
460
|
+
<span class='comment val'># XXX: using a string because define_method()</span>
|
461
|
+
<span class='comment val'># does not accept a block until Ruby 1.9</span>
|
462
|
+
<span class='file identifier id'>file</span><span class='comma token'>,</span> <span class='line identifier id'>line</span> <span class='assign token'>=</span> <span class='__FILE__ __file__ kw'>__FILE__</span><span class='comma token'>,</span> <span class='__LINE__ __line__ kw'>__LINE__</span> <span class='plus op'>+</span> <span class='integer val'>1</span>
|
463
|
+
<span class='template identifier id'>template</span><span class='dot token'>.</span><span class='instance_eval identifier id'>instance_eval</span> <span class='dstring node'>%{
|
464
|
+
def #{type} *node_args, &node_content
|
465
|
+
__node__ #{type.inspect}, *node_args, &node_content
|
466
|
+
end
|
467
|
+
}</span><span class='comma token'>,</span> <span class='file identifier id'>file</span><span class='comma token'>,</span> <span class='line identifier id'>line</span>
|
468
|
+
<span class='end end kw'>end</span>
|
469
|
+
|
470
|
+
<span class='comment val'># evaluate the input & build the document tree</span>
|
471
|
+
<span class='@processed_document ivar id'>@processed_document</span> <span class='assign token'>=</span> <span class='template identifier id'>template</span><span class='dot token'>.</span><span class='instance_eval identifier id'>instance_eval</span> <span class='lbrace token'>{</span> <span class='result identifier id'>result</span> <span class='binding identifier id'>binding</span> <span class='rbrace token'>}</span>
|
472
|
+
|
473
|
+
<span class='comment val'># chain block-level nodes together for local navigation</span>
|
474
|
+
<span class='block_nodes identifier id'>block_nodes</span> <span class='assign token'>=</span> <span class='@nodes ivar id'>@nodes</span><span class='dot token'>.</span><span class='reject identifier id'>reject</span> <span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='n identifier id'>n</span><span class='bitor op'>|</span> <span class='@node_defs ivar id'>@node_defs</span><span class='lbrack token'>[</span><span class='n identifier id'>n</span><span class='dot token'>.</span><span class='type identifier id'>type</span><span class='rbrack token'>]</span><span class='lbrack token'>[</span><span class='string val'>'inline'</span><span class='rbrack token'>]</span> <span class='rbrace token'>}</span>
|
475
|
+
|
476
|
+
<span class='require identifier id'>require</span> <span class='string val'>'enumerator'</span>
|
477
|
+
<span class='block_nodes identifier id'>block_nodes</span><span class='dot token'>.</span><span class='each_cons identifier id'>each_cons</span><span class='lparen token'>(</span><span class='integer val'>2</span><span class='rparen token'>)</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='a identifier id'>a</span><span class='comma token'>,</span> <span class='b identifier id'>b</span><span class='bitor op'>|</span>
|
478
|
+
<span class='a identifier id'>a</span><span class='dot token'>.</span><span class='next_node identifier id'>next_node</span> <span class='assign token'>=</span> <span class='b identifier id'>b</span>
|
479
|
+
<span class='b identifier id'>b</span><span class='dot token'>.</span><span class='prev_node identifier id'>prev_node</span> <span class='assign token'>=</span> <span class='a identifier id'>a</span>
|
480
|
+
<span class='end end kw'>end</span>
|
481
|
+
|
482
|
+
<span class='comment val'># replace node placeholders with their corresponding output</span>
|
483
|
+
<span class='expander identifier id'>expander</span> <span class='assign token'>=</span> <span class='lambda identifier id'>lambda</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='n identifier id'>n</span><span class='comma token'>,</span> <span class='buf identifier id'>buf</span><span class='bitor op'>|</span>
|
484
|
+
<span class='comment val'># calculate node output</span>
|
485
|
+
<span class='source identifier id'>source</span> <span class='assign token'>=</span> <span class='dstring node'>"#{@format_file}:nodes:#{n.type}:output"</span>
|
486
|
+
<span class='n identifier id'>n</span><span class='dot token'>.</span><span class='output identifier id'>output</span> <span class='assign token'>=</span> <span class='Template constant id'>Template</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span>
|
487
|
+
<span class='source identifier id'>source</span><span class='comma token'>,</span> <span class='@node_defs ivar id'>@node_defs</span><span class='lbrack token'>[</span><span class='n identifier id'>n</span><span class='dot token'>.</span><span class='type identifier id'>type</span><span class='rbrack token'>]</span><span class='lbrack token'>[</span><span class='string val'>'output'</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span><span class='dot token'>.</span><span class='chomp identifier id'>chomp</span>
|
488
|
+
<span class='rparen token'>)</span><span class='dot token'>.</span><span class='render_with identifier id'>render_with</span><span class='lparen token'>(</span><span class='@template_vars ivar id'>@template_vars</span><span class='dot token'>.</span><span class='merge identifier id'>merge</span><span class='lparen token'>(</span><span class='symbol val'>:@node</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='n identifier id'>n</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
|
489
|
+
|
490
|
+
<span class='comment val'># expand all child nodes in this node's output</span>
|
491
|
+
<span class='n identifier id'>n</span><span class='dot token'>.</span><span class='children identifier id'>children</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='c identifier id'>c</span><span class='bitor op'>|</span> <span class='expander identifier id'>expander</span><span class='lbrack token'>[</span><span class='c identifier id'>c</span><span class='comma token'>,</span> <span class='n identifier id'>n</span><span class='dot token'>.</span><span class='output identifier id'>output</span><span class='rbrack token'>]</span> <span class='rbrace token'>}</span>
|
492
|
+
|
493
|
+
<span class='comment val'># replace this node's placeholder with its output in the buffer</span>
|
494
|
+
<span class='buf identifier id'>buf</span><span class='lbrack token'>[</span><span class='n identifier id'>n</span><span class='dot token'>.</span><span class='digest identifier id'>digest</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='@node_defs ivar id'>@node_defs</span><span class='lbrack token'>[</span><span class='n identifier id'>n</span><span class='dot token'>.</span><span class='type identifier id'>type</span><span class='rbrack token'>]</span><span class='lbrack token'>[</span><span class='string val'>'silent'</span><span class='rbrack token'>]</span> <span class='question op'>?</span> <span class='string val'>''</span> <span class='colon op'>:</span> <span class='n identifier id'>n</span><span class='dot token'>.</span><span class='output identifier id'>output</span>
|
495
|
+
<span class='end end kw'>end</span>
|
496
|
+
|
497
|
+
<span class='@roots ivar id'>@roots</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='n identifier id'>n</span><span class='bitor op'>|</span> <span class='expander identifier id'>expander</span><span class='lbrack token'>[</span><span class='n identifier id'>n</span><span class='comma token'>,</span> <span class='@processed_document ivar id'>@processed_document</span><span class='rbrack token'>]</span> <span class='rbrace token'>}</span>
|
498
|
+
|
499
|
+
<span class='rescue rescue kw'>rescue</span> <span class='Exception constant id'>Exception</span>
|
500
|
+
<span class='puts identifier id'>puts</span> <span class='input_text identifier id'>input_text</span> <span class='comment val'># so the user can debug line numbers in the stack trace</span>
|
501
|
+
<span class='error identifier id'>error</span> <span class='dstring node'>"Could not process input document #{input_file.inspect}"</span>
|
502
|
+
<span class='end end kw'>end</span>
|
503
|
+
<span class='end end kw'>end</span>
|
504
|
+
</pre>
|
505
|
+
</td>
|
506
|
+
</tr>
|
507
|
+
</table>
|
508
|
+
</div>
|
509
|
+
</div>
|
510
|
+
</div>
|
511
|
+
</div> <div class="section visibilitygroup public">
|
512
|
+
<h1>Public Visibility</h1>
|
513
|
+
<div class="section methodsummary class public">
|
514
|
+
<h1>Public Class Method Summary</h1>
|
515
|
+
<table class="summary">
|
516
|
+
|
517
|
+
<tr>
|
518
|
+
<th class="signature">
|
519
|
+
<span class='name'><a href="#digest-class_method" title="digest">digest</a></span><span class='args'>(input)</span>
|
520
|
+
<span class='block'></span>
|
521
|
+
|
522
|
+
</th>
|
523
|
+
<td class="docstring">
|
524
|
+
<p>
|
525
|
+
Returns a digest of the given string that will not be altered by
|
526
|
+
String#to_xhtml.
|
527
|
+
</p>
|
528
|
+
|
529
|
+
|
530
|
+
</td>
|
531
|
+
</tr>
|
532
|
+
|
533
|
+
</table>
|
534
|
+
</div>
|
535
|
+
<div class="section methodsummary instance public">
|
536
|
+
<h1>Public Instance Method Summary</h1>
|
537
|
+
<table class="summary">
|
538
|
+
|
539
|
+
<tr>
|
540
|
+
<th class="signature">
|
541
|
+
<span class='name'><a href="#to_s-instance_method" title="#to_s">#to_s</a></span><span class='args'></span>
|
542
|
+
<span class='block'></span>
|
543
|
+
|
544
|
+
</th>
|
545
|
+
<td class="docstring">
|
546
|
+
<p>
|
547
|
+
Returns the output of this document.
|
548
|
+
</p>
|
549
|
+
|
550
|
+
|
551
|
+
</td>
|
552
|
+
</tr>
|
553
|
+
|
554
|
+
</table>
|
555
|
+
</div>
|
556
|
+
<div class="section methoddetails class public">
|
557
|
+
<h1>Public Class Method Details</h1>
|
558
|
+
|
559
|
+
<div class="method">
|
560
|
+
<div class="method_header">
|
561
|
+
<h3>digest</h3>
|
562
|
+
</div><div id="digest-class_method" class="section method">
|
563
|
+
<div class="details_title">
|
564
|
+
<div class='section methodsignature'>
|
565
|
+
<tt class='def'>
|
566
|
+
<span class='visibility'>public</span>
|
567
|
+
<span class='return_types'></span>
|
568
|
+
<span class='name'>digest</span><span class='args'>(input)</span>
|
569
|
+
<span class='block'></span>
|
570
|
+
</tt>
|
571
|
+
</div>
|
572
|
+
|
573
|
+
</div><div class="section docstring">
|
574
|
+
<p>
|
575
|
+
Returns a digest of the given string that will not be altered by
|
576
|
+
String#to_xhtml.
|
577
|
+
</p>
|
578
|
+
|
579
|
+
</div><div class="section source">
|
580
|
+
<span>[<a class="source_link" href="#">View source</a>]</span>
|
581
|
+
<div class="source_code">
|
582
|
+
<table>
|
583
|
+
<tr>
|
584
|
+
<td>
|
585
|
+
<pre class="lines">
|
586
|
+
|
587
|
+
|
588
|
+
215
|
589
|
+
216
|
590
|
+
217
|
591
|
+
218
|
592
|
+
219
|
593
|
+
220
|
594
|
+
221</pre>
|
595
|
+
</td>
|
596
|
+
<td>
|
597
|
+
<pre class="code"><span class="info file"># File 'lib/erbook/document.rb', line 215</span>
|
598
|
+
|
599
|
+
<span class='def def kw'>def</span> <span class='Document constant id'>Document</span><span class='dot token'>.</span><span class='digest identifier id'>digest</span> <span class='input identifier id'>input</span>
|
600
|
+
<span class='Digest constant id'>Digest</span><span class='colon2 op'>::</span><span class='SHA1 constant id'>SHA1</span><span class='dot token'>.</span><span class='hexdigest identifier id'>hexdigest</span><span class='lparen token'>(</span><span class='input identifier id'>input</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span><span class='rparen token'>)</span><span class='dot token'>.</span>
|
601
|
+
|
602
|
+
<span class='comment val'># XXX: surround all digits with alphabets so</span>
|
603
|
+
<span class='comment val'># Maruku doesn't change them into HTML</span>
|
604
|
+
<span class='gsub identifier id'>gsub</span><span class='lparen token'>(</span><span class='regexp val'>/\d/</span><span class='comma token'>,</span> <span class='string val'>'z\&z'</span><span class='rparen token'>)</span>
|
605
|
+
<span class='end end kw'>end</span>
|
606
|
+
</pre>
|
607
|
+
</td>
|
608
|
+
</tr>
|
609
|
+
</table>
|
610
|
+
</div>
|
611
|
+
</div>
|
612
|
+
</div>
|
613
|
+
</div>
|
614
|
+
|
615
|
+
</div><div class="section methoddetails instance public">
|
616
|
+
<h1>Public Instance Method Details</h1>
|
617
|
+
|
618
|
+
<div class="method">
|
619
|
+
<div class="method_header">
|
620
|
+
<h3>to_s</h3>
|
621
|
+
</div><div id="to_s-instance_method" class="section method">
|
622
|
+
<div class="details_title">
|
623
|
+
<div class='section methodsignature'>
|
624
|
+
<tt class='def'>
|
625
|
+
<span class='visibility'>public</span>
|
626
|
+
<span class='return_types'></span>
|
627
|
+
<span class='name'>to_s</span><span class='args'></span>
|
628
|
+
<span class='block'></span>
|
629
|
+
</tt>
|
630
|
+
</div>
|
631
|
+
|
632
|
+
</div><div class="section docstring">
|
633
|
+
<p>
|
634
|
+
Returns the output of this document.
|
635
|
+
</p>
|
636
|
+
|
637
|
+
</div><div class="section source">
|
638
|
+
<span>[<a class="source_link" href="#">View source</a>]</span>
|
639
|
+
<div class="source_code">
|
640
|
+
<table>
|
641
|
+
<tr>
|
642
|
+
<td>
|
643
|
+
<pre class="lines">
|
644
|
+
|
645
|
+
|
646
|
+
193
|
647
|
+
194
|
648
|
+
195
|
649
|
+
196</pre>
|
650
|
+
</td>
|
651
|
+
<td>
|
652
|
+
<pre class="code"><span class="info file"># File 'lib/erbook/document.rb', line 193</span>
|
653
|
+
|
654
|
+
<span class='def def kw'>def</span> <span class='to_s identifier id'>to_s</span>
|
655
|
+
<span class='Template constant id'>Template</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='dstring node'>"#{@format_file}:output"</span><span class='comma token'>,</span> <span class='@format ivar id'>@format</span><span class='lbrack token'>[</span><span class='string val'>'output'</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span><span class='rparen token'>)</span><span class='dot token'>.</span>
|
656
|
+
<span class='render_with identifier id'>render_with</span><span class='lparen token'>(</span><span class='@template_vars ivar id'>@template_vars</span><span class='dot token'>.</span><span class='merge identifier id'>merge</span><span class='lparen token'>(</span><span class='symbol val'>:@content</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='@processed_document ivar id'>@processed_document</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
|
657
|
+
<span class='end end kw'>end</span>
|
658
|
+
</pre>
|
659
|
+
</td>
|
660
|
+
</tr>
|
661
|
+
</table>
|
662
|
+
</div>
|
663
|
+
</div>
|
664
|
+
</div>
|
665
|
+
</div>
|
666
|
+
|
667
|
+
</div>
|
668
|
+
</div>
|
669
|
+
|
670
|
+
</div>
|
671
|
+
</div>
|
672
|
+
</body>
|
673
|
+
</html>
|