rweb 0.1.0

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/COPYING ADDED
@@ -0,0 +1,316 @@
1
+ GNU GENERAL PUBLIC LICENSE Version 2, June 1991
2
+
3
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite
4
+ 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute
5
+ verbatim copies of this license document, but changing it is not allowed.
6
+
7
+ Preamble
8
+
9
+ The licenses for most software are designed to take away your freedom to share
10
+ and change it. By contrast, the GNU General Public License is intended to
11
+ guarantee your freedom to share and change free software--to make sure the
12
+ software is free for all its users. This General Public License applies to most
13
+ of the Free Software Foundation's software and to any other program whose
14
+ authors commit to using it. (Some other Free Software Foundation software is
15
+ covered by the GNU Library General Public License instead.) You can apply it to
16
+ your programs, too.
17
+
18
+ When we speak of free software, we are referring to freedom, not price. Our
19
+ General Public Licenses are designed to make sure that you have the freedom to
20
+ distribute copies of free software (and charge for this service if you wish),
21
+ that you receive source code or can get it if you want it, that you can change
22
+ the software or use pieces of it in new free programs; and that you know you can
23
+ do these things.
24
+
25
+ To protect your rights, we need to make restrictions that forbid anyone to deny
26
+ you these rights or to ask you to surrender the rights. These restrictions
27
+ translate to certain responsibilities for you if you distribute copies of the
28
+ software, or if you modify it.
29
+
30
+ For example, if you distribute copies of such a program, whether gratis or for a
31
+ fee, you must give the recipients all the rights that you have. You must make
32
+ sure that they, too, receive or can get the source code. And you must show them
33
+ these terms so they know their rights.
34
+
35
+ We protect your rights with two steps: (1) copyright the software, and (2) offer
36
+ you this license which gives you legal permission to copy, distribute and/or
37
+ modify the software.
38
+
39
+ Also, for each author's protection and ours, we want to make certain that
40
+ everyone understands that there is no warranty for this free software. If the
41
+ software is modified by someone else and passed on, we want its recipients to
42
+ know that what they have is not the original, so that any problems introduced by
43
+ others will not reflect on the original authors' reputations.
44
+
45
+ Finally, any free program is threatened constantly by software patents. We wish
46
+ to avoid the danger that redistributors of a free program will individually
47
+ obtain patent licenses, in effect making the program proprietary. To prevent
48
+ this, we have made it clear that any patent must be licensed for everyone's free
49
+ use or not licensed at all.
50
+
51
+ The precise terms and conditions for copying, distribution and modification
52
+ follow.
53
+
54
+ GNU GENERAL PUBLIC LICENSE
55
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
56
+
57
+ 0. This License applies to any program or other work which contains a notice
58
+ placed by the copyright holder saying it may be distributed under the terms of
59
+ this General Public License. The "Program", below, refers to any such program or
60
+ work, and a "work based on the Program" means either the Program or any
61
+ derivative work under copyright law: that is to say, a work containing the
62
+ Program or a portion of it, either verbatim or with modifications and/or
63
+ translated into another language. (Hereinafter, translation is included without
64
+ limitation in the term "modification".) Each licensee is addressed as "you".
65
+
66
+ Activities other than copying, distribution and modification are not covered by
67
+ this License; they are outside its scope. The act of running the Program is not
68
+ restricted, and the output from the Program is covered only if its contents
69
+ constitute a work based on the Program (independent of having been made by
70
+ running the Program). Whether that is true depends on what the Program does.
71
+
72
+ 1. You may copy and distribute verbatim copies of the Program's source code as
73
+ you receive it, in any medium, provided that you conspicuously and appropriately
74
+ publish on each copy an appropriate copyright notice and disclaimer of warranty;
75
+ keep intact all the notices that refer to this License and to the absence of any
76
+ warranty; and give any other recipients of the Program a copy of this License
77
+ along with the Program.
78
+
79
+ You may charge a fee for the physical act of transferring a copy, and you may at
80
+ your option offer warranty protection in exchange for a fee.
81
+
82
+ 2. You may modify your copy or copies of the Program or any portion of it, thus
83
+ forming a work based on the Program, and copy and distribute such modifications
84
+ or work under the terms of Section 1 above, provided that you also meet all of
85
+ these conditions:
86
+
87
+ a) You must cause the modified files to carry prominent notices stating that
88
+ you changed the files and the date of any change.
89
+
90
+ b) You must cause any work that you distribute or publish, that in whole or in
91
+ part contains or is derived from the Program or any part thereof, to be
92
+ licensed as a whole at no charge to all third parties under the terms of this
93
+ License.
94
+
95
+ c) If the modified program normally reads commands interactively when run, you
96
+ must cause it, when started running for such interactive use in the most
97
+ ordinary way, to print or display an announcement including an appropriate
98
+ copyright notice and a notice that there is no warranty (or else, saying that
99
+ you provide a warranty) and that users may redistribute the program under
100
+ these conditions, and telling the user how to view a copy of this License.
101
+ (Exception: if the Program itself is interactive but does not normally print
102
+ such an announcement, your work based on the Program is not required to print
103
+ an announcement.)
104
+
105
+ These requirements apply to the modified work as a whole. If identifiable
106
+ sections of that work are not derived from the Program, and can be reasonably
107
+ considered independent and separate works in themselves, then this License, and
108
+ its terms, do not apply to those sections when you distribute them as separate
109
+ works. But when you distribute the same sections as part of a whole which is a
110
+ work based on the Program, the distribution of the whole must be on the terms of
111
+ this License, whose permissions for other licensees extend to the entire whole,
112
+ and thus to each and every part regardless of who wrote it.
113
+
114
+ Thus, it is not the intent of this section to claim rights or contest your
115
+ rights to work written entirely by you; rather, the intent is to exercise the
116
+ right to control the distribution of derivative or collective works based on the
117
+ Program.
118
+
119
+ In addition, mere aggregation of another work not based on the Program with the
120
+ Program (or with a work based on the Program) on a volume of a storage or
121
+ distribution medium does not bring the other work under the scope of this
122
+ License.
123
+
124
+ 3. You may copy and distribute the Program (or a work based on it, under Section
125
+ 2) in object code or executable form under the terms of Sections 1 and 2 above
126
+ provided that you also do one of the following:
127
+
128
+ a) Accompany it with the complete corresponding machine-readable source code,
129
+ which must be distributed under the terms of Sections 1 and 2 above on a
130
+ medium customarily used for software interchange; or,
131
+
132
+ b) Accompany it with a written offer, valid for at least three years, to give
133
+ any third party, for a charge no more than your cost of physically performing
134
+ source distribution, a complete machine-readable copy of the corresponding
135
+ source code, to be distributed under the terms of Sections 1 and 2 above on a
136
+ medium customarily used for software interchange; or,
137
+
138
+ c) Accompany it with the information you received as to the offer to
139
+ distribute corresponding source code. (This alternative is allowed only for
140
+ noncommercial distribution and only if you received the program in object code
141
+ or executable form with such an offer, in accord with Subsection b above.)
142
+
143
+ The source code for a work means the preferred form of the work for making
144
+ modifications to it. For an executable work, complete source code means all the
145
+ source code for all modules it contains, plus any associated interface
146
+ definition files, plus the scripts used to control compilation and installation
147
+ of the executable. However, as a special exception, the source code distributed
148
+ need not include anything that is normally distributed (in either source or
149
+ binary form) with the major components (compiler, kernel, and so on) of the
150
+ operating system on which the executable runs, unless that component itself
151
+ accompanies the executable.
152
+
153
+ If distribution of executable or object code is made by offering access to copy
154
+ from a designated place, then offering equivalent access to copy the source code
155
+ from the same place counts as distribution of the source code, even though third
156
+ parties are not compelled to copy the source along with the object code.
157
+
158
+ 4. You may not copy, modify, sublicense, or distribute the Program except as
159
+ expressly provided under this License. Any attempt otherwise to copy, modify,
160
+ sublicense or distribute the Program is void, and will automatically terminate
161
+ your rights under this License. However, parties who have received copies, or
162
+ rights, from you under this License will not have their licenses terminated so
163
+ long as such parties remain in full compliance.
164
+
165
+ 5. You are not required to accept this License, since you have not signed it.
166
+ However, nothing else grants you permission to modify or distribute the Program
167
+ or its derivative works. These actions are prohibited by law if you do not
168
+ accept this License. Therefore, by modifying or distributing the Program (or any
169
+ work based on the Program), you indicate your acceptance of this License to do
170
+ so, and all its terms and conditions for copying, distributing or modifying the
171
+ Program or works based on it.
172
+
173
+ 6. Each time you redistribute the Program (or any work based on the Program),
174
+ the recipient automatically receives a license from the original licensor to
175
+ copy, distribute or modify the Program subject to these terms and conditions.
176
+ You may not impose any further restrictions on the recipients' exercise of the
177
+ rights granted herein. You are not responsible for enforcing compliance by third
178
+ parties to this License.
179
+
180
+ 7. If, as a consequence of a court judgment or allegation of patent infringement
181
+ or for any other reason (not limited to patent issues), conditions are imposed
182
+ on you (whether by court order, agreement or otherwise) that contradict the
183
+ conditions of this License, they do not excuse you from the conditions of this
184
+ License. If you cannot distribute so as to satisfy simultaneously your
185
+ obligations under this License and any other pertinent obligations, then as a
186
+ consequence you may not distribute the Program at all. For example, if a patent
187
+ license would not permit royalty-free redistribution of the Program by all those
188
+ who receive copies directly or indirectly through you, then the only way you
189
+ could satisfy both it and this License would be to refrain entirely from
190
+ distribution of the Program.
191
+
192
+ If any portion of this section is held invalid or unenforceable under any
193
+ particular circumstance, the balance of the section is intended to apply and the
194
+ section as a whole is intended to apply in other circumstances.
195
+
196
+ It is not the purpose of this section to induce you to infringe any patents or
197
+ other property right claims or to contest validity of any such claims; this
198
+ section has the sole purpose of protecting the integrity of the free software
199
+ distribution system, which is implemented by public license practices. Many
200
+ people have made generous contributions to the wide range of software
201
+ distributed through that system in reliance on consistent application of that
202
+ system; it is up to the author/donor to decide if he or she is willing to
203
+ distribute software through any other system and a licensee cannot impose that
204
+ choice.
205
+
206
+ This section is intended to make thoroughly clear what is believed to be a
207
+ consequence of the rest of this License.
208
+
209
+ 8. If the distribution and/or use of the Program is restricted in certain
210
+ countries either by patents or by copyrighted interfaces, the original copyright
211
+ holder who places the Program under this License may add an explicit
212
+ geographical distribution limitation excluding those countries, so that
213
+ distribution is permitted only in or among countries not thus excluded. In such
214
+ case, this License incorporates the limitation as if written in the body of this
215
+ License.
216
+
217
+ 9. The Free Software Foundation may publish revised and/or new versions of the
218
+ General Public License from time to time. Such new versions will be similar in
219
+ spirit to the present version, but may differ in detail to address new problems
220
+ or concerns.
221
+
222
+ Each version is given a distinguishing version number. If the Program specifies
223
+ a version number of this License which applies to it and "any later version",
224
+ you have the option of following the terms and conditions either of that version
225
+ or of any later version published by the Free Software Foundation. If the
226
+ Program does not specify a version number of this License, you may choose any
227
+ version ever published by the Free Software Foundation.
228
+
229
+ 10. If you wish to incorporate parts of the Program into other free programs
230
+ whose distribution conditions are different, write to the author to ask for
231
+ permission. For software which is copyrighted by the Free Software Foundation,
232
+ write to the Free Software Foundation; we sometimes make exceptions for this.
233
+ Our decision will be guided by the two goals of preserving the free status of
234
+ all derivatives of our free software and of promoting the sharing and reuse of
235
+ software generally.
236
+
237
+ NO WARRANTY
238
+
239
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE
240
+ PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED
241
+ IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS
242
+ IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT
243
+ NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
244
+ PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
245
+ PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
246
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
247
+
248
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
249
+ ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE
250
+ PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
251
+ SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY
252
+ TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
253
+ RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF
254
+ THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
255
+ PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
256
+
257
+ END OF TERMS AND CONDITIONS
258
+
259
+ How to Apply These Terms to Your New Programs
260
+
261
+ If you develop a new program, and you want it to be of the greatest possible use
262
+ to the public, the best way to achieve this is to make it free software which
263
+ everyone can redistribute and change under these terms.
264
+
265
+ To do so, attach the following notices to the program. It is safest to attach
266
+ them to the start of each source file to most effectively convey the exclusion
267
+ of warranty; and each file should have at least the "copyright" line and a
268
+ pointer to where the full notice is found.
269
+
270
+ <one line to give the program's name and a brief idea of what it does.>
271
+ Copyright (C) 19yy <name of author>
272
+
273
+ This program is free software; you can redistribute it and/or modify it under
274
+ the terms of the GNU General Public License as published by the Free Software
275
+ Foundation; either version 2 of the License, or (at your option) any later
276
+ version.
277
+
278
+ This program is distributed in the hope that it will be useful, but WITHOUT
279
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
280
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
281
+
282
+ You should have received a copy of the GNU General Public License along with
283
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
284
+ Place, Suite 330, Boston, MA 02111-1307 USA
285
+
286
+ Also add information on how to contact you by electronic and paper mail.
287
+
288
+ If the program is interactive, make it output a short notice like this when it
289
+ starts in an interactive mode:
290
+
291
+ Gnomovision version 69, Copyright (C) 19yy name of author
292
+
293
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This
294
+ is free software, and you are welcome to redistribute it under certain
295
+ conditions; type `show c' for details.
296
+
297
+ The hypothetical commands `show w' and `show c' should show the appropriate
298
+ parts of the General Public License. Of course, the commands you use may be
299
+ called something other than `show w' and `show c'; they could even be mouse-
300
+ clicks or menu items--whatever suits your program.
301
+
302
+ You should also get your employer (if you work as a programmer) or your school,
303
+ if any, to sign a "copyright disclaimer" for the program, if necessary. Here is
304
+ a sample; alter the names:
305
+
306
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
307
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
308
+
309
+ <signature of Ty Coon>, 1 April 1989
310
+ Ty Coon, President of Vice
311
+
312
+ This General Public License does not permit incorporating your program into
313
+ proprietary programs. If your program is a subroutine library, you may consider
314
+ it more useful to permit linking proprietary applications with the library. If
315
+ this is what you want to do, use the GNU Library General Public License instead
316
+ of this License.
@@ -0,0 +1,5 @@
1
+ = Release History
2
+ Version 0.1.0 (2007-08-04)::
3
+ - complete library for tangling as well as for weaving to plaintext
4
+ - RDOC documentation completed
5
+ - full test suite completed
@@ -0,0 +1,132 @@
1
+ = Introduction
2
+ Welcome to the _RWEB_ package. _RWEB_ is several things:
3
+ - it is a library providing the tools to do literate programming in Ruby;
4
+ - it is a utility to permit self-tangling (executable) literate Ruby programs;
5
+ - it is a set of external utilities to do tangling and weaving of literate
6
+ Ruby programs in the more traditional form you see based on Knuth's WEB;
7
+ - it is a framework for customizing the weaving process to enable any back-end
8
+ the user desires to use for generating documentation.
9
+
10
+ == This release
11
+ This release of _RWEB_ only handles plain text for weaving and has the basic
12
+ framework for handling XHTML in the planning pipeline. It is very much a bare-
13
+ bones system, albeit a usable one. The files of note are:
14
+
15
+ lib/rweb.rb::
16
+ This is the library file that does the heavy lifting for the package. It needs
17
+ to be required ("require 'rweb'") and it exposes in return the module _RWEB_.
18
+ The module exposes two functions: tangle and weave. Everything else in the
19
+ module is private utility functions.
20
+
21
+ bin/rtangle and bin/rweave::
22
+ These scripts are self-tangling _RWEB_ documents in plain text format which
23
+ tangle and weave respectively _RWEB_ documents and generate appropriate
24
+ output.
25
+
26
+ COPYING::
27
+ The license under which this program is released. Read it. Know your rights
28
+ (and wrongs).
29
+
30
+ = User's Guide
31
+ _RWEB_ is a very simple format for writing literate programs inspired by Donald
32
+ Knuth's WEB program. An _RWEB_ file has the following structure:
33
+ - Self-tangling boilerplate
34
+ - Directives
35
+ - Documentation and code chunks in alternation
36
+
37
+ == Self-tangling boilerplate
38
+ For sheer convenience it is difficult to beat the ability to directly execute
39
+ _RWEB_ documents instead of having to manually "tangle" the document into
40
+ executable code. The key to doing this is attaching some boilerplate Ruby code
41
+ to the head of an _RWEB_ document and writing the program underneath this. The
42
+ boilerplate should look something like this:
43
+
44
+ #! /usr/bin/ruby -w
45
+ require 'rubygems'
46
+ require 'rweb'
47
+ eval RWEB.tangle(DATA)
48
+ __END__
49
+
50
+ All this code does is require the libraries needed to execute itself (this
51
+ assumes here that rweb has been installed as a gem), call <tt>RWEB.tangle</tt>
52
+ with the special +DATA+ variable and then terminate itself with the +__END__+
53
+ directive. The +DATA+ object contains all of the text after the +__END__+
54
+ directive which, in this case, is our _RWEB_ document. The returned string is
55
+ then evaluated as per usual Ruby methods.
56
+
57
+ == Directives
58
+ Instead of using command line options and confusing the interaction between the
59
+ self-tangling boilerplate and the underlying program, _RWEB_ controls the
60
+ generation of documentation (not code!) with a block of directives. Directives
61
+ have the following syntax:
62
+
63
+ {keys => value}
64
+
65
+ Currently only two keys are supported:
66
+ - style
67
+ - title
68
+
69
+ The +style+ key reflects the documentation style used in the underlying _RWEB_
70
+ document. As of this version the style can only accept the values +Plain+ and
71
+ +XHTML+ and, further, the style +XHTML+ is not yet implemented. Future releases
72
+ will implement XHTML style and will provide tools for user-extended styles to be
73
+ included in the mix.
74
+
75
+ The title key is simply text used while generating the documentation and code
76
+ which provides a title to the work. If left unset, it defaults to +Untitled+.
77
+
78
+ == Code chunks
79
+
80
+ After the directives block (if present) is passed, _RWEB_ begins in
81
+ documentation mode. Any text in documentation segments is taken verbatim by the
82
+ processor and passed on without alteration to the style processors later when
83
+ weaving. A documentation segment ends with the beginning of a code segment.
84
+
85
+ === Starting a code chunk
86
+ A code segment is identified by the use of this tag:
87
+
88
+ << name {
89
+
90
+ The name is optional and may consist of any printable characters including
91
+ whitespace. Any leading or trailing whitespace, however, is stripped before the
92
+ name is used internally. This tag opens a named chunk of code when first
93
+ encountered and copies all text between it and the closing tag into it. If a
94
+ chunk is named several times, subsequent openings just add text to the existing
95
+ chunk, thus allowing a chunk to be divided up for purposes of explanation.
96
+
97
+ === Ending a code chunk
98
+ A chunk is closed with the following tag:
99
+
100
+ }>>
101
+
102
+ Note that chunk tags (both opening and closing) *must* begin in the left-most
103
+ column with *no* whitespace nor other characters in front. There must be nothing
104
+ but whitespace at the end of them as well. _RWEB_ is not a general-purpose
105
+ templating system. It is a literate programming tool only.
106
+
107
+ === Code chunk references
108
+ Within a code chunk, another code chunk may be referenced by the following tag:
109
+
110
+ {<<name>>}
111
+
112
+ A code chunk reference may only have whitespace ahead of it and behind it.
113
+ (Again _RWEB_ is not a templating system.) Any whitespace in front of it is
114
+ replicated for each line of the named chunk, thus allowing the output code to be
115
+ readable. Any attempt to put something other than whitespace in front or behind
116
+ the chunk reference is a runtime error.
117
+
118
+ Note that code chunk references are completely ignored in documentation
119
+ segments.
120
+
121
+ === Mainline code chunk
122
+ The name of a code chunk is optional. Any code chunks without a name form the
123
+ special mainline code chunk that is used as the base chunk from which all other
124
+ chunks are expanded. As with any chunk, the mainline chunk can be opened and
125
+ closed repeatedly with each re-opening causing more text to be appended to it.
126
+ There *must* be a mainline chunk in each _RWEB_ document.
127
+
128
+ == Examples of use
129
+ The utilities in <tt>./bin</tt> as well as the test cases in
130
+ <tt>./tests</tt> should give ideas on how _RWEB_ documents are structured
131
+ and used. Too, some examples are provided in the <tt>./docs</tt> directory
132
+ both of _RWEB_ documents as well as of weaved output.