mucgly 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.rdoc +3 -0
- data/LICENSE +20 -0
- data/README.rdoc +292 -0
- data/Rakefile +29 -0
- data/bin/mucgly +220 -0
- data/doc/EasyFile/InOut.html +2097 -0
- data/doc/EasyFile/Read.html +1334 -0
- data/doc/EasyFile/ReadStack.html +461 -0
- data/doc/EasyFile/Stacked.html +411 -0
- data/doc/EasyFile/String.html +570 -0
- data/doc/EasyFile/Write.html +1084 -0
- data/doc/EasyFile/WriteStack.html +305 -0
- data/doc/EasyFile.html +155 -0
- data/doc/Mucgly/Env.html +1675 -0
- data/doc/Mucgly/MucglyFile/ParseState.html +1662 -0
- data/doc/Mucgly/MucglyFile/Token.html +529 -0
- data/doc/Mucgly/MucglyFile.html +545 -0
- data/doc/Mucgly/Separators.html +521 -0
- data/doc/Mucgly.html +244 -0
- data/doc/_index.html +261 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +338 -0
- data/doc/file.CHANGELOG.html +79 -0
- data/doc/file.README.html +390 -0
- data/doc/file_list.html +58 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +390 -0
- data/doc/js/app.js +214 -0
- data/doc/js/full_list.js +178 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +742 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/easyfile.rb +720 -0
- data/lib/mucgly.rb +627 -0
- data/test/test_basic.rx.txt +19 -0
- data/test/test_include.rb +6 -0
- data/test/test_include.txt +3 -0
- data/test/test_mucgly.rb +32 -0
- data/test/test_multi.rx.txt +4 -0
- data/test/test_specials_cli.rx.txt +11 -0
- data/test/test_specials_cmd.rx.txt +53 -0
- metadata +98 -0
data/doc/index.html
ADDED
@@ -0,0 +1,390 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII" />
|
6
|
+
<title>
|
7
|
+
File: README
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.6.1
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '';
|
20
|
+
framesUrl = "frames.html#!" + escape(window.location.href);
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="_index.html">Index</a> »
|
35
|
+
<span class="title">File: README</span>
|
36
|
+
|
37
|
+
|
38
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div id="search">
|
42
|
+
|
43
|
+
<a class="full_list_link" id="class_list_link"
|
44
|
+
href="class_list.html">
|
45
|
+
Class List
|
46
|
+
</a>
|
47
|
+
|
48
|
+
<a class="full_list_link" id="method_list_link"
|
49
|
+
href="method_list.html">
|
50
|
+
Method List
|
51
|
+
</a>
|
52
|
+
|
53
|
+
<a class="full_list_link" id="file_list_link"
|
54
|
+
href="file_list.html">
|
55
|
+
File List
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<iframe id="search_frame"></iframe>
|
63
|
+
|
64
|
+
<div id="content"><div id='filecontents'>
|
65
|
+
<h1>Mucgly</h1>
|
66
|
+
|
67
|
+
<h2>Introduction</h2>
|
68
|
+
|
69
|
+
<p>Mucgly is a macro expander for inline macros that exist in the middle of
|
70
|
+
body text. The macros are mostly regular Ruby code, but a few special
|
71
|
+
commands is also provided.</p>
|
72
|
+
|
73
|
+
<p>A very simple example:</p>
|
74
|
+
|
75
|
+
<pre class="code ruby"><code class="ruby">Adding 1 + 3 results: -<write (1+3).to_s>-</code></pre>
|
76
|
+
|
77
|
+
<p>After macro expansion the results is:</p>
|
78
|
+
|
79
|
+
<pre class="code ruby"><code class="ruby">Adding 1 + 3 results: 4</code></pre>
|
80
|
+
|
81
|
+
<p>By default macro starts with "-<" and ends with ">-". These limiters
|
82
|
+
are called hooks, hookbeg and hookend respectively. The code between hooks
|
83
|
+
is regular Ruby code. The "write" call writes to selected IO stream.</p>
|
84
|
+
|
85
|
+
<p>Ruby code is executed within a class instance reserved for this purpose.
|
86
|
+
The instance is called the Execution Environment. It enables values from
|
87
|
+
one macro to be visible in others.</p>
|
88
|
+
|
89
|
+
<p>Previous example with multiple macros:</p>
|
90
|
+
|
91
|
+
<pre class="code ruby"><code class="ruby">-<@a = 1>--<@b = 3>-\
|
92
|
+
Adding 1 + 3 results: -<write (@a+@b).to_s>-</code></pre>
|
93
|
+
|
94
|
+
<p>Result is exactly the same as in the previous execution. The first macro
|
95
|
+
"-<@a = 1>-" produces no output, it just sets the variable "@a" to
|
96
|
+
"1". Second macro is similar. The default "escape" character is "\". When
|
97
|
+
placed before newline character, it "eats" the newline and nothing is
|
98
|
+
output. Thus the first line outputs nothing.</p>
|
99
|
+
|
100
|
+
<p>The second line refers to settings from previous macros. Instance variables
|
101
|
+
has to be used to maintain the data between macro calls (due to instance
|
102
|
+
evaluation).</p>
|
103
|
+
|
104
|
+
<h2>Features</h2>
|
105
|
+
<ul><li>
|
106
|
+
<p>User settable hooks to define macro boundaries. Can be set from command
|
107
|
+
line, configuration files, or from macro file.</p>
|
108
|
+
</li><li>
|
109
|
+
<p>Multiple sources for configuration: default config, environment variable,
|
110
|
+
command line.</p>
|
111
|
+
</li><li>
|
112
|
+
<p>Multiple passes for macro file.</p>
|
113
|
+
</li><li>
|
114
|
+
<p>Convention based output file naming.</p>
|
115
|
+
</li><li>
|
116
|
+
<p>Multiple convenience functions for macros to use.</p>
|
117
|
+
</li><li>
|
118
|
+
<p>Macro file introspection: line number, file name</p>
|
119
|
+
</li><li>
|
120
|
+
<p>Output stream de-muxing.</p>
|
121
|
+
</li><li>
|
122
|
+
<p>Many special commands: include, source, etc...</p>
|
123
|
+
</li></ul>
|
124
|
+
|
125
|
+
<h2>Applications</h2>
|
126
|
+
<ul><li>
|
127
|
+
<p>Replacement for M4 macro processor.</p>
|
128
|
+
</li><li>
|
129
|
+
<p>Code generation.</p>
|
130
|
+
</li><li>
|
131
|
+
<p>Document formatting.</p>
|
132
|
+
</li><li>
|
133
|
+
<p>Etc.</p>
|
134
|
+
</li></ul>
|
135
|
+
|
136
|
+
<h2>Special characters</h2>
|
137
|
+
|
138
|
+
<h3>Hooks</h3>
|
139
|
+
|
140
|
+
<p>Hooks start and end the macro definition. By default hookbeg is "-<" and
|
141
|
+
hookend is ">-". These values are not easily conflicting with the macro
|
142
|
+
file body text.</p>
|
143
|
+
|
144
|
+
<p>If literal hook string is required, the escape character should be place
|
145
|
+
before the hook. For example "-<" will produce literal "-<" to the
|
146
|
+
output.</p>
|
147
|
+
|
148
|
+
<p>User can set the hooks to whatever string value desired. The hooks can also
|
149
|
+
have the same value. However nested macros are not possible then. Hooks can
|
150
|
+
also be the same as the escape character, but this makes usage somewhat
|
151
|
+
complicated.</p>
|
152
|
+
|
153
|
+
<h3>Escape</h3>
|
154
|
+
|
155
|
+
<p>Default escape character is "\". It can be used to escape hooks, cancel
|
156
|
+
space (" ") output, and cancel newline ("\n") output.</p>
|
157
|
+
|
158
|
+
<p>User can set the escape character to any character. Only single character
|
159
|
+
value is accepted.</p>
|
160
|
+
|
161
|
+
<h3>Multipass</h3>
|
162
|
+
|
163
|
+
<p>If the macro starts with "#" character, the macro is not expanded. One "#"
|
164
|
+
character is removed and the rest of the macro is output as it is. Each
|
165
|
+
pass will remove one "#" character and when all are removed, the macro is
|
166
|
+
evaluated. Usually two passes are enough and one "#" character is used to
|
167
|
+
save a macro to the later pass.</p>
|
168
|
+
|
169
|
+
<p>Multipass can be used for example to create a Table Of Contents. First pass
|
170
|
+
collects information about document content and second pass will insert the
|
171
|
+
Table Of Contents.</p>
|
172
|
+
|
173
|
+
<p>Example, with functions (insert_toc, header...) defined elsewhere:</p>
|
174
|
+
|
175
|
+
<pre class="code ruby"><code class="ruby">-<#insert_toc>-
|
176
|
+
-<header(1, "My header 1")>-
|
177
|
+
Paragraph1
|
178
|
+
-<header(2, "My header 1.1")>-
|
179
|
+
Paragraph2
|
180
|
+
-<header(1, "My header 2")>-
|
181
|
+
Paragraph3</code></pre>
|
182
|
+
|
183
|
+
<h2>Special commands</h2>
|
184
|
+
|
185
|
+
<p>In addition to regular Ruby code the macros are allowed to include so
|
186
|
+
called Special Commands. These commands start with the ":" characters and
|
187
|
+
with ".".</p>
|
188
|
+
|
189
|
+
<p>Example:</p>
|
190
|
+
|
191
|
+
<pre class="code ruby"><code class="ruby">...
|
192
|
+
-<:hook [ ]->\
|
193
|
+
...</code></pre>
|
194
|
+
|
195
|
+
<p>Would change the hookbeg and hookend to "[" and "]" respectively. One
|
196
|
+
special command is allowed per macro and it can't be mixed normal Ruby
|
197
|
+
code. Command name is separated by ":" in the beginning and by space (" ")
|
198
|
+
in the end. The rest of the macro is taken as argument to the macro. Note
|
199
|
+
that a command without an argument has to end with space as well.</p>
|
200
|
+
|
201
|
+
<p>List of ":" style special commands:</p>
|
202
|
+
<dl class="rdoc-list"><dt>include</dt>
|
203
|
+
<dd>
|
204
|
+
<p>Include reverts the input stream to the file given in the argument. Command
|
205
|
+
can be used to multiplex multiple files into one, for example.</p>
|
206
|
+
</dd><dt>output</dt>
|
207
|
+
<dd>
|
208
|
+
<p>Select a new output file. Use with "close" command, when the new output
|
209
|
+
file is ready.</p>
|
210
|
+
</dd><dt>comment</dt>
|
211
|
+
<dd>
|
212
|
+
<p>Comment is used to add comments into the macro file. No output is produced
|
213
|
+
from comment macros.</p>
|
214
|
+
</dd><dt>source</dt>
|
215
|
+
<dd>
|
216
|
+
<p>Source reads a plain Ruby file into the Execution Environment.</p>
|
217
|
+
</dd><dt>hook</dt>
|
218
|
+
<dd>
|
219
|
+
<p>Sets both hookbeg and hookend to values separated by space. The new hook
|
220
|
+
values are valid immediately after the enclosing macro.</p>
|
221
|
+
</dd><dt>hookbeg</dt>
|
222
|
+
<dd>
|
223
|
+
<p>Sets hookbeg.</p>
|
224
|
+
</dd><dt>hookend</dt>
|
225
|
+
<dd>
|
226
|
+
<p>Sets hookend.</p>
|
227
|
+
</dd><dt>escape</dt>
|
228
|
+
<dd>
|
229
|
+
<p>Sets escape character.</p>
|
230
|
+
</dd><dt>exit</dt>
|
231
|
+
<dd>
|
232
|
+
<p>Aborts the macro file.</p>
|
233
|
+
</dd></dl>
|
234
|
+
|
235
|
+
<p>Variable value reference command starts with "." and is followed by the
|
236
|
+
(instance) variable name.</p>
|
237
|
+
|
238
|
+
<p>For example:</p>
|
239
|
+
|
240
|
+
<pre class="code ruby"><code class="ruby">... -<.my_name>- ...</code></pre>
|
241
|
+
|
242
|
+
<p>Would write out the value of the "@my_name" variable, thus it is equal to
|
243
|
+
writing:</p>
|
244
|
+
|
245
|
+
<pre class="code ruby"><code class="ruby">... -<write @my_name>- ...</code></pre>
|
246
|
+
|
247
|
+
<h2>API methods</h2>
|
248
|
+
|
249
|
+
<p>API methods are instance methods of the Execution Environment, i.e. they
|
250
|
+
are predefined and visible for the macro code. These methods are organized
|
251
|
+
into two categories: Published and Hidden.</p>
|
252
|
+
|
253
|
+
<h3>Published methods</h3>
|
254
|
+
|
255
|
+
<p>Published methods are the most commonly used methods in macros. These are:</p>
|
256
|
+
<dl class="rdoc-list"><dt>write</dt>
|
257
|
+
<dd>
|
258
|
+
<p>Writes string into selected output IO.</p>
|
259
|
+
</dd><dt>puts</dt>
|
260
|
+
<dd>
|
261
|
+
<p>Writes string (+newline) into selected output IO.</p>
|
262
|
+
</dd><dt>source</dt>
|
263
|
+
<dd>
|
264
|
+
<p>Sources a plain Ruby file.</p>
|
265
|
+
</dd></dl>
|
266
|
+
|
267
|
+
<h3>Hidden methods</h3>
|
268
|
+
|
269
|
+
<p>Hidded methods start with underscore ("_"). The naming is used to prevent
|
270
|
+
poluting the Execution Environment's namespace.</p>
|
271
|
+
<dl class="rdoc-list"><dt>_processFilePair</dt>
|
272
|
+
<dd>
|
273
|
+
<p>Process a pair of files. First half is input file and second is output
|
274
|
+
file. File pair argument is an Array of two ([<fileI>,
|
275
|
+
<fileO>]).</p>
|
276
|
+
</dd><dt>_processFilePairs</dt>
|
277
|
+
<dd>
|
278
|
+
<p>Uses "_processFilePair" to process a list of file pairs.</p>
|
279
|
+
</dd><dt>_openInput</dt>
|
280
|
+
<dd>
|
281
|
+
<p>Sets input stream to given file. When this file is closed, the input stream
|
282
|
+
is reverted to the original file.</p>
|
283
|
+
</dd><dt>_openOutput</dt>
|
284
|
+
<dd>
|
285
|
+
<p>Sets output stream to given file. When this file is closed, the input
|
286
|
+
stream is reverted to the original file.</p>
|
287
|
+
</dd><dt>_openString</dt>
|
288
|
+
<dd>
|
289
|
+
<p>Open a StringIO file for output.</p>
|
290
|
+
</dd><dt>_pushInput</dt>
|
291
|
+
<dd>
|
292
|
+
<p>Makes given file as top input stream. When this stream is closed, the input
|
293
|
+
stream is reverted to the original file.</p>
|
294
|
+
</dd><dt>_pushOutput</dt>
|
295
|
+
<dd>
|
296
|
+
<p>Makes given file as top output stream. When this stream is closed, the
|
297
|
+
output stream is reverted to the original file.</p>
|
298
|
+
</dd><dt>_closeInput</dt>
|
299
|
+
<dd>
|
300
|
+
<p>Close input stream.</p>
|
301
|
+
</dd><dt>_closeOutput</dt>
|
302
|
+
<dd>
|
303
|
+
<p>Close output stream.</p>
|
304
|
+
</dd><dt>_ofilename</dt>
|
305
|
+
<dd>
|
306
|
+
<p>Output file name as String.</p>
|
307
|
+
</dd><dt>_olinenumber</dt>
|
308
|
+
<dd>
|
309
|
+
<p>Output file line number.</p>
|
310
|
+
</dd><dt>_ifilename</dt>
|
311
|
+
<dd>
|
312
|
+
<p>Input file name as String.</p>
|
313
|
+
</dd><dt>_ilinenumber</dt>
|
314
|
+
<dd>
|
315
|
+
<p>Input file line number.</p>
|
316
|
+
</dd><dt>_eval</dt>
|
317
|
+
<dd>
|
318
|
+
<p>Perform instance_eval on the given argument.</p>
|
319
|
+
</dd><dt>_inIO</dt>
|
320
|
+
<dd>
|
321
|
+
<p>Handle to input stream (get/set).</p>
|
322
|
+
</dd><dt>_outIO</dt>
|
323
|
+
<dd>
|
324
|
+
<p>Handle to output stream (get/set).</p>
|
325
|
+
</dd><dt>_separators</dt>
|
326
|
+
<dd>
|
327
|
+
<p>Handle to Separators object. Separotors object includes the "escapeChar",
|
328
|
+
"hookBegChars", and "hookEndChars" setter and getter methods.</p>
|
329
|
+
</dd></dl>
|
330
|
+
|
331
|
+
<h2>Command line interface</h2>
|
332
|
+
|
333
|
+
<p>Please execute:</p>
|
334
|
+
|
335
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_mucgly'>mucgly</span> <span class='op'>-</span><span class='id identifier rubyid_h'>h</span></code></pre>
|
336
|
+
|
337
|
+
<p>for an overview of the command line options.</p>
|
338
|
+
|
339
|
+
<h3>Input and Output files</h3>
|
340
|
+
|
341
|
+
<p>Input files can be listed to "-i" option. The default input stream for
|
342
|
+
Mucgly is STDIN.</p>
|
343
|
+
|
344
|
+
<p>Output files can be listed to "-o" option. The default output stream for
|
345
|
+
Mucgly is STDOUT.</p>
|
346
|
+
|
347
|
+
<p>If "-o" option is given without arguments and the input file list includes
|
348
|
+
".rx" in each name, the output file list is created by extracting ".rx"
|
349
|
+
from each input file name.</p>
|
350
|
+
|
351
|
+
<p>For example with:</p>
|
352
|
+
|
353
|
+
<pre class="code ruby"><code class="ruby">mucgly -i foo.rx.txt bar.rx.txt -o</code></pre>
|
354
|
+
|
355
|
+
<p>Two files, foo.txt and bar.txt, would be created. This holds true unless
|
356
|
+
the output streams are manipulated with macro commands.</p>
|
357
|
+
|
358
|
+
<p>If the number of input and output files match, then they are used in pairs.</p>
|
359
|
+
|
360
|
+
<h2>Configuration</h2>
|
361
|
+
|
362
|
+
<p>Mucgly checks for the existance of the "MUCGLY" environment variable. If
|
363
|
+
the variable exists, the file in variable value is read in as plain Ruby.</p>
|
364
|
+
|
365
|
+
<p>User configuration is searched from the users home directory:</p>
|
366
|
+
|
367
|
+
<pre class="code ruby"><code class="ruby">$HOME/.mucgly</code></pre>
|
368
|
+
|
369
|
+
<p>It is read as plain Ruby file if it exists.</p>
|
370
|
+
|
371
|
+
<p>Configuration files can also be given on command line using the "-c"
|
372
|
+
option. These settings can be used to override the settings above.</p>
|
373
|
+
|
374
|
+
<p>Additionally plain Ruby code can be given straight on the command line with
|
375
|
+
"-l" option.</p>
|
376
|
+
|
377
|
+
<h2>More information</h2>
|
378
|
+
|
379
|
+
<p>Check out the "test" directory within installation for detailed examples
|
380
|
+
about usage.</p>
|
381
|
+
</div></div>
|
382
|
+
|
383
|
+
<div id="footer">
|
384
|
+
Generated on Wed Jan 15 19:29:44 2014 by
|
385
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
386
|
+
0.8.6.1 (ruby-1.9.3).
|
387
|
+
</div>
|
388
|
+
|
389
|
+
</body>
|
390
|
+
</html>
|
data/doc/js/app.js
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
function createSourceLinks() {
|
2
|
+
$('.method_details_list .source_code').
|
3
|
+
before("<span class='showSource'>[<a href='#' class='toggleSource'>View source</a>]</span>");
|
4
|
+
$('.toggleSource').toggle(function() {
|
5
|
+
$(this).parent().nextAll('.source_code').slideDown(100);
|
6
|
+
$(this).text("Hide source");
|
7
|
+
},
|
8
|
+
function() {
|
9
|
+
$(this).parent().nextAll('.source_code').slideUp(100);
|
10
|
+
$(this).text("View source");
|
11
|
+
});
|
12
|
+
}
|
13
|
+
|
14
|
+
function createDefineLinks() {
|
15
|
+
var tHeight = 0;
|
16
|
+
$('.defines').after(" <a href='#' class='toggleDefines'>more...</a>");
|
17
|
+
$('.toggleDefines').toggle(function() {
|
18
|
+
tHeight = $(this).parent().prev().height();
|
19
|
+
$(this).prev().show();
|
20
|
+
$(this).parent().prev().height($(this).parent().height());
|
21
|
+
$(this).text("(less)");
|
22
|
+
},
|
23
|
+
function() {
|
24
|
+
$(this).prev().hide();
|
25
|
+
$(this).parent().prev().height(tHeight);
|
26
|
+
$(this).text("more...");
|
27
|
+
});
|
28
|
+
}
|
29
|
+
|
30
|
+
function createFullTreeLinks() {
|
31
|
+
var tHeight = 0;
|
32
|
+
$('.inheritanceTree').toggle(function() {
|
33
|
+
tHeight = $(this).parent().prev().height();
|
34
|
+
$(this).parent().toggleClass('showAll');
|
35
|
+
$(this).text("(hide)");
|
36
|
+
$(this).parent().prev().height($(this).parent().height());
|
37
|
+
},
|
38
|
+
function() {
|
39
|
+
$(this).parent().toggleClass('showAll');
|
40
|
+
$(this).parent().prev().height(tHeight);
|
41
|
+
$(this).text("show all");
|
42
|
+
});
|
43
|
+
}
|
44
|
+
|
45
|
+
function fixBoxInfoHeights() {
|
46
|
+
$('dl.box dd.r1, dl.box dd.r2').each(function() {
|
47
|
+
$(this).prev().height($(this).height());
|
48
|
+
});
|
49
|
+
}
|
50
|
+
|
51
|
+
function searchFrameLinks() {
|
52
|
+
$('.full_list_link').click(function() {
|
53
|
+
toggleSearchFrame(this, $(this).attr('href'));
|
54
|
+
return false;
|
55
|
+
});
|
56
|
+
}
|
57
|
+
|
58
|
+
function toggleSearchFrame(id, link) {
|
59
|
+
var frame = $('#search_frame');
|
60
|
+
$('#search a').removeClass('active').addClass('inactive');
|
61
|
+
if (frame.attr('src') == link && frame.css('display') != "none") {
|
62
|
+
frame.slideUp(100);
|
63
|
+
$('#search a').removeClass('active inactive');
|
64
|
+
}
|
65
|
+
else {
|
66
|
+
$(id).addClass('active').removeClass('inactive');
|
67
|
+
frame.attr('src', link).slideDown(100);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
function linkSummaries() {
|
72
|
+
$('.summary_signature').click(function() {
|
73
|
+
document.location = $(this).find('a').attr('href');
|
74
|
+
});
|
75
|
+
}
|
76
|
+
|
77
|
+
function framesInit() {
|
78
|
+
if (hasFrames) {
|
79
|
+
document.body.className = 'frames';
|
80
|
+
$('#menu .noframes a').attr('href', document.location);
|
81
|
+
window.top.document.title = $('html head title').text();
|
82
|
+
}
|
83
|
+
else {
|
84
|
+
$('#menu .noframes a').text('frames').attr('href', framesUrl);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
function keyboardShortcuts() {
|
89
|
+
if (window.top.frames.main) return;
|
90
|
+
$(document).keypress(function(evt) {
|
91
|
+
if (evt.altKey || evt.ctrlKey || evt.metaKey || evt.shiftKey) return;
|
92
|
+
if (typeof evt.target !== "undefined" &&
|
93
|
+
(evt.target.nodeName == "INPUT" ||
|
94
|
+
evt.target.nodeName == "TEXTAREA")) return;
|
95
|
+
switch (evt.charCode) {
|
96
|
+
case 67: case 99: $('#class_list_link').click(); break; // 'c'
|
97
|
+
case 77: case 109: $('#method_list_link').click(); break; // 'm'
|
98
|
+
case 70: case 102: $('#file_list_link').click(); break; // 'f'
|
99
|
+
default: break;
|
100
|
+
}
|
101
|
+
});
|
102
|
+
}
|
103
|
+
|
104
|
+
function summaryToggle() {
|
105
|
+
$('.summary_toggle').click(function() {
|
106
|
+
if (localStorage) {
|
107
|
+
localStorage.summaryCollapsed = $(this).text();
|
108
|
+
}
|
109
|
+
$('.summary_toggle').each(function() {
|
110
|
+
$(this).text($(this).text() == "collapse" ? "expand" : "collapse");
|
111
|
+
var next = $(this).parent().parent().nextAll('ul.summary').first();
|
112
|
+
if (next.hasClass('compact')) {
|
113
|
+
next.toggle();
|
114
|
+
next.nextAll('ul.summary').first().toggle();
|
115
|
+
}
|
116
|
+
else if (next.hasClass('summary')) {
|
117
|
+
var list = $('<ul class="summary compact" />');
|
118
|
+
list.html(next.html());
|
119
|
+
list.find('.summary_desc, .note').remove();
|
120
|
+
list.find('a').each(function() {
|
121
|
+
$(this).html($(this).find('strong').html());
|
122
|
+
$(this).parent().html($(this)[0].outerHTML);
|
123
|
+
});
|
124
|
+
next.before(list);
|
125
|
+
next.toggle();
|
126
|
+
}
|
127
|
+
});
|
128
|
+
return false;
|
129
|
+
});
|
130
|
+
if (localStorage) {
|
131
|
+
if (localStorage.summaryCollapsed == "collapse") {
|
132
|
+
$('.summary_toggle').first().click();
|
133
|
+
}
|
134
|
+
else localStorage.summaryCollapsed = "expand";
|
135
|
+
}
|
136
|
+
}
|
137
|
+
|
138
|
+
function fixOutsideWorldLinks() {
|
139
|
+
$('a').each(function() {
|
140
|
+
if (window.location.host != this.host) this.target = '_parent';
|
141
|
+
});
|
142
|
+
}
|
143
|
+
|
144
|
+
function generateTOC() {
|
145
|
+
if ($('#filecontents').length === 0) return;
|
146
|
+
var _toc = $('<ol class="top"></ol>');
|
147
|
+
var show = false;
|
148
|
+
var toc = _toc;
|
149
|
+
var counter = 0;
|
150
|
+
var tags = ['h2', 'h3', 'h4', 'h5', 'h6'];
|
151
|
+
var i;
|
152
|
+
if ($('#filecontents h1').length > 1) tags.unshift('h1');
|
153
|
+
for (i = 0; i < tags.length; i++) { tags[i] = '#filecontents ' + tags[i]; }
|
154
|
+
var lastTag = parseInt(tags[0][1], 10);
|
155
|
+
$(tags.join(', ')).each(function() {
|
156
|
+
if ($(this).parents('.method_details .docstring').length != 0) return;
|
157
|
+
if (this.id == "filecontents") return;
|
158
|
+
show = true;
|
159
|
+
var thisTag = parseInt(this.tagName[1], 10);
|
160
|
+
if (this.id.length === 0) {
|
161
|
+
var proposedId = $(this).attr('toc-id');
|
162
|
+
if (typeof(proposedId) != "undefined") this.id = proposedId;
|
163
|
+
else {
|
164
|
+
var proposedId = $(this).text().replace(/[^a-z0-9-]/ig, '_');
|
165
|
+
if ($('#' + proposedId).length > 0) { proposedId += counter; counter++; }
|
166
|
+
this.id = proposedId;
|
167
|
+
}
|
168
|
+
}
|
169
|
+
if (thisTag > lastTag) {
|
170
|
+
for (i = 0; i < thisTag - lastTag; i++) {
|
171
|
+
var tmp = $('<ol/>'); toc.append(tmp); toc = tmp;
|
172
|
+
}
|
173
|
+
}
|
174
|
+
if (thisTag < lastTag) {
|
175
|
+
for (i = 0; i < lastTag - thisTag; i++) toc = toc.parent();
|
176
|
+
}
|
177
|
+
var title = $(this).attr('toc-title');
|
178
|
+
if (typeof(title) == "undefined") title = $(this).text();
|
179
|
+
toc.append('<li><a href="#' + this.id + '">' + title + '</a></li>');
|
180
|
+
lastTag = thisTag;
|
181
|
+
});
|
182
|
+
if (!show) return;
|
183
|
+
html = '<div id="toc"><p class="title"><a class="hide_toc" href="#"><strong>Table of Contents</strong></a> <small>(<a href="#" class="float_toc">left</a>)</small></p></div>';
|
184
|
+
$('#content').prepend(html);
|
185
|
+
$('#toc').append(_toc);
|
186
|
+
$('#toc .hide_toc').toggle(function() {
|
187
|
+
$('#toc .top').slideUp('fast');
|
188
|
+
$('#toc').toggleClass('hidden');
|
189
|
+
$('#toc .title small').toggle();
|
190
|
+
}, function() {
|
191
|
+
$('#toc .top').slideDown('fast');
|
192
|
+
$('#toc').toggleClass('hidden');
|
193
|
+
$('#toc .title small').toggle();
|
194
|
+
});
|
195
|
+
$('#toc .float_toc').toggle(function() {
|
196
|
+
$(this).text('float');
|
197
|
+
$('#toc').toggleClass('nofloat');
|
198
|
+
}, function() {
|
199
|
+
$(this).text('left');
|
200
|
+
$('#toc').toggleClass('nofloat');
|
201
|
+
});
|
202
|
+
}
|
203
|
+
|
204
|
+
$(framesInit);
|
205
|
+
$(createSourceLinks);
|
206
|
+
$(createDefineLinks);
|
207
|
+
$(createFullTreeLinks);
|
208
|
+
$(fixBoxInfoHeights);
|
209
|
+
$(searchFrameLinks);
|
210
|
+
$(linkSummaries);
|
211
|
+
$(keyboardShortcuts);
|
212
|
+
$(summaryToggle);
|
213
|
+
$(fixOutsideWorldLinks);
|
214
|
+
$(generateTOC);
|